-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
… without ticket.agent permission but group relations.
- Loading branch information
1 parent
c73fa7c
commit a6102e7
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
class Issue4243PermissionFix < ActiveRecord::Migration[6.1] | ||
def change | ||
# return if it's a new setup | ||
return if !Setting.exists?(name: 'system_init_done') | ||
|
||
Role.find_each do |role| | ||
next if role.groups.blank? | ||
|
||
role.permissions |= Permission.where(name: 'ticket.agent') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Issue4243PermissionFix, type: :db_migration do | ||
let!(:test_role) do | ||
role = create(:role) | ||
role.group_names_access_map = { | ||
Group.first.name => 'full', | ||
} | ||
role | ||
end | ||
|
||
before do | ||
migrate | ||
end | ||
|
||
it 'does add the permission if groups are present but ticket.agent permission is not set' do | ||
expect(test_role.reload.permissions).to include(Permission.find_by(name: 'ticket.agent')) | ||
end | ||
end |