Skip to content

Commit

Permalink
Add yanked by to gem show page
Browse files Browse the repository at this point in the history
Also added locales for yanked by and pushed by
  • Loading branch information
sonalkr132 committed Apr 14, 2019
1 parent 211e28d commit c332656
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/models/version.rb
Expand Up @@ -4,7 +4,7 @@ class Version < ApplicationRecord
belongs_to :rubygem, touch: true
has_many :dependencies, -> { order('rubygems.name ASC').includes(:rubygem) }, dependent: :destroy, inverse_of: "version"
has_one :gem_download, proc { |m| where(rubygem_id: m.rubygem_id) }, inverse_of: :version
belongs_to :pusher, class_name: "User", foreign_key: "pusher_id"
belongs_to :pusher, class_name: "User", foreign_key: "pusher_id", inverse_of: false, optional: true

before_save :update_prerelease
before_validation :full_nameify!
Expand Down Expand Up @@ -329,6 +329,10 @@ def metadata_uri_set?
Links::LINKS.any? { |_, long| metadata.key? long }
end

def yanker
Deletion.find_by(rubygem: rubygem.name, number: number, platform: platform)&.user unless indexed
end

private

def platform_and_number_are_unique
Expand Down
13 changes: 10 additions & 3 deletions app/views/rubygems/_gem_members.html.erb
@@ -1,15 +1,22 @@
<div class="gem__members">
<% if rubygem.owners.present? %>
<h3 class="t-list__heading"><%= t '.owners_header' %>:</h3>
<div class="gem__users">
<%= links_to_owners(rubygem) %>
</div>
<% end %>
<% if latest_version.pusher.present? %>
<h3 class="t-list__heading"><%= t '.pushed_by' %>:</h3>
<div class="gem__users">
<%= link_to_user(latest_version.pusher) %>
</div>
<% end %>
<% if rubygem.owners.present? %>
<h3 class="t-list__heading"><%= t '.owners_header' %>:</h3>
<% if latest_version.yanker.present? %>
<h3 class="t-list__heading"><%= t '.yanked_by' %>:</h3>
<div class="gem__users">
<%= links_to_owners(rubygem) %>
<%= link_to_user(latest_version.yanker) %>
</div>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/de.yml
Expand Up @@ -221,6 +221,8 @@ de:
list_multi_owner:
rubygem:
owners_header:
pushed_by:
yanked_by:
destroy:
request_queued:
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Expand Up @@ -229,6 +229,8 @@ en:
list_multi_owner: You will lose access to these gem but other owners of the gem will continue to have access.
rubygem:
owners_header: Owners
pushed_by: Pushed by
yanked_by: Yanked by
destroy:
request_queued: Your account deletion request has been enqueued. We will send you a confrimation mail when your request has been processed.
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/es.yml
Expand Up @@ -221,6 +221,8 @@ es:
list_multi_owner:
rubygem:
owners_header:
pushed_by:
yanked_by:
destroy:
request_queued:
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/fr.yml
Expand Up @@ -221,6 +221,8 @@ fr:
list_multi_owner: Vous allez perdre l'accès à ces gems mais d'autres propriétaires de ces gems y ont toujours accès.
rubygem:
owners_header: Propriétaires
pushed_by:
yanked_by:
destroy:
request_queued: Votre demande de suppression de compte a été envoyée. Nous vous enverrons un email de confirmation lorsque votre demande aura été prise en compte.
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ja.yml
Expand Up @@ -221,6 +221,8 @@ ja:
list_multi_owner: あなたはこれらのGemへのアクセス権を喪失しますが、他のオーナーがアクセス権を継続します。
rubygem:
owners_header: オーナー
pushed_by:
yanked_by:
destroy:
request_queued: あなたのアカウント削除処理は追って実行されます。削除処理の完了次第、確認のメールを送信します。
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/nl.yml
Expand Up @@ -221,6 +221,8 @@ nl:
list_multi_owner:
rubygem:
owners_header:
pushed_by:
yanked_by:
destroy:
request_queued:
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/pt-BR.yml
Expand Up @@ -221,6 +221,8 @@ pt-BR:
list_multi_owner:
rubygem:
owners_header:
pushed_by:
yanked_by:
destroy:
request_queued:
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/zh-CN.yml
Expand Up @@ -221,6 +221,8 @@ zh-CN:
list_multi_owner:
rubygem:
owners_header:
pushed_by:
yanked_by:
destroy:
request_queued:
update:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/zh-TW.yml
Expand Up @@ -221,6 +221,8 @@ zh-TW:
list_multi_owner:
rubygem:
owners_header:
pushed_by:
yanked_by:
destroy:
request_queued:
update:
Expand Down
1 change: 1 addition & 0 deletions test/functional/api/v1/rubygems_controller_test.rb
Expand Up @@ -242,6 +242,7 @@ def self.should_respond_to(format)
should "register new gem" do
assert_equal 1, Rubygem.count
assert_equal @user, Rubygem.last.ownerships.first.user
assert_equal @user, Rubygem.last.versions.first.pusher
assert_equal "Successfully registered gem: test (0.0.0)", @response.body
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/integration/push_test.rb
Expand Up @@ -17,6 +17,10 @@ class PushTest < ActionDispatch::IntegrationTest
assert_response :success
assert page.has_content?("sandworm")
assert page.has_content?("1.0.0")
assert page.has_content?("Pushed By")

css = %(div.gem__users a[alt=#{@user.handle}])
assert page.has_css?(css, count: 2)
end

test "push a new version of a gem" do
Expand Down
5 changes: 5 additions & 0 deletions test/integration/yank_test.rb
Expand Up @@ -33,6 +33,11 @@ class YankTest < SystemTest
click_link "2.2.2"
assert page.has_content? "This version has been yanked"
assert page.has_css? 'meta[name="robots"][content="noindex"]', visible: false

assert page.has_content?("Yanked By")

css = %(div.gem__users a[alt=#{@user.handle}])
assert page.has_css?(css, count: 2)
end

test "yanked gem entirely then someone else pushes a new version" do
Expand Down

0 comments on commit c332656

Please sign in to comment.