Permalink
Browse files

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

…wnload count
  • Loading branch information...
1 parent 62e2957 commit 6e10178b747d1219dd5d6778105ff823fbb148ad @qrush qrush committed Jan 27, 2010
@@ -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
View
@@ -85,4 +85,8 @@ def serve_via_cf
end
end
end
+
+ get "/downloads/*.gem" do
+ redirect "/gems/#{params[:splat]}.gem"
+ end
end
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"
@@ -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
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/
@@ -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

0 comments on commit 6e10178

Please sign in to comment.