Skip to content

Commit 0d033e9

Browse files
committed
add password reset test
1 parent 47ad85f commit 0d033e9

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

spec/requests/users/passwords_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,30 @@
123123
end
124124
end
125125
end
126+
127+
describe "PUT /update" do
128+
let(:token) do
129+
raw_token, enc_token = Devise.token_generator.generate(User, :reset_password_token)
130+
user.update!(reset_password_token: enc_token, reset_password_sent_at: Time.current)
131+
raw_token
132+
end
133+
134+
let(:params) do
135+
{
136+
user: {
137+
reset_password_token: token,
138+
password: "newpassword123!",
139+
password_confirmation: "newpassword123!"
140+
}
141+
}
142+
end
143+
144+
subject(:submit_reset) { put user_password_path, params: params }
145+
146+
it "successfully resets the password" do
147+
submit_reset
148+
expect(response).to redirect_to(new_user_session_path)
149+
expect(flash[:notice]).to eq("Your password has been changed successfully.")
150+
end
151+
end
126152
end

0 commit comments

Comments
 (0)