Sha256: b10823510abdc782e8c44a281c8a5960d5fc80f831f23e64be93b28a62352ebc

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require "test_helper"

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

  test "should get edit" do
    get edit_identity_email_url
    assert_response :success
  end

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

    get edit_identity_email_url
    assert_redirected_to new_sessions_sudo_url(proceed_to_url: edit_identity_email_url)
  end

  test "should update email" do
    patch identity_email_url, params: { email: "new_email@hey.com" }
    assert_redirected_to root_url
  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" }
    assert_redirected_to new_sessions_sudo_url(proceed_to_url: identity_email_url)
  end

  def sign_in_as(<%= singular_table_name %>)
    post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); <%= singular_table_name %>
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authentication-zero-2.9.2 lib/generators/authentication/templates/test_unit/controllers/html/identity/emails_controller_test.rb.tt
authentication-zero-2.9.1 lib/generators/authentication/templates/test_unit/controllers/html/identity/emails_controller_test.rb.tt
authentication-zero-2.9.0 lib/generators/authentication/templates/test_unit/controllers/html/identity/emails_controller_test.rb.tt