Sha256: fd71378fb29c3e17bf68631fa07cc737a3120ee54709b4bffd858ab778e4a081

Contents?: true

Size: 1007 Bytes

Versions: 9

Compression:

Stored size: 1007 Bytes

Contents

require 'test_helper'

class PasswordsControllerTest < Devise::ControllerTestCase
  tests Devise::PasswordsController
  include Devise::TestHelpers

  setup do
    request.env["devise.mapping"] = Devise.mappings[:user]
    @user = create_user.tap(&:confirm)
    @raw  = @user.send_reset_password_instructions
  end

  def put_update_with_params
    put :update, params: { "user" => {
        "reset_password_token" => @raw, "password" => "1234567", "password_confirmation" => "1234567"
      }
    }
  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

9 entries across 9 versions & 2 rubygems

Version Path
devise-4.0.3 test/controllers/passwords_controller_test.rb
devise-4.1.1 test/controllers/passwords_controller_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/devise-4.1.0/test/controllers/passwords_controller_test.rb
devise-4.1.0 test/controllers/passwords_controller_test.rb
devise-4.0.2 test/controllers/passwords_controller_test.rb
devise-4.0.1 test/controllers/passwords_controller_test.rb
devise-4.0.0 test/controllers/passwords_controller_test.rb
devise-4.0.0.rc2 test/controllers/passwords_controller_test.rb
devise-4.0.0.rc1 test/controllers/passwords_controller_test.rb