@@ -104,6 +104,14 @@ class SecurePasswordTest < ActiveModel::TestCase
104104 assert_equal [ "doesn't match Password" ] , @user . errors [ :password_confirmation ]
105105 end
106106
107+ test "create a new user with validation, a spaces only password, and an incorrect password confirmation" do
108+ @user . password = " "
109+ @user . password_confirmation = "something else"
110+ assert_not @user . valid? ( :create ) , "user should be invalid"
111+ assert_equal 1 , @user . errors . count
112+ assert_equal [ "doesn't match Password" ] , @user . errors [ :password_confirmation ]
113+ end
114+
107115 test "resetting password to nil clears the password cache" do
108116 @user . password = "password"
109117 @user . password = nil
@@ -179,6 +187,14 @@ class SecurePasswordTest < ActiveModel::TestCase
179187 assert_equal [ "doesn't match Password" ] , @existing_user . errors [ :password_confirmation ]
180188 end
181189
190+ test "updating an existing user with validation, a spaces only password, and an incorrect password confirmation" do
191+ @existing_user . password = " "
192+ @existing_user . password_confirmation = "something else"
193+ assert_not @existing_user . valid? ( :update ) , "user should be invalid"
194+ assert_equal 1 , @existing_user . errors . count
195+ assert_equal [ "doesn't match Password" ] , @existing_user . errors [ :password_confirmation ]
196+ end
197+
182198 test "updating an existing user with validation and a correct password challenge" do
183199 @existing_user . password = "new password"
184200 @existing_user . password_challenge = "password"
0 commit comments