Commit db328436 authored by Markus Koller's avatar Markus Koller

Merge branch 'fix-slack-label-filter-behavior-blank' into 'master'

Fix slack label filter behavior blank

See merge request gitlab-org/gitlab!61236
parents 1762ca57 c428b294
...@@ -30,7 +30,7 @@ class ChatNotificationService < Service ...@@ -30,7 +30,7 @@ class ChatNotificationService < Service
boolean_accessor :notify_only_broken_pipelines, :notify_only_default_branch boolean_accessor :notify_only_broken_pipelines, :notify_only_default_branch
validates :webhook, presence: true, public_url: true, if: :activated? validates :webhook, presence: true, public_url: true, if: :activated?
validates :labels_to_be_notified_behavior, inclusion: { in: LABEL_NOTIFICATION_BEHAVIOURS }, allow_nil: true validates :labels_to_be_notified_behavior, inclusion: { in: LABEL_NOTIFICATION_BEHAVIOURS }, allow_blank: true
def initialize_properties def initialize_properties
if properties.nil? if properties.nil?
......
---
title: Fix slack label filter behavior blank
merge_request: 61236
author:
type: fixed
...@@ -12,7 +12,7 @@ RSpec.describe ChatNotificationService do ...@@ -12,7 +12,7 @@ RSpec.describe ChatNotificationService do
end end
describe 'validations' do describe 'validations' do
it { is_expected.to validate_inclusion_of(:labels_to_be_notified_behavior).in_array(%w[match_any match_all]) } it { is_expected.to validate_inclusion_of(:labels_to_be_notified_behavior).in_array(%w[match_any match_all]).allow_blank }
end end
describe '#can_test?' do describe '#can_test?' do
...@@ -127,6 +127,22 @@ RSpec.describe ChatNotificationService do ...@@ -127,6 +127,22 @@ RSpec.describe ChatNotificationService do
end end
end end
context 'when labels_to_be_notified_behavior is blank' do
subject(:chat_service) { described_class.new(labels_to_be_notified: label_filter, labels_to_be_notified_behavior: '') }
context 'no matching labels' do
let(:label_filter) { '~some random label' }
it_behaves_like 'does not notify the chat service'
end
context 'only one label matches' do
let(:label_filter) { '~some random label, ~Bug' }
it_behaves_like 'notifies the chat service'
end
end
context 'when labels_to_be_notified_behavior is match_any' do context 'when labels_to_be_notified_behavior is match_any' do
subject(:chat_service) do subject(:chat_service) do
described_class.new( described_class.new(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment