From 79d65305b0fa7ffcdb0ccd7182ddf238b8586a02 Mon Sep 17 00:00:00 2001 From: taitus Date: Mon, 27 Mar 2023 13:17:27 +0200 Subject: [PATCH] Update test to test exactly what we want to test Since this test was added in commit 78c6a30424 the "current_password" was filled with an incorrect value. This test did not fail because in previous versions of the "devise-security" gem if this "current_password" was not valid a "self.valid?" was performed which caused the error we are testing. In version 0.17 (as can be seen in the following commit https://github.com/devise-security/devise-security/pull/340/commits/41a99b67fe0) if the "current_password" is not valid, related errors are still added but the "self.valid?" code is removed, which is what causes the expected error "must be different than the current password" to appear in the "new password" field. By adding a correct "current_password" in the test, we avoid this validation for the "current_password" (which no longer includes the expected error) and follow the natural flow of devise that does end up intercepting the error for the new password entered. --- spec/system/users_auth_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/users_auth_spec.rb b/spec/system/users_auth_spec.rb index 1d51c5630..646cd3716 100644 --- a/spec/system/users_auth_spec.rb +++ b/spec/system/users_auth_spec.rb @@ -737,7 +737,7 @@ describe "Users" do expect(page).to have_content "Your password is expired" - fill_in "Current password", with: "judgmentday" + fill_in "Current password", with: "123456789" fill_in "New password", with: "123456789" fill_in "Password confirmation", with: "123456789" click_button "Change your password"