Skip to content

Commit

Permalink
Add change log links to gem page w/o table change
Browse files Browse the repository at this point in the history
This takes changelog out of the Links table

Tried to keep as much of the commits from @olivierlacan and @jaymcgavren
as possible.
  • Loading branch information
kbrock committed Mar 8, 2017
1 parent 65acac2 commit 06996e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/models/links.rb
Expand Up @@ -2,6 +2,7 @@ class Links
# Links available for indexed gems
LINKS = {
'home' => 'homepage_uri',
'changelog' => 'changelog_uri',
'code' => 'source_code_uri',
'docs' => 'documentation_uri',
'wiki' => 'wiki_uri',
Expand Down Expand Up @@ -54,10 +55,11 @@ def download_uri

# define getters for each of the uris (both short `home` or long `homepage_uri` versions)
# don't define for download_uri since it has special logic and is already defined
# using a try because linkset does not define all the uri attributes
LINKS.each do |short, long|
unless method_defined?(long)
define_method(long) do
version.metadata[long].presence || linkset&.public_send(short)
version.metadata[long].presence || linkset.try(short)
end
end
alias_method short, long
Expand Down
4 changes: 3 additions & 1 deletion test/unit/rubygem_test.rb
Expand Up @@ -457,7 +457,8 @@ class RubygemTest < ActiveSupport::TestCase
"documentation_uri" => "http://example.com/docs",
"mailing_list_uri" => "http://example.com/mail",
"source_code_uri" => "http://example.com/code",
"bug_tracker_uri" => "http://example.com/bugs"
"bug_tracker_uri" => "http://example.com/bugs",
"changelog_uri" => "http://example.com/change"
}
)

Expand All @@ -469,6 +470,7 @@ class RubygemTest < ActiveSupport::TestCase
assert_equal "http://example.com/mail", hash["mailing_list_uri"]
assert_equal "http://example.com/code", hash["source_code_uri"]
assert_equal "http://example.com/bugs", hash["bug_tracker_uri"]
assert_equal "http://example.com/change", hash["changelog_uri"]
end

should "return version documentation url if metadata and linkset docs is empty" do
Expand Down

0 comments on commit 06996e6

Please sign in to comment.