Sha256: 1a40f8bbc00b77ac0e39d45b38f6adbf96fb77f4d3e0588de4b8f4e6bba03f6b

Contents?: true

Size: 986 Bytes

Versions: 8

Compression:

Stored size: 986 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

8 entries across 8 versions & 1 rubygems

Version Path
authentication-zero-2.2.7 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
authentication-zero-2.2.6 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
authentication-zero-2.2.5 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
authentication-zero-2.2.4 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
authentication-zero-2.2.3 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
authentication-zero-2.2.2 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
authentication-zero-2.2.1 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
authentication-zero-2.1.1 lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt