diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-18 11:02:45 +0000 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-01-19 10:48:40 +0100 |
commit | 49ac01465c2397badcc9f73cba81c4b477364cff (patch) | |
tree | b23e036e89d2be303c70102045d68aa431e12e5f /spec | |
parent | 9f0f38e9fe8d769ed2c502ce0b4769c9824b6f43 (diff) | |
download | gitlab-ce-49ac01465c2397badcc9f73cba81c4b477364cff.tar.gz |
Merge branch 'i-#25814-500-error' into 'master'
Fix Compare page throws 500 error when any branch/reference is not selected
Closes #25814
See merge request !8523
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/compare_controller_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb index 7a57801c437..b03c4b52de6 100644 --- a/spec/controllers/projects/compare_controller_spec.rb +++ b/spec/controllers/projects/compare_controller_spec.rb @@ -64,6 +64,36 @@ describe Projects::CompareController do expect(assigns(:diffs)).to eq(nil) expect(assigns(:commits)).to eq(nil) end + + it 'redirects back to index when params[:from] is empty and preserves params[:to]' do + post(:create, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + from: '', + to: 'master') + + expect(response).to redirect_to(namespace_project_compare_index_path(project.namespace, project, to: 'master')) + end + + it 'redirects back to index when params[:to] is empty and preserves params[:from]' do + post(:create, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + from: 'master', + to: '') + + expect(response).to redirect_to(namespace_project_compare_index_path(project.namespace, project, from: 'master')) + end + + it 'redirects back to index when params[:from] and params[:to] are empty' do + post(:create, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + from: '', + to: '') + + expect(response).to redirect_to(namespace_project_compare_index_path) + end end describe 'GET diff_for_path' do |