diff options
author | Valery Sizov <valery@gitlab.com> | 2017-02-06 18:59:54 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-02-23 15:31:03 +0200 |
commit | 08e4d98cacb12f3d9b80b81ed1f50b9474c8b276 (patch) | |
tree | 69376ef4e4553a378c65ff33bb3776ff5d4bebd3 /spec/controllers/projects/branches_controller_spec.rb | |
parent | 319dfd68a82fe0b6893513a8f99962c3ea13965b (diff) | |
download | gitlab-ce-08e4d98cacb12f3d9b80b81ed1f50b9474c8b276.tar.gz |
Create master branch first if project is repository-less
Diffstat (limited to 'spec/controllers/projects/branches_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/branches_controller_spec.rb | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 9de03876755..3ab3a0eb3e8 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -68,7 +68,7 @@ describe Projects::BranchesController do describe "created from the new branch button on issues" do let(:branch) { "1-feature-branch" } - let!(:issue) { create(:issue, project: project) } + let(:issue) { create(:issue, project: project) } before do sign_in(user) @@ -95,6 +95,49 @@ describe Projects::BranchesController do issue_iid: issue.iid end + context 'repository-less project' do + let(:project) { create :empty_project } + + it 'redirects to newly created branch' do + result = { status: :success, branch: double(name: branch) } + + expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result) + expect(SystemNoteService).to receive(:new_issue_branch).and_return(true) + + post :create, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + branch_name: branch, + issue_iid: issue.iid + + expect(response).to redirect_to namespace_project_tree_path(project.namespace, project, branch) + end + + it 'redirects to autodeploy setup page' do + result = { status: :success, branch: double(name: branch) } + + project.create_kubernetes_service( + active: true, + properties: { + namespace: project.path, + api_url: 'https://kubernetes.example.com', + token: 'a' * 40, + } + ) + + expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result) + expect(SystemNoteService).to receive(:new_issue_branch).and_return(true) + + post :create, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + branch_name: branch, + issue_iid: issue.iid + + expect(response.location).to include(namespace_project_new_blob_path(project.namespace, project, branch)) + end + end + context 'without issue feature access' do before do project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) |