Change: 一般ユーザーはデフォルトで招待を不可にするよう変更 (#629)
* Change: 一般ユーザーはデフォルトで招待を不可にするよう変更 * Fix test
This commit is contained in:
parent
878b4eb2ce
commit
4119b8713e
3 changed files with 9 additions and 3 deletions
|
@ -47,7 +47,8 @@ class UserRole < ApplicationRecord
|
|||
NONE = 0
|
||||
ALL = FLAGS.values.reduce(&:|)
|
||||
|
||||
DEFAULT = FLAGS[:invite_users]
|
||||
DEFAULT = 0
|
||||
EVERYONE_ALLOWED = FLAGS[:invite_users]
|
||||
|
||||
CATEGORIES = {
|
||||
invites: %i(
|
||||
|
@ -197,6 +198,6 @@ class UserRole < ApplicationRecord
|
|||
end
|
||||
|
||||
def validate_dangerous_permissions
|
||||
errors.add(:permissions_as_keys, :dangerous) if everyone? && Flags::DEFAULT & permissions != permissions
|
||||
errors.add(:permissions_as_keys, :dangerous) if everyone? && Flags::EVERYONE_ALLOWED & permissions != permissions
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,6 +28,7 @@ admin:
|
|||
- manage_custom_emojis
|
||||
- manage_webhooks
|
||||
- manage_roles
|
||||
- invite_users
|
||||
owner:
|
||||
name: Owner
|
||||
position: 1000
|
||||
|
|
|
@ -135,12 +135,16 @@ RSpec.describe UserRole do
|
|||
end
|
||||
|
||||
it 'has default permissions' do
|
||||
expect(subject.permissions).to eq UserRole::FLAGS[:invite_users]
|
||||
expect(subject.permissions).to eq 0
|
||||
end
|
||||
|
||||
it 'has negative position' do
|
||||
expect(subject.position).to eq(described_class::NOBODY_POSITION)
|
||||
end
|
||||
|
||||
it 'is able to add invite permission' do
|
||||
expect { subject.update!(permissions: UserRole::FLAGS[:invite_users]) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe '.nobody' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue