Skip to content

Commit

Permalink
Add funding links to sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Oct 1, 2020
1 parent c3fb97c commit 9275dde
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/models/concerns/rubygem_searchable.rb
Expand Up @@ -35,6 +35,7 @@ def as_indexed_json(_options = {}) # rubocop:disable Metrics/MethodLength
source_code_uri: versioned_links&.source_code_uri,
bug_tracker_uri: versioned_links&.bug_tracker_uri,
changelog_uri: versioned_links&.changelog_uri,
funding_uri: versioned_links&.funding_uri,
yanked: versions.none?(&:indexed?),
summary: latest_version&.summary,
description: latest_version&.description,
Expand Down
3 changes: 2 additions & 1 deletion app/models/links.rb
Expand Up @@ -8,7 +8,8 @@ class Links
"wiki" => "wiki_uri",
"mail" => "mailing_list_uri",
"bugs" => "bug_tracker_uri",
"download" => "download_uri"
"download" => "download_uri",
"funding" => "funding_uri"
}.freeze

# Links available for non-indexed gems
Expand Down
1 change: 1 addition & 0 deletions app/models/rubygem.rb
Expand Up @@ -187,6 +187,7 @@ def payload(version = versions.most_recent, protocol = Gemcutter::PROTOCOL, host
"source_code_uri" => versioned_links.source_code_uri,
"bug_tracker_uri" => versioned_links.bug_tracker_uri,
"changelog_uri" => versioned_links.changelog_uri,
"funding_uri" => versioned_links.funding_uri,
"dependencies" => {
"development" => deps.select { |r| r.rubygem && r.scope == "development" },
"runtime" => deps.select { |r| r.rubygem && r.scope == "runtime" }
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -44,6 +44,7 @@ en:
docs: Documentation URL
mail: Mailing List URL
wiki: Wiki URL
funding: Funding URL
session:
password: Password
who: Email or Username
Expand Down
1 change: 1 addition & 0 deletions lib/elastic_searcher.rb
Expand Up @@ -99,6 +99,7 @@ def api_source
wiki_uri
documentation_uri
mailing_list_uri
funding_uri
source_code_uri
bug_tracker_uri
changelog_uri]
Expand Down
3 changes: 2 additions & 1 deletion test/unit/pusher_test.rb
Expand Up @@ -292,7 +292,7 @@ class PusherTest < ActiveSupport::TestCase
end

should "create rubygem index" do
@rubygem.update_column("updated_at", Date.new(2016, 07, 04))
@rubygem.update_column("updated_at", Date.new(2016, 0o7, 0o4))
Delayed::Worker.new.work_off
response = Rubygem.__elasticsearch__.client.get index: "rubygems-#{Rails.env}",
type: "rubygem",
Expand All @@ -317,6 +317,7 @@ class PusherTest < ActiveSupport::TestCase
"source_code_uri" => "http://example.com",
"bug_tracker_uri" => "http://example.com",
"changelog_uri" => nil,
"funding_uri" => nil,
"yanked" => false,
"summary" => "old summary",
"description" => "Some awesome gem",
Expand Down
1 change: 1 addition & 0 deletions test/unit/rubygem_searchable_test.rb
Expand Up @@ -45,6 +45,7 @@ class RubygemSearchableTest < ActiveSupport::TestCase
mailing_list_uri: "http://example.com",
source_code_uri: "http://example.com",
bug_tracker_uri: "http://example.com",
funding_uri: "http://example.com",
yanked: false,
summary: "some summary",
description: "some description",
Expand Down
5 changes: 4 additions & 1 deletion test/unit/rubygem_test.rb
Expand Up @@ -458,7 +458,8 @@ class RubygemTest < ActiveSupport::TestCase
"mailing_list_uri" => "http://example.com/mail",
"source_code_uri" => "http://example.com/code",
"bug_tracker_uri" => "http://example.com/bugs",
"changelog_uri" => "http://example.com/change"
"changelog_uri" => "http://example.com/change",
"funding_uri" => "http://example.com/funding"
}
)

Expand All @@ -471,6 +472,7 @@ class RubygemTest < ActiveSupport::TestCase
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"]
assert_equal "http://example.com/funding", hash["funding_uri"]
end

should "return version documentation url if metadata and linkset docs is empty" do
Expand Down Expand Up @@ -498,6 +500,7 @@ class RubygemTest < ActiveSupport::TestCase
assert_equal @rubygem.linkset.mail, hash["mailing_list_uri"]
assert_equal @rubygem.linkset.code, hash["source_code_uri"]
assert_equal @rubygem.linkset.bugs, hash["bug_tracker_uri"]
assert_equal @rubygem.linkset.funding, hash["funding_uri"]
end

should "return version documentation uri if linkset docs is empty" do
Expand Down

0 comments on commit 9275dde

Please sign in to comment.