Sha256: fdeeeb22d7a14e56db667ac2af5582b7a163ccd9f6160ed5fe36f1aff5fe8b78
Contents?: true
Size: 983 Bytes
Versions: 1
Compression:
Stored size: 983 Bytes
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 patch email_url, params: { current_password: "secret123", email: "new_email@hey.com" }, headers: { "Authorization" => "Bearer #{@token}" } assert_response :success end test "should not update email with wrong current password" do patch email_url, params: { current_password: "wrong_password", email: @<%= singular_table_name %>.email }, headers: { "Authorization" => "Bearer #{@token}" } 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.headers["X-Session-Token"]] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authentication-zero-2.2.8 | lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt |