Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moving Download button to /downloads so robots stop increasing the do…

…wnload count
  • Loading branch information...
commit 6e10178b747d1219dd5d6778105ff823fbb148ad 1 parent 62e2957
Nick Quaranto qrush authored
2  app/helpers/rubygems_helper.rb
View
@@ -72,6 +72,6 @@ def unsubscribe_link(gem)
end
def download_link(version)
- link_to "Download", "/gems/#{version.full_name}.gem", :id => :download
+ link_to "Download", "/downloads/#{version.full_name}.gem", :id => :download
end
end
4 app/metal/hostess.rb
View
@@ -85,4 +85,8 @@ def serve_via_cf
end
end
end
+
+ get "/downloads/*.gem" do
+ redirect "/gems/#{params[:splat]}.gem"
+ end
end
16 features/download.feature
View
@@ -62,20 +62,18 @@ Feature: Download Gems
And I push the gem "andhapp-1.1.1.gem" with my api key
And I push the gem "andhapp-1.1.0.gem" with my api key
And the system processes jobs
-
+
When I visit the gem page for "andhapp" version "1.1.1"
Then I should see "0 total downloads"
-
+
When I visit the gem page for "andhapp" version "1.1.1"
- Then I follow "Download"
- And the system processes jobs
+ And I download the rubygem "andhapp" version "1.1.1" 1 time
And I visit the gem page for "andhapp"
- Then I should see "1 total downloads"
+ Then I should see "1 total downloads"
And I should see "1 for this version"
-
+
When I visit the gem page for "andhapp" version "1.1.0"
- Then I follow "Download"
- And the system processes jobs
+ And I download the rubygem "andhapp" version "1.1.0" 1 time
And I visit the gem page for "andhapp"
Then I should see "2 total downloads"
- And I should see "1 for this version"
+ And I should see "1 for this version"
2  features/step_definitions/api_steps.rb
View
@@ -35,7 +35,7 @@
visit api_v1_rubygem_owners_path(:rubygem_id => rubygem_name), :delete, :email => owner_email
end
-When /^I download the rubygem "([^\"]*)" version "([^\"]*)" (\d+) times$/ do |rubygem_name, version_number, count|
+When /^I download the rubygem "([^\"]*)" version "([^\"]*)" (\d+) times?$/ do |rubygem_name, version_number, count|
count.to_i.times do
visit "/gems/#{rubygem_name}-#{version_number}.gem", :get
end
4 public/robots.txt
View
@@ -1,5 +1,5 @@
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
-# User-Agent: *
-# Disallow: /
+User-Agent: *
+Disallow: /downloads/
6 test/unit/hostess_test.rb
View
@@ -105,4 +105,10 @@ def touch(path, local = true)
assert_equal 1, rubygem.reload.downloads
assert_equal 1, version.reload.downloads_count
end
+
+ should "redirect to /gems for /downloads" do
+ get "/downloads/rails-3.0.0.gem"
+ assert_equal "/gems/rails-3.0.0.gem", last_response.headers["Location"]
+ assert_equal 302, last_response.status
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.