Sha256: c04d6ddb9b0573ddab5d8aa69c88628e60d9c2e978812bd2223b6797cf5d0942

Contents?: true

Size: 1002 Bytes

Versions: 4

Compression:

Stored size: 1002 Bytes

Contents

require 'test_helper'

class PasswordsControllerTest < ActionController::TestCase
  tests Devise::PasswordsController
  include Devise::TestHelpers

  def setup
    request.env["devise.mapping"] = Devise.mappings[:user]

    @user = create_user.tap(&:confirm!)
    @user.send_reset_password_instructions
  end

  def put_update_with_params
    put :update, "user" => {
      "reset_password_token" => @user.reset_password_token, "password" => "123456", "password_confirmation" => "123456"
    }
  end

  test 'redirect to after_sign_in_path_for if after_resetting_password_path_for is not overridden' do
    put_update_with_params
    assert_redirected_to "http://test.host/"
  end

  test 'redirect accordingly if after_resetting_password_path_for is overridden' do
    custom_path = "http://custom.path/"
    Devise::PasswordsController.any_instance.stubs(:after_resetting_password_path_for).with(@user).returns(custom_path)

    put_update_with_params
    assert_redirected_to custom_path
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-3.0.4 test/controllers/passwords_controller_test.rb
devise-2.2.8 test/controllers/passwords_controller_test.rb
devise-2.2.7 test/controllers/passwords_controller_test.rb
devise-3.0.3 test/controllers/passwords_controller_test.rb