issue_2608_missing_trigger_permission_spec.rb 719 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue2608MissingTriggerPermission, type: :db_migration do
  4. let(:name) { 'admin.trigger' }
  5. context 'when "admin.trigger" permission already exists' do
  6. before { Permission.find_or_create_by(name: name) }
  7. it 'does nothing' do
  8. expect { migrate }.not_to change(Permission, :count)
  9. end
  10. end
  11. context 'when "admin.trigger" permission does not exist' do
  12. before { Permission.find_by(name: name)&.destroy }
  13. it 'creates it' do
  14. expect { migrate }
  15. .to change(Permission, :count).by(1)
  16. .and change { Permission.exists?(name: name) }.to(true)
  17. end
  18. end
  19. end