diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-02-10 18:02:46 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-02-19 13:14:53 -0500 |
commit | b8295fc3232a3d9ca2af524225f9a66ab7735926 (patch) | |
tree | 8f8d9109dff563618bdaa585c17305ddff8d8133 /spec/controllers | |
parent | ccd2a8d6b577e9a5a0ea3a350e6bc039550bc1ae (diff) | |
download | gitlab-ce-b8295fc3232a3d9ca2af524225f9a66ab7735926.tar.gz |
Fix build and add specs
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/commit_controller_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index 7793bf1e421..bbe400dad88 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -143,4 +143,53 @@ describe Projects::CommitController do expect(assigns(:tags)).to include("v1.1.0") end end + + describe '#revert' do + context 'when target branch is not provided' do + it 'should render the 404 page' do + post(:revert, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: commit.id) + + expect(response).not_to be_success + expect(response.status).to eq(404) + end + end + + context 'when the revert was successful' do + it 'should redirect to the commits page' do + post(:revert, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + target_branch: 'master', + id: commit.id) + + expect(response).to redirect_to namespace_project_commits_path(project.namespace, project, 'master') + expect(flash[:notice]).to eq('The commit has been successfully reverted.') + end + end + + context 'when the revert failed' do + before do + post(:revert, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + target_branch: 'master', + id: commit.id) + end + + it 'should redirect to the commit page' do + # Reverting a commit that has been already reverted. + post(:revert, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + target_branch: 'master', + id: commit.id) + + expect(response).to redirect_to namespace_project_commit_path(project.namespace, project, commit.id) + expect(flash[:alert]).to match('Sorry, we cannot revert this commit automatically.') + end + end + end end |