diff options
author | Rémy Coutable <remy@rymai.me> | 2019-07-01 10:54:11 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-07-01 10:54:11 +0000 |
commit | 96080fce7d65e870b309f409e76c794f18d3ee74 (patch) | |
tree | 09e01394f46ae6592b4de3602b735d4be73b5836 /spec/controllers/projects/branches_controller_spec.rb | |
parent | 0e8b76e1918a7ca441e9eb98819f10da24e0588a (diff) | |
parent | 6b68acbfe9db1d3c855d7505817ebca62e3a61c1 (diff) | |
download | gitlab-ce-96080fce7d65e870b309f409e76c794f18d3ee74.tar.gz |
Merge branch '58583-confidential-mr-branch-backend' into 'master'
Support creating an MR/branch on a fork from an issue
See merge request gitlab-org/gitlab-ce!29831
Diffstat (limited to 'spec/controllers/projects/branches_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/branches_controller_spec.rb | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 287ea9f425d..b30966e70a7 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -92,7 +92,7 @@ describe Projects::BranchesController do end it 'posts a system note' do - expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, "1-feature-branch") + expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, "1-feature-branch", branch_project: project) post :create, params: { @@ -103,6 +103,75 @@ describe Projects::BranchesController do } end + context 'confidential_issue_project_id is present' do + let(:confidential_issue_project) { create(:project) } + + def create_branch_with_confidential_issue_project + post( + :create, + params: { + namespace_id: project.namespace, + project_id: project, + branch_name: branch, + confidential_issue_project_id: confidential_issue_project.id, + issue_iid: issue.iid + } + ) + end + + context 'create_confidential_merge_request feature is enabled' do + before do + stub_feature_flags(create_confidential_merge_request: true) + end + + context 'user cannot update issue' do + let(:issue) { create(:issue, project: confidential_issue_project) } + + it 'does not post a system note' do + expect(SystemNoteService).not_to receive(:new_issue_branch) + + create_branch_with_confidential_issue_project + end + end + + context 'user can update issue' do + before do + confidential_issue_project.add_reporter(user) + end + + context 'issue is under the specified project' do + let(:issue) { create(:issue, project: confidential_issue_project) } + + it 'posts a system note' do + expect(SystemNoteService).to receive(:new_issue_branch).with(issue, confidential_issue_project, user, "1-feature-branch", branch_project: project) + + create_branch_with_confidential_issue_project + end + end + + context 'issue is not under the specified project' do + it 'does not post a system note' do + expect(SystemNoteService).not_to receive(:new_issue_branch) + + create_branch_with_confidential_issue_project + end + end + end + end + + context 'create_confidential_merge_request feature is disabled' do + before do + stub_feature_flags(create_confidential_merge_request: false) + end + + it 'posts a system note on project' do + expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, "1-feature-branch", branch_project: project) + + create_branch_with_confidential_issue_project + end + end + end + context 'repository-less project' do let(:project) { create :project } |