Skip to content

Commit

Permalink
Merge pull request #1946 from rubygems/yanked_version_details
Browse files Browse the repository at this point in the history
show downloads and license information for yanked versions too
  • Loading branch information
dwradcliffe authored Apr 5, 2019
2 parents cfcca34 + 7a927d7 commit 8437253
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/downloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index
def show
full_name = params[:id]
version = Version.find_by(full_name: full_name)
if version && !version.yanked?
if version
data = {
total_downloads: GemDownload.count_for_rubygem(version.rubygem_id),
version_downloads: GemDownload.count_for_version(version.id)
Expand Down
35 changes: 17 additions & 18 deletions app/views/rubygems/_aside.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
<%= render partial: "rubygems/github_button", locals: { github_link: github_link } %>
<% end %>

<% if @latest_version.indexed %>
<div class="gem__downloads-wrap" data-href="<%= api_v1_download_path(@latest_version.full_name, :format => 'json') %>">
<h2 class="gem__downloads__heading t-text--s">
<%= t('stats.index.total_downloads') %>
<span class="gem__downloads"><%= number_with_delimiter(@rubygem.downloads) %></span>
</h2>
<h2 class="gem__downloads__heading t-text--s">
<%= t('.downloads_for_this_version') %>
<span class="gem__downloads"><%= number_with_delimiter(@latest_version.downloads_count) %></span>
</h2>
</div>
<% end %>
<div class="gem__downloads-wrap" data-href="<%= api_v1_download_path(@latest_version.full_name, :format => 'json') %>">
<h2 class="gem__downloads__heading t-text--s">
<%= t('stats.index.total_downloads') %>
<span class="gem__downloads"><%= number_with_delimiter(@rubygem.downloads) %></span>
</h2>
<h2 class="gem__downloads__heading t-text--s">
<%= t('.downloads_for_this_version') %>
<span class="gem__downloads"><%= number_with_delimiter(@latest_version.downloads_count) %></span>
</h2>
</div>

<% if @latest_version.indexed %>
<h2 class="gem__ruby-version__heading t-list__heading">
Expand All @@ -33,14 +31,15 @@
<span class="gem__code__icon" id="js-gem__code--install" data-clipboard-target="#install_text">=</span>
</div>
</h2>
<h2 class="gem__ruby-version__heading t-list__heading">
<%= pluralized_licenses_header @latest_version %>:
<span class="gem__ruby-version">
<p><%= formatted_licenses @latest_version.licenses %></p>
</span>
</h2>
<% end %>

<h2 class="gem__ruby-version__heading t-list__heading">
<%= pluralized_licenses_header @latest_version %>:
<span class="gem__ruby-version">
<p><%= formatted_licenses @latest_version.licenses %></p>
</span>
</h2>

<h2 class="gem__ruby-version__heading t-list__heading">
<%= t('.required_ruby_version') %>:
<i class="gem__ruby-version">
Expand Down
8 changes: 1 addition & 7 deletions test/functional/api/v1/downloads_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,7 @@ def self.should_respond_to(format, to_meth = :to_s)
get_show(@version)
end

should "return a 404" do
assert_response :not_found
end

should "say gem could not be found" do
assert_equal "This rubygem could not be found.", @response.body
end
should respond_with :success
end

context "On GET to all" do
Expand Down

0 comments on commit 8437253

Please sign in to comment.