Sha256: 674900b4980f142e406e08e3e000421422321a77b6fcf31d6dd988162f5a5b53

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

require 'test_helper'

class ProfileTest < ActionDispatch::IntegrationTest
  test 'profile page is displayed' do
    user = FactoryBot.create(:user)

    acting_as(user).get profile_edit_path

    assert_response :success
  end

  test 'profile information can be updated' do
    user = FactoryBot.create(:user)

    acting_as(user).patch profile_edit_path, params: {
      name: 'Test User',
      email: 'test@example.com'
    }

    assert_redirected_to profile_edit_path

    user.reload

    assert_equal 'Test User', user.name
    assert_equal 'test@example.com', user.email
  end

  test 'email verification status is unchanged when the email address is unchanged' do
    user = FactoryBot.create(:user)

    acting_as(user).patch profile_edit_path, params: {
      name: 'Test User',
      email: user.email
    }

    assert_redirected_to profile_edit_path
    assert_not user.reload.email_verified_at.blank?
  end

  test 'user can delete their account' do
    user = FactoryBot.create(:user)

    acting_as(user).delete profile_destroy_path, params: {
      password: 'password'
    }

    assert_redirected_to '/'

    assert_guest
    assert_raise(ActiveRecord::RecordNotFound) { user.reload }
  end

  test 'correct password must be provided to delete account' do
    user = FactoryBot.create(:user)

    acting_as(user).delete profile_destroy_path, params: {
      password: 'wrong-password'
    }

    assert_response :unprocessable_entity
    assert_not_nil user.reload
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kaze-0.13.0 stubs/default/test/integration/profile_test.rb
kaze-0.12.0 stubs/default/test/integration/profile_test.rb
kaze-0.11.0 stubs/default/test/integration/profile_test.rb
kaze-0.10.0 stubs/default/test/integration/profile_test.rb