Sha256: d046ce9725f473ca55443d3a85fb24e0a22338a8fcd939c034025083dd81e762
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 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_reset_url assert_response :success end test "should get edit" do get edit_password_reset_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_reset_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_reset_url, params: { email: "invalid_email@hey.com" } end assert_redirected_to new_password_reset_url assert_equal "Sorry, we didn't recognize that email address", flash[:alert] end test "should update password" do patch password_reset_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_reset_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" } assert_redirected_to new_password_reset_path assert_equal "Your token has expired, please request a new one", flash[:alert] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authentication-zero-2.1.1 | lib/generators/authentication/templates/test_unit/controllers/html/password_resets_controller_test.rb.tt |