diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-18 14:02:45 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-18 14:02:45 +0300 |
commit | cdf0af666c04290ece320e39a890af75f2e7d7e4 (patch) | |
tree | 5f065073cd715e4c2098f9bd30453325978fe562 /spec | |
parent | f5ff5dc270c1f28cd4a5fee675cc9c576017f577 (diff) | |
parent | 856003cfea894b56784f0fea4ee64655e6c16f06 (diff) |
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 |