From 4d710ef84d4cd78b489c1b7a7f386adc204215a4 Mon Sep 17 00:00:00 2001 From: Roberto Miranda Date: Mon, 16 Dec 2019 13:43:56 +0000 Subject: [PATCH 1/4] Rename protected branches, in order to reflect they real intention in the test --- spec/integration/protected_branches_spec.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/integration/protected_branches_spec.rb b/spec/integration/protected_branches_spec.rb index 115be29d..f1e36c09 100644 --- a/spec/integration/protected_branches_spec.rb +++ b/spec/integration/protected_branches_spec.rb @@ -23,14 +23,13 @@ ProtectedBranches: enabled: true branches: - - protected - - protected_for_destructive_only: - destructive_only: true + - protected_for_destructive_only + YML around do |example| remote_repo = repo do - `git checkout -b protected > #{File::NULL} 2>&1` + `git checkout -b protected_for_destructive_only > #{File::NULL} 2>&1` `git commit --allow-empty -m "Remote commit"` `git checkout -b unprotected > #{File::NULL} 2>&1` `git checkout -b dummy > #{File::NULL} 2>&1` @@ -152,8 +151,8 @@ end end - context 'when pushing to a protected branch' do - let(:remote_ref) { 'protected' } + context 'when pushing to a protected for destructive only branch' do + let(:remote_ref) { 'protected_for_destructive_only' } context 'when force-pushing' do include_context 'force-pushing' From 3ba4f64c7bc160bdfe2c3c7b0799b145d19f24e8 Mon Sep 17 00:00:00 2001 From: Roberto Miranda Date: Mon, 16 Dec 2019 14:08:58 +0000 Subject: [PATCH 2/4] Add protected branch scenario --- spec/integration/protected_branches_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/integration/protected_branches_spec.rb b/spec/integration/protected_branches_spec.rb index f1e36c09..dee42091 100644 --- a/spec/integration/protected_branches_spec.rb +++ b/spec/integration/protected_branches_spec.rb @@ -24,6 +24,8 @@ enabled: true branches: - protected_for_destructive_only + - protected: + destructive_only: false YML @@ -31,6 +33,7 @@ remote_repo = repo do `git checkout -b protected_for_destructive_only > #{File::NULL} 2>&1` `git commit --allow-empty -m "Remote commit"` + `git checkout -b protected > #{File::NULL} 2>&1` `git checkout -b unprotected > #{File::NULL} 2>&1` `git checkout -b dummy > #{File::NULL} 2>&1` end @@ -151,6 +154,21 @@ end end + context "when pushing to a protected branch" do + let(:remote_ref) { 'protected' } + + subject do + shell("git push #{flags} origin HEAD".split) + end + + context 'when pushing' do + context 'with ProtectedBranches enabled' do + include_context 'ProtectedBranches enabled' + include_examples 'push fails' + end + end + end + context 'when pushing to a protected for destructive only branch' do let(:remote_ref) { 'protected_for_destructive_only' } From a66054000ccb0ffbef5d7818c319f67401b86081 Mon Sep 17 00:00:00 2001 From: Roberto Miranda Date: Mon, 16 Dec 2019 14:20:12 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=92=87=E2=80=8D=E2=99=80=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/integration/protected_branches_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/integration/protected_branches_spec.rb b/spec/integration/protected_branches_spec.rb index dee42091..9c5c5de9 100644 --- a/spec/integration/protected_branches_spec.rb +++ b/spec/integration/protected_branches_spec.rb @@ -154,7 +154,7 @@ end end - context "when pushing to a protected branch" do + context 'when pushing to a protected branch' do let(:remote_ref) { 'protected' } subject do From aa8e25864d4698e21c6011b31881bb1a5880e86a Mon Sep 17 00:00:00 2001 From: Roberto Miranda Date: Mon, 16 Dec 2019 14:20:56 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=92=87=E2=80=8D=E2=99=80=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/integration/protected_branches_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/integration/protected_branches_spec.rb b/spec/integration/protected_branches_spec.rb index 9c5c5de9..ef1b9201 100644 --- a/spec/integration/protected_branches_spec.rb +++ b/spec/integration/protected_branches_spec.rb @@ -157,10 +157,6 @@ context 'when pushing to a protected branch' do let(:remote_ref) { 'protected' } - subject do - shell("git push #{flags} origin HEAD".split) - end - context 'when pushing' do context 'with ProtectedBranches enabled' do include_context 'ProtectedBranches enabled'