Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## password_resets_controller_test.rb
- require 'test_helper'
- class PasswordResetsControllerTest < ActionController::TestCase
- # Works using user fixture...
- context "Logged out" do
- setup do
- @user = users(:ben)
- end
- context "on GET to :edit" do
- context "with a valid perishable token" do
- setup { get :edit, :id => @user.perishable_token }
- should_respond_with :success
- should_render_template :edit
- should_not_set_the_flash
- end
- context "without a valid perishable token" do
- setup { get :edit, :id => @user.username }
- should_not_assign_to :user
- should_respond_with :redirect
- should_set_the_flash_to /sorry/i
- end
- end
- context "on PUT to :update" do
- setup { put :update, :id => @user.perishable_token, :user => { :password => "newpassword", :password_confirmation => "newpassword"} }
- should_respond_with :redirect
- should_set_the_flash_to /updated/i
- end
- end
- # Doesn't work using Factory(:user
- context "Logged out" do
- setup do
- @user = Factory(:user)
- @user_session = UserSession.find(@user)
- @user_session.destroy
- end
- context "on GET to :edit" do
- context "with a valid perishable token" do
- setup { get :edit, :id => @user.perishable_token }
- should_respond_with :success
- should_render_template :edit
- should_not_set_the_flash
- end
- context "without a valid perishable token" do
- setup { get :edit, :id => @user.username }
- should_not_assign_to :user
- should_respond_with :redirect
- should_set_the_flash_to /sorry/i
- end
- end
- context "on PUT to :update" do
- setup { put :update, :id => @user.perishable_token, :user => { :password => "newpassword", :password_confirmation => "newpassword"} }
- should_respond_with :redirect
- should_set_the_flash_to /updated/i
- end
- end
- end
- ## users.yml
- ben:
- username: ben
- email: ben@example.com
- password_salt: <%= salt = Authlogic::Random.hex_token %>
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("password" + salt) %>
- persistence_token: <%= Authlogic::Random.hex_token %>
- single_access_token: <%= Authlogic::Random.friendly_token %>
- perishable_token: <%= Authlogic::Random.friendly_token %>
- ## factories.rb
- Factory.define :user do |f|
- f.sequence(:username) { |n| "user#{n}" }
- f.password "password"
- f.password_confirmation { |u| u.password }
- f.sequence(:email) { |n| "user#{n}@example.com" }
- end
- ## Errors
- 1) Failure:
- test: Logged out on GET to :edit with a valid perishable token should not set the flash. (PasswordResetsControllerTest)
- method __bind_1244363655_917834 in macros.rb at line 93
- method call in context.rb at line 254
- method test: Logged out on GET to :edit with a valid perishable token should not set the flash. in context.rb at line 254
- Flash was set to:
- {:notice=>"We're sorry, but we could not locate your account.If you are having issues try copying and pasting the URL from your email into your browser or restarting the reset password process."}.
- <{}> expected but was
- <{:notice=>
- "We're sorry, but we could not locate your account.If you are having issues try copying and pasting the URL from your email into your browser or restarting the reset password process."}>.
- 2) Failure:
- test: Logged out on GET to :edit with a valid perishable token should render template :edit. (PasswordResetsControllerTest)
- method __bind_1244363655_938004 in macros.rb at line 220
- method call in context.rb at line 254
- method test: Logged out on GET to :edit with a valid perishable token should render template :edit. in context.rb at line 254
- expecting <"edit"> but rendering with <"">
- 3) Failure:
- test: Logged out on GET to :edit with a valid perishable token should respond with success. (PasswordResetsControllerTest)
- method __bind_1244363655_954256 in macros.rb at line 177
- method call in context.rb at line 254
- method test: Logged out on GET to :edit with a valid perishable token should respond with success. in context.rb at line 254
- Expected response to be a <:success>, but was <302>
- 4) Failure:
- test: Logged out on PUT to :update should have /updated/i in the flash. (PasswordResetsControllerTest)
- method assert_contains in assertions.rb at line 29
- method __bind_1244363656_269338 in macros.rb at line 89
- method call in context.rb at line 254
- method test: Logged out on PUT to :update should have /updated/i in the flash. in context.rb at line 254
- /updated/i not found in ["We're sorry, but we could not locate your account.If you are having issues try copying and pasting the URL from your email into your browser or restarting the reset password process."] , Flash: {:notice=>"We're sorry, but we could not locate your account.If you are having issues try copying and pasting the URL from your email into your browser or restarting the reset password process."}.
- <nil> is not true.
- 25 tests, 26 assertions, 4 failures, 0 errors
Add Comment
Please, Sign In to add comment