Commit 37e3b969 authored by Balasankar "Balu" C's avatar Balasankar "Balu" C

Enhance specs for notifications for protected branches

Signed-off-by: default avatarBalasankar "Balu" C <balasankar@gitlab.com>
parent 7bb880ae
...@@ -369,6 +369,48 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name| ...@@ -369,6 +369,48 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
end end
end end
context 'on a protected branch with protected branches defined using wildcards' do
before do
create(:protected_branch, project: project, name: '*-stable')
end
let(:data) do
Gitlab::DataBuilder::Push.build(
project: project,
user: user,
ref: '1-stable'
)
end
context 'pushing tags' do
let(:data) do
Gitlab::DataBuilder::Push.build(
project: project,
user: user,
ref: "#{Gitlab::Git::TAG_REF_PREFIX}test"
)
end
it_behaves_like "triggered #{service_name} service", event_type: "push"
end
context 'notification enabled only for default branch' do
it_behaves_like "untriggered #{service_name} service", event_type: "push", branches_to_be_notified: "default"
end
context 'notification enabled only for protected branches' do
it_behaves_like "triggered #{service_name} service", event_type: "push", branches_to_be_notified: "protected"
end
context 'notification enabled only for default and protected branches' do
it_behaves_like "triggered #{service_name} service", event_type: "push", branches_to_be_notified: "default_and_protected"
end
context 'notification enabled for all branches' do
it_behaves_like "triggered #{service_name} service", event_type: "push", branches_to_be_notified: "all"
end
end
context 'on a neither protected nor default branch' do context 'on a neither protected nor default branch' do
let(:data) do let(:data) do
Gitlab::DataBuilder::Push.build( Gitlab::DataBuilder::Push.build(
...@@ -570,6 +612,36 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name| ...@@ -570,6 +612,36 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
end end
end end
context 'on a protected branch with protected branches defined usin wildcards' do
before do
create(:protected_branch, project: project, name: '*-stable')
end
let(:pipeline) do
create(:ci_pipeline,
project: project, status: :failed,
sha: project.commit.sha, ref: '1-stable')
end
let(:data) { Gitlab::DataBuilder::Pipeline.build(pipeline) }
context 'notification enabled only for default branch' do
it_behaves_like "untriggered #{service_name} service", event_type: "pipeline", branches_to_be_notified: "default"
end
context 'notification enabled only for protected branches' do
it_behaves_like "triggered #{service_name} service", event_type: "pipeline", branches_to_be_notified: "protected"
end
context 'notification enabled only for default and protected branches' do
it_behaves_like "triggered #{service_name} service", event_type: "pipeline", branches_to_be_notified: "default_and_protected"
end
context 'notification enabled for all branches' do
it_behaves_like "triggered #{service_name} service", event_type: "pipeline", branches_to_be_notified: "all"
end
end
context 'on a neither protected nor default branch' do context 'on a neither protected nor default branch' do
let(:pipeline) do let(:pipeline) do
create(:ci_pipeline, create(:ci_pipeline,
......
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