Commit 25f5188e authored by Kerri Miller's avatar Kerri Miller

Merge branch 'fix-protected-branch-notification-tests' into 'master'

Fix chat notification protected branch tests

See merge request gitlab-org/gitlab!74816
parents 4a2c929b a1347b16
......@@ -2,7 +2,7 @@
FactoryBot.define do
factory :protected_branch do
name
sequence(:name) { |n| "protected_branch_#{n}" }
project
transient do
......@@ -11,6 +11,20 @@ FactoryBot.define do
default_access_level { true }
end
trait :create_branch_on_repository do
association :project, factory: [:project, :repository]
transient do
repository_branch_name { name }
end
after(:create) do |protected_branch, evaluator|
project = protected_branch.project
project.repository.create_branch(evaluator.repository_branch_name, project.default_branch_or_main)
end
end
trait :developers_can_push do
transient do
default_push_level { false }
......
......@@ -304,7 +304,7 @@ RSpec.describe Integrations::MicrosoftTeams do
context 'with protected branch' do
before do
create(:protected_branch, project: project, name: 'a-protected-branch')
create(:protected_branch, :create_branch_on_repository, project: project, name: 'a-protected-branch')
end
let(:pipeline) do
......
......@@ -113,7 +113,7 @@ RSpec.shared_examples "chat integration" do |integration_name|
context "with protected branch" do
before do
create(:protected_branch, project: project, name: "a-protected-branch")
create(:protected_branch, :create_branch_on_repository, project: project, name: "a-protected-branch")
end
let(:sample_data) do
......@@ -309,7 +309,7 @@ RSpec.shared_examples "chat integration" do |integration_name|
context "with protected branch" do
before do
create(:protected_branch, project: project, name: "a-protected-branch")
create(:protected_branch, :create_branch_on_repository, project: project, name: "a-protected-branch")
end
let(:sample_data) do
......
......@@ -305,7 +305,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch' do
before do
create(:protected_branch, project: project, name: 'a-protected-branch')
create(:protected_branch, :create_branch_on_repository, project: project, name: 'a-protected-branch')
end
let(:data) do
......@@ -347,7 +347,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch with protected branches defined using wildcards' do
before do
create(:protected_branch, project: project, name: '*-stable')
create(:protected_branch, :create_branch_on_repository, repository_branch_name: '1-stable', project: project, name: '*-stable')
end
let(:data) do
......@@ -560,7 +560,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch' do
before do
create(:protected_branch, project: project, name: 'a-protected-branch')
create(:protected_branch, :create_branch_on_repository, project: project, name: 'a-protected-branch')
end
let(:pipeline) do
......@@ -590,7 +590,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch with protected branches defined usin wildcards' do
before do
create(:protected_branch, project: project, name: '*-stable')
create(:protected_branch, :create_branch_on_repository, repository_branch_name: '1-stable', project: project, name: '*-stable')
end
let(:pipeline) do
......
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