Fix failing tests.

This commit is contained in:
José Valim
2011-06-10 11:10:56 +02:00
parent 17596b0dc6
commit e242ca0937
3 changed files with 10 additions and 10 deletions

View File

@@ -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? }

View File

@@ -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)

View File

@@ -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