Sha256: f974c1f29eb4d7c48704ad4d6145cc2c43b05f26c51b47013ed0892e586f1451
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 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(email_hint: "invalid_email@hey.com") assert_equal "The email address doesn't exist in our database", 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