diff options
Diffstat (limited to 'spec/controllers/projects/commit_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/commit_controller_spec.rb | 127 |
1 files changed, 26 insertions, 101 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index 8d3939d8133..1a925f2ea4d 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -155,12 +155,7 @@ RSpec.describe Projects::CommitController do let(:commit) { fork_project.commit('remove-submodule') } it 'renders it' do - get(:show, - params: { - namespace_id: fork_project.namespace, - project_id: fork_project, - id: commit.id - }) + get :show, params: { namespace_id: fork_project.namespace, project_id: fork_project, id: commit.id } expect(response).to be_successful end @@ -174,10 +169,10 @@ RSpec.describe Projects::CommitController do go(id: commit.id, merge_request_iid: merge_request.iid) expect(assigns(:new_diff_note_attrs)).to eq({ - noteable_type: 'MergeRequest', - noteable_id: merge_request.id, - commit_id: commit.id - }) + noteable_type: 'MergeRequest', + noteable_id: merge_request.id, + commit_id: commit.id + }) expect(response).to be_ok end end @@ -187,12 +182,7 @@ RSpec.describe Projects::CommitController do it 'contains branch and tags information' do commit = project.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e') - get(:branches, - params: { - namespace_id: project.namespace, - project_id: project, - id: commit.id - }) + get :branches, params: { namespace_id: project.namespace, project_id: project, id: commit.id } expect(assigns(:branches)).to include('master', 'feature_conflict') expect(assigns(:branches_limit_exceeded)).to be_falsey @@ -205,12 +195,7 @@ RSpec.describe Projects::CommitController do allow_any_instance_of(Repository).to receive(:branch_count).and_return(1001) allow_any_instance_of(Repository).to receive(:tag_count).and_return(1001) - get(:branches, - params: { - namespace_id: project.namespace, - project_id: project, - id: commit.id - }) + get :branches, params: { namespace_id: project.namespace, project_id: project, id: commit.id } expect(assigns(:branches)).to eq([]) expect(assigns(:branches_limit_exceeded)).to be_truthy @@ -234,12 +219,7 @@ RSpec.describe Projects::CommitController do describe 'POST revert' do context 'when target branch is not provided' do it 'renders the 404 page' do - post(:revert, - params: { - namespace_id: project.namespace, - project_id: project, - id: commit.id - }) + post :revert, params: { namespace_id: project.namespace, project_id: project, id: commit.id } expect(response).not_to be_successful expect(response).to have_gitlab_http_status(:not_found) @@ -248,13 +228,7 @@ RSpec.describe Projects::CommitController do context 'when the revert commit is missing' do it 'renders the 404 page' do - post(:revert, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: '1234567890' - }) + post :revert, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: '1234567890' } expect(response).not_to be_successful expect(response).to have_gitlab_http_status(:not_found) @@ -263,13 +237,7 @@ RSpec.describe Projects::CommitController do context 'when the revert was successful' do it 'redirects to the commits page' do - post(:revert, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: commit.id - }) + post :revert, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: commit.id } expect(response).to redirect_to project_commits_path(project, 'master') expect(flash[:notice]).to eq('The commit has been successfully reverted.') @@ -278,24 +246,12 @@ RSpec.describe Projects::CommitController do context 'when the revert failed' do before do - post(:revert, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: commit.id - }) + post :revert, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: commit.id } end it 'redirects to the commit page' do # Reverting a commit that has been already reverted. - post(:revert, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: commit.id - }) + post :revert, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: commit.id } expect(response).to redirect_to project_commit_path(project, commit.id) expect(flash[:alert]).to match('Sorry, we cannot revert this commit automatically.') @@ -306,12 +262,7 @@ RSpec.describe Projects::CommitController do describe 'POST cherry_pick' do context 'when target branch is not provided' do it 'renders the 404 page' do - post(:cherry_pick, - params: { - namespace_id: project.namespace, - project_id: project, - id: master_pickable_commit.id - }) + post :cherry_pick, params: { namespace_id: project.namespace, project_id: project, id: master_pickable_commit.id } expect(response).not_to be_successful expect(response).to have_gitlab_http_status(:not_found) @@ -320,13 +271,7 @@ RSpec.describe Projects::CommitController do context 'when the cherry-pick commit is missing' do it 'renders the 404 page' do - post(:cherry_pick, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: '1234567890' - }) + post :cherry_pick, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: '1234567890' } expect(response).not_to be_successful expect(response).to have_gitlab_http_status(:not_found) @@ -335,13 +280,7 @@ RSpec.describe Projects::CommitController do context 'when the cherry-pick was successful' do it 'redirects to the commits page' do - post(:cherry_pick, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: master_pickable_commit.id - }) + post :cherry_pick, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: master_pickable_commit.id } expect(response).to redirect_to project_commits_path(project, 'master') expect(flash[:notice]).to eq('The commit has been successfully cherry-picked into master.') @@ -350,24 +289,12 @@ RSpec.describe Projects::CommitController do context 'when the cherry_pick failed' do before do - post(:cherry_pick, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: master_pickable_commit.id - }) + post :cherry_pick, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: master_pickable_commit.id } end it 'redirects to the commit page' do # Cherry-picking a commit that has been already cherry-picked. - post(:cherry_pick, - params: { - namespace_id: project.namespace, - project_id: project, - start_branch: 'master', - id: master_pickable_commit.id - }) + post :cherry_pick, params: { namespace_id: project.namespace, project_id: project, start_branch: 'master', id: master_pickable_commit.id } expect(response).to redirect_to project_commit_path(project, master_pickable_commit.id) expect(flash[:alert]).to match('Sorry, we cannot cherry-pick this commit automatically.') @@ -381,15 +308,14 @@ RSpec.describe Projects::CommitController do let(:create_merge_request) { nil } def send_request - post(:cherry_pick, - params: { - namespace_id: forked_project.namespace, - project_id: forked_project, - target_project_id: target_project.id, - start_branch: 'feature', - id: forked_project.commit.id, - create_merge_request: create_merge_request - }) + post :cherry_pick, params: { + namespace_id: forked_project.namespace, + project_id: forked_project, + target_project_id: target_project.id, + start_branch: 'feature', + id: forked_project.commit.id, + create_merge_request: create_merge_request + } end def merge_request_url(source_project, branch) @@ -478,8 +404,7 @@ RSpec.describe Projects::CommitController do diff_for_path(id: commit2.id, old_path: existing_path, new_path: existing_path) expect(assigns(:diff_notes_disabled)).to be_falsey - expect(assigns(:new_diff_note_attrs)).to eq(noteable_type: 'Commit', - commit_id: commit2.id) + expect(assigns(:new_diff_note_attrs)).to eq(noteable_type: 'Commit', commit_id: commit2.id) end it 'only renders the diffs for the path given' do |