diff --git a/spec/models/webhook_spec.rb b/spec/models/webhook_spec.rb index d856793759..3bce8c7931 100644 --- a/spec/models/webhook_spec.rb +++ b/spec/models/webhook_spec.rb @@ -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! }