Sha256: ea0973a121ce6e94bcf00c8bd051bc61fe5b8f257ae7b6edb07887a6056cc226

Contents?: true

Size: 981 Bytes

Versions: 9

Compression:

Stored size: 981 Bytes

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_email_url
    assert_response :success
  end

  test "should update email" do
    patch email_url, params: { current_password: "secret123", <%= singular_table_name %>: { email: "new_email@hey.com" } }
    assert_redirected_to root_path
  end

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

    assert_redirected_to edit_email_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" }); <%= singular_table_name %>
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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