Skip to content

Commit

Permalink
fixes rubygem blank documentation url
Browse files Browse the repository at this point in the history
  • Loading branch information
farukaydin committed Jun 15, 2015
1 parent 855f8a6 commit 01a4c21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def payload(version=versions.most_recent, host_with_port=Gemcutter::HOST)
'gem_uri' => "http://#{host_with_port}/gems/#{version.full_name}.gem",
'homepage_uri' => linkset.try(:home),
'wiki_uri' => linkset.try(:wiki),
'documentation_uri' => linkset.try(:docs) || version.documentation_path,
'documentation_uri' => linkset.try(:docs).presence || version.documentation_path,
'mailing_list_uri' => linkset.try(:mail),
'source_code_uri' => linkset.try(:code),
'bug_tracker_uri' => linkset.try(:bugs),
Expand Down
10 changes: 9 additions & 1 deletion test/unit/rubygem_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class RubygemTest < ActiveSupport::TestCase
context "with a linkset" do
setup do
@rubygem = build(:rubygem)
version = create(:version, :rubygem => @rubygem)
@version = create(:version, :rubygem => @rubygem)
end

should "return a bunch of JSON" do
Expand All @@ -388,6 +388,14 @@ class RubygemTest < ActiveSupport::TestCase
assert_equal @rubygem.linkset.bugs, hash["bug_tracker_uri"]
end

should "return version documentation url if linkset docs is empty" do
@rubygem.linkset.docs = ""
@rubygem.save
hash = MultiJson.load(@rubygem.to_json)

assert_equal @version.documentation_path, hash["documentation_uri"]
end

should "return a bunch of XML" do
doc = Nokogiri.parse(@rubygem.to_xml)

Expand Down

0 comments on commit 01a4c21

Please sign in to comment.