Skip to content

Commit

Permalink
Merge pull request #11174 from krauselukas/fix/hide_scm_channel
Browse files Browse the repository at this point in the history
Hide scm channel from subscription configuration page
  • Loading branch information
krauselukas committed May 25, 2021
2 parents 1379e72 + 44a93e8 commit 659f1e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/api/app/models/event_subscription.rb
Expand Up @@ -21,6 +21,9 @@ class EventSubscription < ApplicationRecord
scm: 4
}

# Channels used by the event system, but not meant to be enabled by hand
INTERNAL_ONLY_CHANNELS = ['scm'].freeze

serialize :payload, JSON

belongs_to :user, inverse_of: :event_subscriptions
Expand Down Expand Up @@ -77,8 +80,8 @@ def parameters_for_notification
subscription_receiver_role: receiver_role }
end

def self.without_channel_disabled
channels.keys.reject { |channel| channel == 'disabled' }
def self.without_disabled_or_internal_channels
channels.keys.reject { |channel| channel == 'disabled' || channel.in?(INTERNAL_ONLY_CHANNELS) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/event_subscription/for_role_form.rb
Expand Up @@ -10,7 +10,7 @@ def initialize(role_name, event, subscriber)
end

def call
@channels = EventSubscription.without_channel_disabled.map do |channel|
@channels = EventSubscription.without_disabled_or_internal_channels.map do |channel|
channel_for_event_class_and_role(@event, name, channel)
end

Expand Down
Expand Up @@ -9,7 +9,7 @@
let(:subscription) { channel.subscription }

RSpec.shared_examples 'a channel with subscription' do |channel_name|
it { expect(subject.channels.map(&:name)).to match_array(EventSubscription.channels.keys[1..-1]) }
it { expect(subject.channels.map(&:name)).to match_array(EventSubscription.without_disabled_or_internal_channels) }
it { expect(channel.name).to eq(channel_name) }
it { expect(subscription.eventtype).to eq(event_class.to_s) }
it { expect(subscription.receiver_role).to eq(role) }
Expand Down

0 comments on commit 659f1e0

Please sign in to comment.