Sha256: f50c74174777b850aa6cc4718929f948a83bd65a899a17e30f69bab14b91f6fb

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

require "test_helper"

class Identity::EmailsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon))
  end

  test "should update email" do
    patch identity_email_url, params: { email: "new_email@hey.com" }, headers: { "Authorization" => "Bearer #{@token}" }
    assert_response :success
  end

  test "should not update email without sudo" do
    @<%= singular_table_name %>.sessions.last.update! sudo_at: 1.day.ago

    patch identity_email_url, params: { email: "new_email@hey.com" }, headers: { "Authorization" => "Bearer #{@token}" }

    assert_response :forbidden
    assert_equal "Enter your password to continue", response.parsed_body["error"]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authentication-zero-2.10.0 lib/generators/authentication/templates/test_unit/controllers/api/identity/emails_controller_test.rb.tt
authentication-zero-2.9.3 lib/generators/authentication/templates/test_unit/controllers/api/identity/emails_controller_test.rb.tt