mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* Replace Maybe for Sure in select code areas * Make sure passwords are consistent * Remove (admin|member) from demo data first name * Database and schema names finally to `sure` * Fix broken test * Another (benchmarking) database name to `sure_*` * More rebranding to Sure * Missed this Maybe mention in the same page * Random nitpicks and more Maybes * Demo data accounts and more Maybes * Test data account updates * Impersonation test accounts * Consistency with `compose.example.yml`
41 lines
1.0 KiB
Ruby
41 lines
1.0 KiB
Ruby
require "test_helper"
|
|
|
|
class ImpersonationSessionTest < ActiveSupport::TestCase
|
|
test "only super admin can impersonate" do
|
|
regular_user = users(:family_member)
|
|
|
|
assert_not regular_user.super_admin?
|
|
|
|
assert_raises(ActiveRecord::RecordInvalid) do
|
|
ImpersonationSession.create!(
|
|
impersonator: regular_user,
|
|
impersonated: users(:sure_support_staff)
|
|
)
|
|
end
|
|
end
|
|
|
|
test "super admin cannot be impersonated" do
|
|
super_admin = users(:sure_support_staff)
|
|
|
|
assert super_admin.super_admin?
|
|
|
|
assert_raises(ActiveRecord::RecordInvalid) do
|
|
ImpersonationSession.create!(
|
|
impersonator: users(:family_member),
|
|
impersonated: super_admin
|
|
)
|
|
end
|
|
end
|
|
|
|
test "impersonation session must have different impersonator and impersonated" do
|
|
super_admin = users(:sure_support_staff)
|
|
|
|
assert_raises(ActiveRecord::RecordInvalid) do
|
|
ImpersonationSession.create!(
|
|
impersonator: super_admin,
|
|
impersonated: super_admin
|
|
)
|
|
end
|
|
end
|
|
end
|