Commit 20a2d906 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

RSpec hg_access_protected_branches: removed lengthy setup

It turns out that these tests don't need the branches to actually
exist. This gets the time to run this RSpec file down from 10
minutes to less than 4 on my development workstation.

That is enough to make sharding meaningful.

Of course that raises the question whether they test anything,
since some expected Forbidden could actually now be raised for
the wrong reason. There is the case of the
`safe_commit_for_new_protected_branch?` where one checks that
protected branch rules are applied even if the commit actually
creates the protected branch (through wildcard protection,
that is indeed possible), but this is not currently covered,
although it should.

In other words actual coverage is no worse, and we should add
new tests for the cases that aren't strongly covered,
(perhaps UPSTREAM).

The empty repo is a special case, but the general factory fixture
takes care of that.

branch : heptapod-stable
parent fc0da2f09a87
......@@ -28,10 +28,6 @@
# for a protected branch name (either branch/feature or branch/exact
let(:topic_protected_branch) { 'topic/feature/follow-up' }
before do
let(:mr_iid) { nil }
# last element of each list is the accept_mr_iid
......@@ -56,32 +52,6 @@
] }
# GR rename as prepare_mergeable_into_protected_branch ?
def mergeable_into_protected_branch
# This is obviously to avoid repeated setup. The examples don't
# actually perform actual pushes, so we can indeed just keep it as is
@mergeable_into_protected_branch_sha ||=
'feature', # file name
'start of "feature" branch', # file content
branch_name: 'branch/feature',
start_branch_name: 'branch/default',
message: "potentially protected branch creation"
'This is the file content',
message: 'This is a good commit message',
start_branch_name: 'branch/feature',
branch_name: topic_protected_branch
def self.run_permission_checks(permissions_matrix)
permissions_matrix.each_pair do |role, matrix|
# Run through the entire matrix for this role in one test to avoid
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