Skip to content

Commit

Permalink
Unyank now responds to anything with 410 Gone
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush authored and arthurnn committed Apr 20, 2015
1 parent 1c1b0c6 commit dc9ce8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
7 changes: 1 addition & 6 deletions app/controllers/api/v1/rubygems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ def yank
end

def unyank
if !@version.indexed?
@version.unyank!
render :text => "Successfully unyanked gem: #{@version.to_title}"
else
render :text => "The version #{params[:version]} is already indexed.", :status => :unprocessable_entity
end
render text: "Unyanking of gems is no longer supported.", status: :gone
end

def reverse_dependencies
Expand Down
29 changes: 3 additions & 26 deletions test/functional/api/v1/rubygems_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,49 +336,26 @@ def self.should_respond_to(format)
setup do
put :unyank, :gem_name => @rubygem.to_param, :version => @v1.number
end
should respond_with :success
#should change("the rubygem's indexed version count", :by => 1) { @rubygem.versions.indexed.count }
should "re-index 0.1.0" do
assert @v1.reload.indexed?
end
should respond_with :gone
end

context "ON PUT to unyank for version 0.1.2 and platform x86-darwin-10" do
setup do
put :unyank, :gem_name => @rubygem.to_param, :version => @v3.number, :platform => @v3.platform
end
should respond_with :success
#should change("the rubygem's indexed version count", :by => 1) { @rubygem.versions.indexed.count }
should "re-index 0.1.2" do
assert @v3.reload.indexed?
end
should respond_with :gone
end


context "ON PUT to unyank for version 0.1.1" do
setup do
put :unyank, :gem_name => @rubygem.to_param, :version => @v2.number
end
should respond_with :unprocessable_entity
should respond_with :gone
end
end
end

def should_return_latest_gems(gems)
assert_equal 2, gems.length
gems.each {|g| assert g.is_a?(Hash) }
assert_equal @rubygem_2.attributes['name'], gems[0]['name']
assert_equal @rubygem_3.attributes['name'], gems[1]['name']
end

def should_return_just_updated_gems(gems)
assert_equal 3, gems.length
gems.each {|g| assert g.is_a?(Hash) }
assert_equal @rubygem_1.attributes['name'], gems[0]['name']
assert_equal @rubygem_2.attributes['name'], gems[1]['name']
assert_equal @rubygem_3.attributes['name'], gems[2]['name']
end

context "No signed in-user" do
context "On GET to index with JSON for a list of gems" do
setup do
Expand Down
6 changes: 4 additions & 2 deletions test/integration/yank_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class YankTest < SystemTest
assert ! page.has_content?(@user.handle)
end

test "undo a yank" do
test "undo a yank is not supported" do
create(:version, rubygem: @rubygem, number: "1.0.0", indexed: true)
create(:version, rubygem: @rubygem, number: "0.0.0", indexed: false)

page.driver.browser.header("Authorization", @user.api_key)
Expand All @@ -68,7 +69,8 @@ class YankTest < SystemTest
assert page.has_content? "sandworm"

click_link "sandworm"
assert page.has_content? "0.0.0"
assert page.has_content?("1.0.0")
assert ! page.has_content?("0.0.0")
end

teardown do
Expand Down

0 comments on commit dc9ce8a

Please sign in to comment.