From 87c39b6d393d211c038bff084a3f8d21f0391d71 Mon Sep 17 00:00:00 2001 From: Martin Cabrera Date: Sun, 15 Jan 2017 02:28:01 +0100 Subject: [PATCH] Added specs for the preservation of the from/to parameter --- .../projects/compare_controller_spec.rb | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb index c4905937878..b03c4b52de6 100644 --- a/spec/controllers/projects/compare_controller_spec.rb +++ b/spec/controllers/projects/compare_controller_spec.rb @@ -65,7 +65,27 @@ describe Projects::CompareController do expect(assigns(:commits)).to eq(nil) end - it 'redirects back to index when params[:from] & params[:to] are empty' do + 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,