diff options
author | francis <francis> | 2008-03-21 15:31:31 +0000 |
---|---|---|
committer | francis <francis> | 2008-03-21 15:31:31 +0000 |
commit | 788ddd480c7c131a5c04d0923ccb354a545c39b1 (patch) | |
tree | 5824b424af05ea55aca1b7e97185e558a62f3c5a /spec/controllers/user_controller_spec.rb | |
parent | 910299dc932f9b32dc29cc35631afe62566e9cbb (diff) |
Test stuff for password changing.
Diffstat (limited to 'spec/controllers/user_controller_spec.rb')
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 6405cbe37..96b9fcdfd 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -226,3 +226,61 @@ describe UserController, "when sending another user a message" do end +describe UserController, "when changing password" do + integrate_views + fixtures :users + + it "should show the email form when not logged in" do + get :signchange + response.should render_template('signchange_send_confirm') + end + + it "should send a confirmation email when logged in normally" do + session[:user_id] = users(:bob_smith_user).id + get :signchange + response.should render_template('signchange_confirm') + + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + mail = deliveries[0] + mail.body.should include("Please click on the link below to confirm your email address") + end + + it "should send a confirmation email when have wrong login circumstance" do + session[:user_id] = users(:bob_smith_user).id + session[:user_circumstance] = "bogus" + get :signchange + response.should render_template('signchange_confirm') + end + + it "should show the password change screen when logged in as special password change mode" do + session[:user_id] = users(:bob_smith_user).id + session[:user_circumstance] = "change_password" + get :signchange + response.should render_template('signchange') + end + + it "should change the password, if you have right to do so" do + session[:user_id] = users(:bob_smith_user).id + session[:user_circumstance] = "change_password" + + old_hash = users(:bob_smith_user).hashed_password + post :signchange, { :user => { :password => 'ooo', :password_confirmation => 'ooo' }, + :submitted_signchange_password => 1 + } + users(:bob_smith_user).hashed_password.should != old_hash + + response.should redirect_to(:controller => 'user', :action => 'show', :url_name => users(:bob_smith_user).url_name) + end + + it "should not change the password, if you're not logged in" do + end + + it "should not change the password, if you're just logged in normally" do + end + +end + + + + |