Skip to content
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
10 changes: 4 additions & 6 deletions app/helpers/rubygems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def formatted_licenses(license_names)
end
end

def link_to_page(text, url)
link_to(text, url, rel: 'nofollow', class: ['gem__link', 't-list__item']) if url.present?
def link_to_page(id, url)
link_to(t(".links.#{id}"), url, rel: 'nofollow', class: ['gem__link', 't-list__item'], id: id) if url.present?
end

def link_to_directory
Expand Down Expand Up @@ -65,14 +65,12 @@ def atom_link(rubygem)
end

def download_link(version)
link_to t('.links.download'), "/downloads/#{version.full_name}.gem",
class: 'gem__link t-list__item', id: :download
link_to_page :download, "/downloads/#{version.full_name}.gem"
end

def documentation_link(version, linkset)
return unless linkset.nil? || linkset.docs.blank?
link_to t('.links.docs'), version.documentation_path,
class: 'gem__link t-list__item', id: :docs
link_to_page :docs, version.documentation_path
end

def badge_link(rubygem)
Expand Down
2 changes: 1 addition & 1 deletion app/views/rubygems/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<% if @latest_version.indexed %>
<% if @rubygem.linkset.present? %>
<%- Linkset::LINKS.each do |link| %>
<%= link_to_page t("rubygems.show.links.#{link}"), @rubygem.linkset.public_send(link) %>
<%= link_to_page link, @rubygem.linkset.public_send(link) %>
<%- end %>
<% end %>

Expand Down
9 changes: 5 additions & 4 deletions test/unit/helpers/rubygems_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,23 @@ class RubygemsHelperTest < ActionView::TestCase
@linkset = build(:linkset)
@linkset.wiki = nil
@linkset.code = ""
@virtual_path = "rubygems.show"
end

should "create link for homepage" do
assert_match @linkset.home, link_to_page("Homepage", @linkset.home)
assert_match @linkset.home, link_to_page(:home, @linkset.home)
end

should "be a nofollow link" do
assert_match 'rel="nofollow"', link_to_page("Homepage", @linkset.home)
assert_match 'rel="nofollow"', link_to_page(:home, @linkset.home)
end

should "not create link for wiki" do
assert_nil link_to_page("Wiki", @linkset.wiki)
assert_nil link_to_page(:wiki, @linkset.wiki)
end

should "not create link for code" do
assert_nil link_to_page("Code", @linkset.code)
assert_nil link_to_page(:code, @linkset.code)
end
end

Expand Down