Commit 3be8d15e authored by Mark Lapierre's avatar Mark Lapierre

Wait for branch protection before removing it

Tests can fail if they try to remove protection from a branch
immediately after the repo was created. This adds a readme so
the repo is created ASAP, and waits for the branch protection
to be applied before removing it.
parent b640376c
......@@ -72,6 +72,16 @@ module QA
self.remove_via_api!(&block)
end
# Remove the branch protection after confirming that it exists
def remove_via_api!
Support::Retrier.retry_until(max_duration: 60, sleep_interval: 1, message: "Waiting for branch #{branch_name} to be protected") do
# We confirm it exists before removal because there's no creation event when the default branch is automatically protected by GitLab itself, and there's a slight delay between creating the repo and protecting the default branch
exists?
end
super
end
def api_get_path
"/projects/#{project.id}/protected_branches/#{branch_name}"
end
......
......@@ -4,7 +4,9 @@ module QA
RSpec.describe 'Create', :requires_admin do
describe 'Setup an MR with codeowners file' do
let(:project) do
Resource::Project.fabricate_via_api!
Resource::Project.fabricate_via_api! do |project|
project.initialize_with_readme = true
end
end
let!(:target) 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