@@ -104,6 +104,14 @@ class SecurePasswordTest < ActiveModel::TestCase
104
104
assert_equal [ "doesn't match Password" ] , @user . errors [ :password_confirmation ]
105
105
end
106
106
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
+
107
115
test "resetting password to nil clears the password cache" do
108
116
@user . password = "password"
109
117
@user . password = nil
@@ -179,6 +187,14 @@ class SecurePasswordTest < ActiveModel::TestCase
179
187
assert_equal [ "doesn't match Password" ] , @existing_user . errors [ :password_confirmation ]
180
188
end
181
189
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
+
182
198
test "updating an existing user with validation and a correct password challenge" do
183
199
@existing_user . password = "new password"
184
200
@existing_user . password_challenge = "password"
0 commit comments