mirror of https://github.com/tootsuite/mastodon
Add coverage for .required_permissions, make unique
parent
bca7d9302b
commit
961afb47e8
|
@ -53,7 +53,9 @@ class Webhook < ApplicationRecord
|
|||
end
|
||||
|
||||
def required_permissions
|
||||
events.map { |event| Webhook.permission_for_event(event) }
|
||||
events
|
||||
.map { |event| Webhook.permission_for_event(event) }
|
||||
.uniq
|
||||
end
|
||||
|
||||
def self.permission_for_event(event)
|
||||
|
|
|
@ -71,6 +71,22 @@ RSpec.describe Webhook do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#required_permissions' do
|
||||
subject { described_class.new(events:).required_permissions }
|
||||
|
||||
context 'with empty events' do
|
||||
let(:events) { [] }
|
||||
|
||||
it { is_expected.to eq([]) }
|
||||
end
|
||||
|
||||
context 'with multiple event types' do
|
||||
let(:events) { %w(account.created account.updated status.created) }
|
||||
|
||||
it { is_expected.to eq %i(manage_users view_devops) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#rotate_secret!' do
|
||||
it 'changes the secret' do
|
||||
expect { webhook.rotate_secret! }
|
||||
|
|
Loading…
Reference in New Issue