summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorMarkus Koller <mkoller@gitlab.com>2019-06-20 19:13:02 +0200
committerMarkus Koller <mkoller@gitlab.com>2019-06-25 13:19:29 +0200
commit8fd2c08472afc3846ba28f97994a57143bc76eaf (patch)
treea79905ff65bce863a0b156d450d967a6dae82a72 /spec/controllers
parente8aff8351e7de96c51cdc5c2f1af41fc85c7b57f (diff)
downloadgitlab-ce-8fd2c08472afc3846ba28f97994a57143bc76eaf.tar.gz
Make checks for continue_params more robust
The check for continue_params&.key?(:to) in Projects::ImportsController caused an exception in redirect_to if this key contained a nil value. Since url_for won't add any params for an empty hash, we can just return that in continue_params if params[:continue] isn't present, and simplify the code in the controllers to check for the values we actually want to use.
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/concerns/continue_params_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/controllers/concerns/continue_params_spec.rb b/spec/controllers/concerns/continue_params_spec.rb
index 5e47f5e9f28..b4b62cbe1e3 100644
--- a/spec/controllers/concerns/continue_params_spec.rb
+++ b/spec/controllers/concerns/continue_params_spec.rb
@@ -18,6 +18,14 @@ describe ContinueParams do
ActionController::Parameters.new(continue: params)
end
+ it 'returns an empty hash if params are not present' do
+ allow(controller).to receive(:params) do
+ ActionController::Parameters.new
+ end
+
+ expect(controller.continue_params).to eq({})
+ end
+
it 'cleans up any params that are not allowed' do
allow(controller).to receive(:params) do
strong_continue_params(to: '/hello',