Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow access to some sidebar controls for owners of fully yanked gems #5260

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/rubygems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def unsubscribe_link(rubygem)

link_to t("rubygems.aside.links.unsubscribe"), rubygem_subscription_path(rubygem.slug),
class: [:toggler, "gem__link", "t-list__item", style], id: "unsubscribe",
method: :delete, remote: true
method: :delete
end

def change_diff_link(rubygem, latest_version)
Expand Down
23 changes: 23 additions & 0 deletions app/views/rubygems/_aside_yanked.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="gem__aside l-col--r--pad">
<% if @adoption %>
<%= link_to "adoption", rubygem_adoptions_path(@rubygem.slug), class: "adoption__tag" %>
<% end %>

<% if @rubygem.metadata_mfa_required? %>
<h2 class="gem__ruby-version__heading t-list__heading">
<%= t('.requires_mfa') %>:
<span class="gem__ruby-version">
true
</span>
</h2>
<% end %>
<div class="t-list__items">
<%= unsubscribe_link(@rubygem) %>
<%= ownership_link(@rubygem) if policy(@rubygem).show_unconfirmed_ownerships? %>
<%= rubygem_trusted_publishers_link(@rubygem) if policy(@rubygem).configure_trusted_publishers? %>
<%= oidc_api_key_role_links(@rubygem) if policy(@rubygem).configure_oidc? %>
<%= resend_owner_confirmation_link(@rubygem) if @rubygem.unconfirmed_ownership?(current_user) %>
<%= rubygem_adoptions_link(@rubygem) if policy(@rubygem).show_adoption? %>
<%= rubygem_security_events_link(@rubygem) if policy(@rubygem).show_events? %>
</div>
</div>
2 changes: 2 additions & 0 deletions app/views/rubygems/show_yanked.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
<%= render partial: "rubygems/gem_members", locals: { latest_version: @latest_version, rubygem: @rubygem } %>
<% end %>
</div>

<%= render "rubygems/aside_yanked" %>
</div>
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ en:
show_yanked:
not_hosted_notice: This gem is not currently hosted on RubyGems.org. Yanked versions of this gem may already exist.
reserved_namespace_html:
one: This gem previously existed, but has been removed by its owner. The RubyGems.org team has reserved this gem name for 1 more day. After that time is up, anyone will be able to claim this gem name using gem push. <br/> If you are the previous owner of this gem, you can change ownership of this gem using the gem owner command. You can also create new versions of this gem using gem push.
other: This gem previously existed, but has been removed by its owner. The RubyGems.org team has reserved this gem name for %{count} more days. After that time is up, anyone will be able to claim this gem name using gem push. <br/> If you are the previous owner of this gem, you can change ownership of this gem using the gem owner command. You can also create new versions of this gem using gem push.
one: This gem previously existed, but has been removed by its owner. The RubyGems.org team has reserved this gem name for 1 more day. After that time is up, anyone will be able to claim this gem name using gem push. <br/><br/> If you are the previous owner of this gem, you can change ownership of this gem using the gem owner command or create new versions of this gem using gem push.
other: This gem previously existed, but has been removed by its owner. The RubyGems.org team has reserved this gem name for %{count} more days. After that time is up, anyone will be able to claim this gem name using gem push. <br/><br/> If you are the previous owner of this gem, you can change ownership of this gem using the gem owner command or create new versions of this gem using gem push.
security_events:
title: Security Events
description_html: "This page shows the security events that have occurred on %{gem}. If you see any suspicious activity, please <a href='mailto:[email protected]'>contact support</a>."
Expand Down
25 changes: 25 additions & 0 deletions test/integration/rubygems_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,29 @@ class RubygemsTest < ActionDispatch::IntegrationTest

assert page.has_content? "Provenance"
end

test "GET to show for a fully yanked gem as owner" do
user = create(:user, remember_token_expires_at: Gemcutter::REMEMBER_FOR.from_now)
rubygem = create(:rubygem, owners: [user], number: "1.0.0", created_at: 2.months.ago)
version = rubygem.versions.sole
user.deletions.create!(version:)
rubygem.reload

assert_predicate rubygem.public_versions.to_a, :empty?

get "/gems/#{rubygem.name}"

assert page.has_content? "This gem previously existed, but has been removed by its owner."
refute page.has_link? "Owners"
refute page.has_link? "Trusted publishers"
refute page.has_link? "Security Events"

post session_path(session: { who: user.handle, password: PasswordHelpers::SECURE_TEST_PASSWORD })

get "/gems/#{rubygem.name}"

assert page.has_link? "Owners"
assert page.has_link? "Trusted publishers"
assert page.has_link? "Security Events"
end
end