Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/policies/ci/bridge_policy_spec.rb')
-rw-r--r--spec/policies/ci/bridge_policy_spec.rb34
1 files changed, 23 insertions, 11 deletions
diff --git a/spec/policies/ci/bridge_policy_spec.rb b/spec/policies/ci/bridge_policy_spec.rb
index d23355b4c1e..29eb4d94c03 100644
--- a/spec/policies/ci/bridge_policy_spec.rb
+++ b/spec/policies/ci/bridge_policy_spec.rb
@@ -16,22 +16,34 @@ RSpec.describe Ci::BridgePolicy do
it_behaves_like 'a deployable job policy', :ci_bridge
describe '#play_job' do
- before do
- fake_access = double('Gitlab::UserAccess')
- expect(fake_access).to receive(:can_update_branch?).with('master').and_return(can_update_branch)
- expect(Gitlab::UserAccess).to receive(:new).with(user, container: downstream_project).and_return(fake_access)
- end
+ context 'when downstream project exists' do
+ before do
+ fake_access = double('Gitlab::UserAccess')
+ expect(fake_access).to receive(:can_update_branch?).with('master').and_return(can_update_branch)
+ expect(Gitlab::UserAccess).to receive(:new).with(user, container: downstream_project).and_return(fake_access)
+ end
+
+ context 'when user can update the downstream branch' do
+ let(:can_update_branch) { true }
- context 'when user can update the downstream branch' do
- let(:can_update_branch) { true }
+ it 'allows' do
+ expect(policy).to be_allowed :play_job
+ end
+ end
+
+ context 'when user can not update the downstream branch' do
+ let(:can_update_branch) { false }
- it 'allows' do
- expect(policy).to be_allowed :play_job
+ it 'does not allow' do
+ expect(policy).not_to be_allowed :play_job
+ end
end
end
- context 'when user can not update the downstream branch' do
- let(:can_update_branch) { false }
+ context 'when downstream project does not exist' do
+ before do
+ bridge.update!(options: { trigger: { project: 'deleted-project' } })
+ end
it 'does not allow' do
expect(policy).not_to be_allowed :play_job