Commit a1347b16 authored by Andy Soiron's avatar Andy Soiron Committed by Kerri Miller

Fix chat notification protected branch tests

parent 57ac6715
......@@ -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