Sha256: 516c9eb6f6697ada6db9fba3ca2c5fa0ca495e8eeb73bc3a817de687e8edb5a8

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 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 '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

3 entries across 3 versions & 1 rubygems

Version Path
kaze-0.8.0 stubs/default/test/integration/profile_test.rb
kaze-0.7.0 stubs/default/test/integration/profile_test.rb
kaze-0.6.0 stubs/default/test/integration/profile_test.rb