BigW Consortium Gitlab

Commit 52c8651a by Chris Wilson

Fix notify_only_default_branch check for Slack service

The notify_only_default_branch property is using boolean_accessor this means we need to check it using a question methods. Also add specs for disabling this option.
parent 8b9cd3c0
......@@ -150,7 +150,7 @@ class ChatNotificationService < Service
def notify_for_ref?(data)
return true if data[:object_attributes][:tag]
return true unless notify_only_default_branch
return true unless notify_only_default_branch?
data[:object_attributes][:ref] == project.default_branch
end
......
---
title: Fix notify_only_default_branch check for Slack service
merge_request:
author:
......@@ -328,7 +328,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
context 'only notify for the default branch' do
context 'when enabled' do
let(:pipeline) do
create(:ci_pipeline, project: project, status: 'failed', ref: 'not-the-default-branch')
create(:ci_pipeline, :failed, project: project, ref: 'not-the-default-branch')
end
before do
......@@ -342,6 +342,18 @@ RSpec.shared_examples 'slack or mattermost notifications' do
expect(result).to be_falsy
end
end
context 'when disabled' do
let(:pipeline) do
create(:ci_pipeline, :failed, project: project, ref: 'not-the-default-branch')
end
before do
chat_service.notify_only_default_branch = false
end
it_behaves_like 'call Slack/Mattermost API'
end
end
end
end
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