mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
fix: Only admins can generate invite codes (#1611)
* fix: Only admins can generate invite codes * fix: raise error if user is not an admin when creating invite codesss
This commit is contained in:
20
test/controllers/invite_codes_controller_test.rb
Normal file
20
test/controllers/invite_codes_controller_test.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
require "test_helper"
|
||||
|
||||
class InviteCodesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
Rails.application.config.app_mode.stubs(:self_hosted?).returns(true)
|
||||
end
|
||||
test "admin can generate invite codes" do
|
||||
sign_in users(:family_admin)
|
||||
|
||||
assert_difference("InviteCode.count") do
|
||||
post invite_codes_url, params: {}
|
||||
end
|
||||
end
|
||||
|
||||
test "non-admin cannot generate invite codes" do
|
||||
sign_in users(:family_member)
|
||||
|
||||
assert_raises(StandardError) { post invite_codes_url, params: {} }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user