diff options
Diffstat (limited to 'spec/controllers/projects/branches_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/branches_controller_spec.rb | 175 |
1 files changed, 106 insertions, 69 deletions
diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 31471cde420..02b3d5269a6 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -22,10 +22,12 @@ describe Projects::BranchesController do sign_in(user) post :create, - namespace_id: project.namespace, - project_id: project, - branch_name: branch, - ref: ref + params: { + namespace_id: project.namespace, + project_id: project, + branch_name: branch, + ref: ref + } end context "valid branch name, valid source" do @@ -76,10 +78,12 @@ describe Projects::BranchesController do it 'redirects' do post :create, - namespace_id: project.namespace, - project_id: project, - branch_name: branch, - issue_iid: issue.iid + params: { + namespace_id: project.namespace, + project_id: project, + branch_name: branch, + issue_iid: issue.iid + } expect(subject) .to redirect_to("/#{project.full_path}/tree/1-feature-branch") @@ -89,10 +93,12 @@ describe Projects::BranchesController do expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, "1-feature-branch") post :create, - namespace_id: project.namespace, - project_id: project, - branch_name: branch, - issue_iid: issue.iid + params: { + namespace_id: project.namespace, + project_id: project, + branch_name: branch, + issue_iid: issue.iid + } end context 'repository-less project' do @@ -105,10 +111,12 @@ describe Projects::BranchesController do 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 + params: { + namespace_id: project.namespace.to_param, + project_id: project.to_param, + branch_name: branch, + issue_iid: issue.iid + } expect(response).to redirect_to project_tree_path(project, branch) end @@ -121,10 +129,12 @@ describe Projects::BranchesController do 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 + params: { + namespace_id: project.namespace.to_param, + project_id: project.to_param, + branch_name: branch, + issue_iid: issue.iid + } expect(response.location).to include(project_new_blob_path(project, branch)) expect(response).to have_gitlab_http_status(302) @@ -156,10 +166,12 @@ describe Projects::BranchesController do 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 + params: { + namespace_id: project.namespace.to_param, + project_id: project.to_param, + branch_name: branch, + issue_iid: issue.iid + } expect(response.location).to include(project_new_blob_path(project, branch)) expect(response).to have_gitlab_http_status(302) @@ -173,10 +185,12 @@ describe Projects::BranchesController do expect(SystemNoteService).not_to receive(:new_issue_branch) post :create, - namespace_id: project.namespace, - project_id: project, - branch_name: branch, - issue_iid: issue.iid + params: { + namespace_id: project.namespace, + project_id: project, + branch_name: branch, + issue_iid: issue.iid + } end end @@ -191,10 +205,12 @@ describe Projects::BranchesController do expect(SystemNoteService).not_to receive(:new_issue_branch) post :create, - namespace_id: project.namespace, - project_id: project, - branch_name: branch, - issue_iid: issue.iid + params: { + namespace_id: project.namespace, + project_id: project, + branch_name: branch, + issue_iid: issue.iid + } end end end @@ -228,11 +244,14 @@ describe Projects::BranchesController do end def create_branch(name:, ref:) - post :create, namespace_id: project.namespace.to_param, - project_id: project.to_param, - branch_name: name, - ref: ref, - format: :json + post :create, + format: :json, + params: { + namespace_id: project.namespace.to_param, + project_id: project.to_param, + branch_name: name, + ref: ref + } end end @@ -246,9 +265,11 @@ describe Projects::BranchesController do it 'returns 303' do post :destroy, format: :html, - id: 'foo/bar/baz', - namespace_id: project.namespace, - project_id: project + params: { + id: 'foo/bar/baz', + namespace_id: project.namespace, + project_id: project + } expect(response).to have_gitlab_http_status(303) end @@ -261,10 +282,12 @@ describe Projects::BranchesController do sign_in(user) post :destroy, - format: format, - id: branch, - namespace_id: project.namespace, - project_id: project + format: format, + params: { + id: branch, + namespace_id: project.namespace, + project_id: project + } end context 'as JS' do @@ -359,8 +382,10 @@ describe Projects::BranchesController do describe "DELETE destroy_all_merged" do def destroy_all_merged delete :destroy_all_merged, - namespace_id: project.namespace, - project_id: project + params: { + namespace_id: project.namespace, + project_id: project + } end context 'when user is allowed to push' do @@ -404,10 +429,12 @@ describe Projects::BranchesController do context 'when rendering a JSON format' do it 'filters branches by name' do get :index, - namespace_id: project.namespace, - project_id: project, format: :json, - search: 'master' + params: { + namespace_id: project.namespace, + project_id: project, + search: 'master' + } parsed_response = JSON.parse(response.body) @@ -423,10 +450,12 @@ describe Projects::BranchesController do context 'when cache is enabled yet cold', :request_store do it 'return with a status 200' do get :index, - namespace_id: project.namespace, - project_id: project, - state: 'all', - format: :html + format: :html, + params: { + namespace_id: project.namespace, + project_id: project, + state: 'all' + } expect(response).to have_gitlab_http_status(200) end @@ -439,10 +468,12 @@ describe Projects::BranchesController do it 'return with a status 200' do get :index, - namespace_id: project.namespace, - project_id: project, - state: 'all', - format: :html + format: :html, + params: { + namespace_id: project.namespace, + project_id: project, + state: 'all' + } expect(response).to have_gitlab_http_status(200) end @@ -451,30 +482,36 @@ describe Projects::BranchesController do context 'when deprecated sort/search/page parameters are specified' do it 'returns with a status 301 when sort specified' do get :index, - namespace_id: project.namespace, - project_id: project, - sort: 'updated_asc', - format: :html + format: :html, + params: { + namespace_id: project.namespace, + project_id: project, + sort: 'updated_asc' + } expect(response).to redirect_to project_branches_filtered_path(project, state: 'all') end it 'returns with a status 301 when search specified' do get :index, - namespace_id: project.namespace, - project_id: project, - search: 'feature', - format: :html + format: :html, + params: { + namespace_id: project.namespace, + project_id: project, + search: 'feature' + } expect(response).to redirect_to project_branches_filtered_path(project, state: 'all') end it 'returns with a status 301 when page specified' do get :index, - namespace_id: project.namespace, - project_id: project, - page: 2, - format: :html + format: :html, + params: { + namespace_id: project.namespace, + project_id: project, + page: 2 + } expect(response).to redirect_to project_branches_filtered_path(project, state: 'all') end |