issue_2608_missing_trigger_permission_spec.rb 642 B

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