Add coverage for .permission_for_event

This commit is contained in:
Matt Jankowski 2024-10-12 17:02:36 -04:00
parent 74faa1fd22
commit 21ff5e9656

View file

@ -19,6 +19,58 @@ RSpec.describe Webhook do
end
end
describe '.permission_for_event' do
subject { described_class.permission_for_event(event) }
context 'with a nil value' do
let(:event) { nil }
it { is_expected.to be_nil }
end
context 'with an account approved event' do
let(:event) { 'account.approved' }
it { is_expected.to eq(:manage_users) }
end
context 'with an account created event' do
let(:event) { 'account.created' }
it { is_expected.to eq(:manage_users) }
end
context 'with an account updated event' do
let(:event) { 'account.updated' }
it { is_expected.to eq(:manage_users) }
end
context 'with an report created event' do
let(:event) { 'report.created' }
it { is_expected.to eq(:manage_reports) }
end
context 'with an report updated event' do
let(:event) { 'report.updated' }
it { is_expected.to eq(:manage_reports) }
end
context 'with an status created event' do
let(:event) { 'status.created' }
it { is_expected.to eq(:view_devops) }
end
context 'with an status updated event' do
let(:event) { 'status.updated' }
it { is_expected.to eq(:view_devops) }
end
end
describe '#rotate_secret!' do
it 'changes the secret' do
expect { webhook.rotate_secret! }