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 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :protected_branch do factory :protected_branch do
name sequence(:name) { |n| "protected_branch_#{n}" }
project project
transient do transient do
...@@ -11,6 +11,20 @@ FactoryBot.define do ...@@ -11,6 +11,20 @@ FactoryBot.define do
default_access_level { true } default_access_level { true }
end 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 trait :developers_can_push do
transient do transient do
default_push_level { false } default_push_level { false }
......
...@@ -304,7 +304,7 @@ RSpec.describe Integrations::MicrosoftTeams do ...@@ -304,7 +304,7 @@ RSpec.describe Integrations::MicrosoftTeams do
context 'with protected branch' do context 'with protected branch' do
before 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 end
let(:pipeline) do let(:pipeline) do
......
...@@ -113,7 +113,7 @@ RSpec.shared_examples "chat integration" do |integration_name| ...@@ -113,7 +113,7 @@ RSpec.shared_examples "chat integration" do |integration_name|
context "with protected branch" do context "with protected branch" do
before 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 end
let(:sample_data) do let(:sample_data) do
...@@ -309,7 +309,7 @@ RSpec.shared_examples "chat integration" do |integration_name| ...@@ -309,7 +309,7 @@ RSpec.shared_examples "chat integration" do |integration_name|
context "with protected branch" do context "with protected branch" do
before 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 end
let(:sample_data) do let(:sample_data) do
......
...@@ -305,7 +305,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name| ...@@ -305,7 +305,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch' do context 'on a protected branch' do
before 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 end
let(:data) do let(:data) do
...@@ -347,7 +347,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name| ...@@ -347,7 +347,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch with protected branches defined using wildcards' do context 'on a protected branch with protected branches defined using wildcards' do
before 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 end
let(:data) do let(:data) do
...@@ -560,7 +560,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name| ...@@ -560,7 +560,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch' do context 'on a protected branch' do
before 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 end
let(:pipeline) do let(:pipeline) do
...@@ -590,7 +590,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name| ...@@ -590,7 +590,7 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
context 'on a protected branch with protected branches defined usin wildcards' do context 'on a protected branch with protected branches defined usin wildcards' do
before 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 end
let(:pipeline) do 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