Sha256: 72755b907d2fd208f3278630342a1ef5fa43a1b1ebff97837332b9b5e3515d4b
Contents?: true
Size: 1.15 KB
Versions: 5
Compression:
Stored size: 1.15 KB
Contents
require "test_helper" class EmailsControllerTest < ActionDispatch::IntegrationTest setup do @<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon)) end test "should update email" do assert_enqueued_email_with EmailMailer, :changed, args: { change: [@<%= singular_table_name %>.email, "new_email@hey.com"] } do patch emails_url, params: { current_password: "secret123", email: "new_email@hey.com" }, headers: { "Authorization" => "Bearer #{@token}" } end assert_response :success end test "should not update email with wrong current password" do assert_no_enqueued_emails do patch emails_url, params: { current_password: "wrong_password", email: @<%= singular_table_name %>.email }, headers: { "Authorization" => "Bearer #{@token}" } end assert_response :bad_request assert_equal "The current password you entered is incorrect", response.parsed_body["error"] end def sign_in_as(<%= singular_table_name %>) post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }) [<%= singular_table_name %>, response.parsed_body["session_token"]] end end
Version data entries
5 entries across 5 versions & 1 rubygems