Sha256: 073a76fbc64ff33030c802ed6de29091f70f38346e6c7474190d9bb58e206275

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

require "test_helper"

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

  test "should get edit" do
    get edit_emails_url
    assert_response :success
  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", <%= singular_table_name %>: { email: "new_email@hey.com" } }
    end

    assert_redirected_to root_path
  end

  test "should not update email with wrong current password" do
    assert_no_enqueued_emails do
      patch emails_url, params: { current_password: "wrong_password", <%= singular_table_name %>: { email: @<%= singular_table_name %>.email } }
    end

    assert_redirected_to edit_emails_path
    assert_equal "The current password you entered is incorrect", flash[:alert]
  end

  def sign_in_as(<%= singular_table_name %>)
    post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
authentication-zero-2.0.0 lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
authentication-zero-1.0.2 lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
authentication-zero-1.0.1 lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
authentication-zero-1.0.0 lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
authentication-zero-0.0.24 lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
authentication-zero-0.0.23 lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt