Skip to content

Commit

Permalink
render notice when viewing an archived gem
Browse files Browse the repository at this point in the history
  • Loading branch information
colby-swandale committed Aug 15, 2024
1 parent b41ec50 commit 2faf872
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/rubygems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def index
def show
@versions = @rubygem.public_versions.limit(5)
@adoption = @rubygem.ownership_call

flash[:notice] = t(".archived_notice") if @rubygem.archived?

if @versions.to_a.any?
render "show"
else
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ en:
show_all_versions: Show all versions (%{count} total)
versions_header: Versions
yanked_notice: This version has been yanked, and it is not available for download directly or for other gems that may have depended on it.
archived_notice: This gem has been archived. It is now read-only and will not accept new versions.
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:
Expand Down
11 changes: 11 additions & 0 deletions test/functional/rubygems_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,17 @@ class RubygemsControllerTest < ActionController::TestCase
end
end

context "on GET to show for an archived gem" do
setup do
@rubygem = create(:rubygem, :archived)
get :show, params: { id: @rubygem.slug }
end

should "render a notice indicating the gem has been archived" do
assert page.has_content? I18n.t("rubygems.show.archived_notice")
end
end

context "When not logged in" do
context "On GET to show for a gem" do
setup do
Expand Down

0 comments on commit 2faf872

Please sign in to comment.