Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pusher_id to /api/v1/:gem/versions/:version #3765

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions app/models/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def downloads_count
def payload
{
"authors" => authors,
"pusher_id" => pusher_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we include raw IDs elsewhere in API responses? Would this make more sense to embed "pusher" => @pusher&.payload or something like that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Interesting - I definitely would prefer that we have more data on the user (at least what's exposed on the RubyGems gem page right now), but I wasn't sure what information the team would like to expose, since we currently don't include any user fields. Do you have any opinions on that front?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, raw ID is already at profiles API like https://rubygems.org/api/v1/profiles/simi.json and it accepts ID as well https://rubygems.org/api/v1/profiles/42601.json.

"built_at" => built_at,
"created_at" => created_at,
"description" => description,
Expand Down
6 changes: 4 additions & 2 deletions test/models/version_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ class VersionTest < ActiveSupport::TestCase
should "only have relevant API fields" do
json = @version.as_json

fields = %w[number built_at summary description authors platform
fields = %w[number built_at summary description authors pusher_id platform
ruby_version rubygems_version prerelease downloads_count licenses
requirements sha metadata created_at]

assert_equal fields.map(&:to_s).sort, json.keys.sort
assert_equal @version.authors, json["authors"]
assert_equal @version.pusher_id.to_s, json["pusher_id"]
assert_equal @version.built_at, json["built_at"]
assert_equal @version.created_at, json["created_at"]
assert_equal @version.description, json["description"]
Expand All @@ -41,13 +42,14 @@ class VersionTest < ActiveSupport::TestCase

should "only have relevant API fields" do
xml = Nokogiri.parse(@version.to_xml)
fields = %w[number built-at summary description authors platform
fields = %w[number built-at summary description authors pusher-id platform
ruby-version rubygems-version prerelease downloads-count licenses
requirements sha metadata created-at]

assert_equal fields.map(&:to_s).sort,
xml.root.children.map(&:name).reject { |t| t == "text" }.sort
assert_equal @version.authors, xml.at_css("authors").content
assert_equal @version.pusher_id.to_s, xml.at_css("pusher-id").content
assert_equal @version.built_at.iso8601, xml.at_css("built-at").content
assert_equal @version.description, xml.at_css("description").content
assert_equal @version.downloads_count, xml.at_css("downloads-count").content.to_i
Expand Down