Sha256: ed5eaff5350b08bf401c3f0c9ee7aaa8e64720790e71e786e3753b7d3741cfad

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 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_not_nil user.reload
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kaze-0.17.0 stubs/default/test/integration/profile_test.rb
kaze-0.16.0 stubs/default/test/integration/profile_test.rb
kaze-0.15.0 stubs/default/test/integration/profile_test.rb
kaze-0.14.0 stubs/default/test/integration/profile_test.rb