Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow fully-yanked gems to be unyanked by the original owner

This still allows for a new user to swoop in and claim the gem by pushing their own version. Doing so would delete the previous ownership.
  • Loading branch information...
commit 62fd59c6d56382d7e9820a9ad5a214045ebc8ad5 1 parent ceb0021
@laserlemon laserlemon authored
View
1  app/models/pusher.rb
@@ -77,6 +77,7 @@ def notify(message, code)
end
def update
+ rubygem.disown if rubygem.versions.indexed.count.zero?
rubygem.update_attributes_from_gem_specification!(version, spec)
rubygem.create_ownership(user) unless version.new_record?
true
View
7 app/models/rubygem.rb
@@ -225,9 +225,10 @@ def reorder_versions
def yank!(version)
version.yank!
- if versions.indexed.count.zero?
- ownerships.each(&:delete)
- end
+ end
+
+ def disown
+ ownerships.each(&:delete)
end
def find_or_initialize_version_from_spec(spec)
View
19 features/yank.feature
@@ -95,3 +95,22 @@ Feature: Delete Gems
And I go to the dashboard
And I follow "RGem"
Then I should not see "This gem has been yanked."
+
+ Scenario: User unyanks a gem with no indexed versions
+ Given I am signed up as "email@person.com"
+ And I have an API key for "email@person.com/password"
+ And the following ownership exists:
+ | rubygem | user |
+ | name: RGem | email: email@person.com |
+ And the following versions exist:
+ | rubygem | number |
+ | name: RGem | 1.2.3 |
+ When I yank the gem "RGem" version "1.2.3" with my API key
+ And I go to the dashboard
+ And I go to the "RGem" rubygem page
+ Then I should see "This gem has been yanked"
+
+ When I unyank the gem "RGem" version "1.2.3" with my API key
+ And I go to the dashboard
+ And I follow "RGem"
+ Then I should not see "This gem has been yanked"
View
3  test/functional/api/v1/rubygems_controller_test.rb
@@ -261,10 +261,9 @@ def self.should_respond_to(format)
delete :yank, :gem_name => @rubygem.to_param, :version => @v1.number
end
should respond_with :success
- should "keep the gem, deindex, remove owner" do
+ should "keep the gem, deindex, keep owner" do
assert_equal 1, @rubygem.versions.count
assert @rubygem.versions.indexed.count.zero?
- assert @rubygem.ownerships.count.zero?
end
end
View
8 test/unit/rubygem_test.rb
@@ -372,8 +372,12 @@ class RubygemTest < ActiveSupport::TestCase
@rubygem_with_version.yank!(@rubygem_with_version.versions.first)
end
- should "no longer be owned" do
- assert @rubygem_with_version.reload.unowned?
+ should "still be owned" do
+ assert @rubygem_with_version.owned_by?(@owner)
+ end
+
+ should "no longer be indexed" do
+ assert @rubygem_with_version.versions.indexed.count.zero?
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.