Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: 一般ユーザーはデフォルトで招待を不可にするよう変更 #629

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/models/user_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ module Flags
NONE = 0
ALL = FLAGS.values.reduce(&:|)

DEFAULT = FLAGS[:invite_users]
DEFAULT = 0
EVERYONE_ALLOWED = FLAGS[:invite_users]

CATEGORIES = {
invites: %i(
Expand Down Expand Up @@ -196,6 +197,6 @@ def validate_position_elevation
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
1 change: 1 addition & 0 deletions config/roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ admin:
- manage_custom_emojis
- manage_webhooks
- manage_roles
- invite_users
owner:
name: Owner
position: 1000
Expand Down
6 changes: 5 additions & 1 deletion spec/models/user_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@
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(-1)
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
Expand Down
Loading