Skip to content

Commit

Permalink
Namespaced the passwords controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Mar 26, 2009
1 parent 589c703 commit 4ecad82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class PasswordsController < ApplicationController
class Clearance::PasswordsController < ApplicationController

before_filter :forbid_missing_token, :only => [:edit, :update]
before_filter :forbid_non_existant_user, :only => [:edit, :update]
filter_parameter_logging :password, :password_confirmation

def new
render :template => 'passwords/new'
end

def create
Expand All @@ -16,12 +17,13 @@ def create
redirect_to url_after_create
else
flash.now[:notice] = "Unknown email"
render :action => :new
render :template => 'passwords/new'
end
end

def edit
@user = User.find_by_id_and_token(params[:user_id], params[:token])
render :template => 'passwords/edit'
end

def update
Expand All @@ -33,7 +35,7 @@ def update
sign_user_in(@user)
redirect_to url_after_update
else
render :action => :edit
render :template => 'passwords/edit'
end
end

Expand Down
5 changes: 3 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ActionController::Routing::Routes.draw do |map|
map.resources :passwords
map.resources :passwords, :controller => 'clearance/passwords'
map.resource :session
map.resources :users, :has_one => [:password] do |users|
map.resources :users do |users|
users.resource :password, :controller => 'clearance/passwords'
users.resource :confirmation, :controller => 'clearance/confirmations'
end
end
4 changes: 3 additions & 1 deletion test/controllers/passwords_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

class PasswordsControllerTest < ActionController::TestCase

tests Clearance::PasswordsController

should_route :get, '/users/1/password/edit',
:action => 'edit', :user_id => '1'
:controller => 'clearance/passwords', :action => 'edit', :user_id => '1'

context "a signed up user" do
setup do
Expand Down

0 comments on commit 4ecad82

Please sign in to comment.