Sha256: 15a3e1138b120ad42788a5b6afcc9ac33bc37a933667a77aa801fbfd7bdee67f
Contents?: true
Size: 1.74 KB
Versions: 3
Compression:
Stored size: 1.74 KB
Contents
require "test_helper" class PasswordResetsControllerTest < ActionDispatch::IntegrationTest setup do @<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon) @sid = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 20.minutes) @sid_exp = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 0.minutes) end test "should get new" do get new_password_resets_url assert_response :success end test "should get edit" do get edit_password_resets_url(token: @sid) assert_response :success end test "should send a password reset email" do assert_enqueued_email_with PasswordMailer, :reset, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do post password_resets_url, params: { email: @<%= singular_table_name %>.email } end assert_redirected_to sign_in_path end test "should not send a password reset email to a nonexistent email" do assert_no_enqueued_emails do post password_resets_url, params: { email: "invalid_email@hey.com" } end assert_redirected_to new_password_resets_url assert_equal "Sorry, we didn't recognize that email address", flash[:alert] end test "should update password" do patch password_resets_url, params: { token: @sid, <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } } assert_redirected_to sign_in_path end test "should not update password with expired token" do patch password_resets_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" } assert_redirected_to new_password_resets_path assert_equal "Your token has expired, please request a new one", flash[:alert] end end
Version data entries
3 entries across 3 versions & 1 rubygems