diff --git a/lib/devise/models/authenticatable.rb b/lib/devise/models/authenticatable.rb index 8a20f0b3..1bf63645 100644 --- a/lib/devise/models/authenticatable.rb +++ b/lib/devise/models/authenticatable.rb @@ -127,7 +127,7 @@ module Devise # Find an initialize a group of attributes based on a list of required attributes. def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc: (case_insensitive_keys || []).each { |k| attributes[k].try(:downcase!) } - (strip_whitespace_keys || []).each { |k| conditions[k].try(:strip!) } + (strip_whitespace_keys || []).each { |k| attributes[k].try(:strip!) } attributes = attributes.slice(*required_attributes) attributes.delete_if { |key, value| value.blank? } diff --git a/test/integration/database_authenticatable_test.rb b/test/integration/database_authenticatable_test.rb index 76d5a28e..4a758747 100644 --- a/test/integration/database_authenticatable_test.rb +++ b/test/integration/database_authenticatable_test.rb @@ -34,11 +34,11 @@ class DatabaseAuthenticationTest < ActionController::IntegrationTest end test 'sign in with email including extra spaces should fail when email is NOT the list of strip whitespace keys' do - swap Devise, :case_insensitive_keys => [] do - create_user(:email => ' foo@bar.com ') + swap Devise, :strip_whitespace_keys => [] do + create_user(:email => 'foo@bar.com') sign_in_as_user do - fill_in 'email', :with => 'foo@bar.com' + fill_in 'email', :with => ' foo@bar.com ' end assert_not warden.authenticated?(:user) diff --git a/test/integration/recoverable_test.rb b/test/integration/recoverable_test.rb index b240a50b..819c46ea 100644 --- a/test/integration/recoverable_test.rb +++ b/test/integration/recoverable_test.rb @@ -54,10 +54,10 @@ class PasswordTest < ActionController::IntegrationTest end test 'reset password with email with extra whitespace should succeed when email is in the list of strip whitespace keys' do - create_user(:email => ' foo@bar.com ') + create_user(:email => 'foo@bar.com') request_forgot_password do - fill_in 'email', :with => 'foo@bar.com' + fill_in 'email', :with => ' foo@bar.com ' end assert_current_url '/users/sign_in' @@ -65,16 +65,16 @@ class PasswordTest < ActionController::IntegrationTest end test 'reset password with email with extra whitespace should fail when email is NOT the list of strip whitespace keys' do - swap Devise, :case_insensitive_keys => [] do - create_user(:email => ' foo@bar.com ') + swap Devise, :strip_whitespace_keys => [] do + create_user(:email => 'foo@bar.com') request_forgot_password do - fill_in 'email', :with => 'foo@bar.com' + fill_in 'email', :with => ' foo@bar.com ' end assert_response :success assert_current_url '/users/password' - assert_have_selector "input[type=email][value='foo@bar.com']" + assert_have_selector "input[type=email][value=' foo@bar.com ']" assert_contain 'not found' end end