permission_switch_to_label_description_spec.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe PermissionSwitchToLabelDescription, db_strategy: :reset, type: :db_migration do
  4. let(:permission) { Permission.find_by! name: permission_name }
  5. let(:permission_name) { 'admin' }
  6. before do
  7. ActiveRecord::Migration.rename_column(:permissions, :description, :note)
  8. ActiveRecord::Migration.remove_column(:permissions, :label)
  9. Permission.reset_column_information
  10. permission.preferences[:translations] = ['Sample']
  11. permission.preferences.delete(:prio)
  12. permission.save!(validate: false)
  13. end
  14. it 'updates attributes' do
  15. migrate
  16. expect(permission.reload).to have_attributes(
  17. label: 'Admin interface',
  18. description: 'Configure your system.',
  19. preferences: { prio: 1_000 }
  20. )
  21. end
  22. context 'when permission has additional preferences' do
  23. let(:permission_name) { 'user_preferences.overview_sorting' }
  24. it 'keeps additional preferences' do
  25. migrate
  26. expect(permission.reload).to have_attributes(
  27. preferences: { prio: 1690, required: ['ticket.agent'] }
  28. )
  29. end
  30. end
  31. end