issue_4243_permission_fix_spec.rb 756 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue4243PermissionFix, type: :db_migration do
  4. let!(:test_role) do
  5. role = create(:role)
  6. role.group_names_access_map = {
  7. Group.first.name => 'full',
  8. }
  9. role
  10. end
  11. let!(:agent_role) do
  12. role = create(:role, :agent)
  13. role.group_names_access_map = {
  14. Group.first.name => 'full',
  15. }
  16. role
  17. end
  18. before do
  19. migrate
  20. end
  21. it 'does remove the groups if the role does not have the ticket.agent permissions' do
  22. expect(test_role.reload.groups).to eq([])
  23. end
  24. it 'does nothing if the role does have the ticket.agent permissions' do
  25. expect(agent_role.reload.groups).to be_present
  26. end
  27. end