trabajo-afectivo/spec/db/migrate/issue_2608_missing_trigger_permission_spec.rb

26 lines
719 B
Ruby
Raw Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
require 'rails_helper'
RSpec.describe Issue2608MissingTriggerPermission, type: :db_migration do
let(:name) { 'admin.trigger' }
context 'when "admin.trigger" permission already exists' do
before { Permission.find_or_create_by(name: name) }
it 'does nothing' do
expect { migrate }.not_to change(Permission, :count)
end
end
context 'when "admin.trigger" permission does not exist' do
before { Permission.find_by(name: name)&.destroy }
it 'creates it' do
expect { migrate }
.to change(Permission, :count).by(1)
.and change { Permission.exists?(name: name) }.to(true)
end
end
end