Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgraded to Rails 3 router DSL

* Pushed all deprecated actions to one controller action
* Renamed StatisticsController to StatsController
* Moved searches#new to searches#show to use a resource instead
* Removed unnecessary clearance routes and requires
  • Loading branch information...
commit 629e8aa36c793629a93eacd93f2c959196a19726 1 parent aa52f02
@qrush qrush authored
View
4 app/controllers/api/deprecated_controller.rb
@@ -1,10 +1,8 @@
class Api::DeprecatedController < ApplicationController
-
- def method_missing(method)
+ def index
render :status => :forbidden, :text => %{
This version of the Gemcutter plugin has been deprecated.
Please install the latest version using: gem update gemcutter
}
end
-
end
View
2  app/controllers/searches_controller.rb
@@ -1,6 +1,6 @@
class SearchesController < ApplicationController
- def new
+ def show
if params[:query]
@gems = Rubygem.search(params[:query]).with_versions.paginate(:page => params[:page])
@exact_match = Rubygem.name_is(params[:query]).with_versions.first
View
2  app/controllers/statistics_controller.rb → app/controllers/stats_controller.rb
@@ -1,4 +1,4 @@
-class StatisticsController < ApplicationController
+class StatsController < ApplicationController
def index
@number_of_gems = Rubygem.total_count
@number_of_users = User.count
View
2  app/views/layouts/application.html.erb
@@ -77,7 +77,7 @@
<%= link_to "Status", "http://twitter.com/gemcutter" %>
<%= link_to "Code", "http://github.com/rubygems/gemcutter" %>
<%= link_to "Discuss", "http://groups.google.com/group/gemcutter" %>
- <%= link_to "Stats", statistics_url %>
+ <%= link_to "Stats", stats_url %>
<%= link_to "designed by #{image_tag('thoughtbot.png')}".html_safe, "http://thoughtbot.com", :title => "Designed by Thoughtbot", :id => "thoughtbot" %>
<%= link_to "supported by #{image_tag('rubycentral.png')}".html_safe, "http://rubycentral.org", :title => "Supported by Ruby Central", :id => "rubycentral" %>
</div>
View
0  app/views/searches/new.html.erb → app/views/searches/show.html.erb
File renamed without changes
View
0  app/views/statistics/index.html.erb → app/views/stats/index.html.erb
File renamed without changes
View
6 config/initializers/clearance.rb
@@ -1,9 +1,3 @@
-require 'clearance/confirmations_controller'
-require 'clearance/passwords_controller'
-require 'clearance/sessions_controller'
-require 'clearance/users_controller'
-
-
Clearance.configure do |config|
config.mailer_sender = "donotreply@rubygems.org"
end
View
124 config/routes.rb
@@ -5,94 +5,82 @@
################################################################################
# API v1
- map.namespace :api do |api|
- api.namespace :v1 do |v1|
- v1.resource :api_key,
- :only => [:show, :reset],
- :member => {:reset => :put}
- v1.resources :rubygems,
- :as => "gems",
- :collection => {:yank => :delete, :unyank => :put},
- :only => [:create, :show] do |rubygems|
- rubygems.resource :owners,
- :only => [:show, :create, :destroy]
+ namespace :api do
+ namespace :v1 do
+ resource :api_key, :only => :show do
+ put :reset
+ end
+
+ resources :downloads, :only => :index
+
+ resources :rubygems, :path => "gems", :only => [:create, :show] do
+ collection do
+ delete :yank
+ put :unyank
+ end
+ resource :owners, :only => [:show, :create, :destroy]
+ end
+
+ resource :search, :only => :show
+
+ resources :web_hooks, :only => [:create, :index] do
+ collection do
+ delete :remove
+ post :fire
+ end
end
- v1.resource :search, :only => :show
- v1.resources :web_hooks,
- :only => [:create, :index],
- :collection => {:remove => :delete,
- :fire => :post}
- v1.resources :downloads, :only => :index
end
end
################################################################################
# API v0
- map.json_gem "/gems/:id.json",
- :controller => "api/deprecated",
- :format => "json",
- :requirements => { :id => RUBYGEM_NAME_MATCHER }
- map.resource :api_key,
- :only => [:show, :reset],
- :member => {:reset => :put},
- :controller => "api/deprecated"
- map.resource :migrate,
- :only => [:create, :update],
- :controller => "api/deprecated",
- :path_prefix => "/gems/:rubygem_id",
- :requirements => { :rubygem_id => RUBYGEM_NAME_MATCHER }
+ scope :to => "api/deprecated#index" do
+ get "api_key"
+ put "api_key/reset"
- ################################################################################
- # UI
+ post "gems"
+ get "gems/:id.json"
- map.search "/search", :controller => "searches", :action => "new"
- map.resource :dashboard, :only => :show
- map.resource :profile, :only => [:edit, :update]
- map.resources :statistics, :only => :index, :as => "stats"
+ scope :path => "gems/:rubygem_id" do
+ put "migrate"
+ post "migrate"
- map.resources :rubygems,
- :as => "gems",
- :except => [:create],
- :requirements => { :id => RUBYGEM_NAME_MATCHER } do |rubygems|
+ get "owners(.:format)"
+ post "owners(.:format)"
+ delete "owners(.:format)"
+ end
+ end
- rubygems.resource :owners,
- :only => [:show, :create, :destroy],
- :controller => "api/deprecated"
+ ################################################################################
+ # UI
- rubygems.resource :subscription, :only => [:create, :destroy]
+ resource :search, :only => :show
+ resource :dashboard, :only => :show
+ resource :profile, :only => [:edit, :update]
+ resources :stats, :only => :index
- rubygems.resources :versions,
- :only => [:index, :show],
- :requirements => { :rubygem_id => RUBYGEM_NAME_MATCHER, :id => RUBYGEM_NAME_MATCHER }
- end
+ constraints :id => RUBYGEM_NAME_MATCHER do
+ resources :rubygems, :path => "gems", :only => [:index, :show, :edit, :update] do
+ resource :subscription, :only => [:create, :destroy]
- map.resources :rubygems,
- :as => "gems",
- :controller => "api/deprecated",
- :only => [:create]
+ constraints :rubygem_id => RUBYGEM_NAME_MATCHER do
+ resources :versions, :only => [:index, :show]
+ end
+ end
+ end
################################################################################
- # Clearance
-
- map.sign_up 'sign_up', :controller => 'clearance/users', :action => 'new'
- map.sign_in 'sign_in', :controller => 'clearance/sessions', :action => 'new'
- map.sign_out 'sign_out',
- :controller => 'clearance/sessions',
- :action => 'destroy',
- :method => :delete
- map.resource :session,
- :controller => 'sessions',
- :only => :create
- map.resources :users, :controller => 'clearance/users' do |users|
- users.resource :confirmation,
- :controller => 'confirmations',
- :only => [:new, :create]
+ # Clearance Overrides
+
+ resource :session, :only => :create
+ scope :path => "users/:user_id" do
+ resource :confirmation, :only => [:new, :create], :as => :user_confirmation
end
################################################################################
# Root
- map.root :controller => "home", :action => "index"
+ root :to => "home#index"
end
View
14 test/functional/api/deprecated_controller_test.rb
@@ -4,19 +4,19 @@ class Api::DeprecatedControllerTest < ActionController::TestCase
should "route old paths to new controller" do
route = { :controller => "api/deprecated" }
- assert_recognizes(route.merge(:action => "show"), :path => "/api_key")
- assert_recognizes(route.merge(:action => "reset"), :path => "/api_key/reset", :method => :put)
+ assert_recognizes(route.merge(:action => "index"), :path => "/api_key")
+ assert_recognizes(route.merge(:action => "index"), :path => "/api_key/reset", :method => :put)
route = { :controller => "api/deprecated", :rubygem_id => "rails", :format => "json" }
- assert_recognizes(route.merge(:action => "show"), :path => "/gems/rails/owners.json")
- assert_recognizes(route.merge(:action => "create"), :path => "/gems/rails/owners.json", :method => :post)
- assert_recognizes(route.merge(:action => "destroy"), :path => "/gems/rails/owners.json", :method => :delete)
+ assert_recognizes(route.merge(:action => "index"), :path => "/gems/rails/owners.json")
+ assert_recognizes(route.merge(:action => "index"), :path => "/gems/rails/owners.json", :method => :post)
+ assert_recognizes(route.merge(:action => "index"), :path => "/gems/rails/owners.json", :method => :delete)
- route = { :controller => "api/deprecated", :id => "rails", :format => "json" }
+ route = { :controller => "api/deprecated", :id => "rails" }
assert_recognizes(route.merge(:action => "index"), :path => "/gems/rails.json")
route = { :controller => "api/deprecated" }
- assert_recognizes(route.merge(:action => "create"), :path => '/gems', :method => :post)
+ assert_recognizes(route.merge(:action => "index"), :path => '/gems', :method => :post)
end
end
View
18 test/functional/searches_controller_test.rb
@@ -2,29 +2,29 @@
class SearchesControllerTest < ActionController::TestCase
- context 'on GET to new with no search parameters' do
- setup { get :new }
+ context 'on GET to show with no search parameters' do
+ setup { get :show }
should respond_with :success
- should render_template :new
+ should render_template :show
should "see no results" do
assert_not_contain "Results"
end
end
- context 'on GET to new with search parameters for a rubygem without versions' do
+ context 'on GET to show with search parameters for a rubygem without versions' do
setup do
@sinatra = Factory(:rubygem, :name => "sinatra")
assert_nil @sinatra.versions.most_recent
assert @sinatra.reload.versions.count.zero?
- get :new, :query => "sinatra"
+ get :show, :query => "sinatra"
end
should respond_with :success
- should render_template :new
+ should render_template :show
end
- context 'on GET to new with search parameters' do
+ context 'on GET to show with search parameters' do
setup do
@sinatra = Factory(:rubygem, :name => "sinatra")
@sinatra_redux = Factory(:rubygem, :name => "sinatra-redux")
@@ -32,11 +32,11 @@ class SearchesControllerTest < ActionController::TestCase
Factory(:version, :rubygem => @sinatra)
Factory(:version, :rubygem => @sinatra_redux)
Factory(:version, :rubygem => @brando)
- get :new, :query => "sinatra"
+ get :show, :query => "sinatra"
end
should respond_with :success
- should render_template :new
+ should render_template :show
should assign_to(:gems) { [@sinatra, @sinatra_redux] }
should assign_to(:exact_match) { @sinatra }
should "see sinatra on the page in the results" do
View
2  .../functional/statistics_controller_test.rb → test/functional/stats_controller_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class StatisticsControllerTest < ActionController::TestCase
+class StatsControllerTest < ActionController::TestCase
context "on GET to index" do
setup do
@number_of_gems = 1337
Please sign in to comment.
Something went wrong with that request. Please try again.