Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-10-13 20:45:27 +0300
committerJan Provaznik <jprovaznik@gitlab.com>2018-10-13 20:45:27 +0300
commitc6a4c9231e983f2bd5f0c2115a5c9c16fd18bfb2 (patch)
treead6b6a362c8f4342244e0123a3219e3c44785ebc /spec
parent4127b357881fedbf903159e089cc0c9d99c37eff (diff)
Use InvalidUTF8ErrorHandler only for rails 4
In Rails 5 catches invalid UTF8 characters in querystring in a params middleware, errors are handled by a params middleware and raises a BadRequest exception. This means that these UTF8 errors are not raised deeper in application stack and these can't also be handled on application level. If we would want to have custom handler for these errors, we would have to create a new middleware and insert it before actionpack's params middleware and rescue BadRequest exceptions there. But there is no need to do this currently (see discussion on https://gitlab.com/gitlab-org/gitlab-ce/issues/51908)
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/application_controller_spec.rb26
1 files changed, 19 insertions, 7 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index a8556771edd..be3fc832008 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -685,22 +685,34 @@ describe ApplicationController do
end
context 'html' do
+ subject { get :index, text: "hi \255" }
+
it 'renders 412' do
- get :index, text: "hi \255"
+ if Gitlab.rails5?
+ expect { subject }.to raise_error(ActionController::BadRequest)
+ else
+ subject
- expect(response).to have_gitlab_http_status(412)
- expect(response).to render_template :precondition_failed
+ expect(response).to have_gitlab_http_status(412)
+ expect(response).to render_template :precondition_failed
+ end
end
end
context 'js' do
+ subject { get :index, text: "hi \255", format: :js }
+
it 'renders 412' do
- get :index, text: "hi \255", format: :js
+ if Gitlab.rails5?
+ expect { subject }.to raise_error(ActionController::BadRequest)
+ else
+ subject
- json_response = JSON.parse(response.body)
+ json_response = JSON.parse(response.body)
- expect(response).to have_gitlab_http_status(412)
- expect(json_response['error']).to eq('Invalid UTF-8')
+ expect(response).to have_gitlab_http_status(412)
+ expect(json_response['error']).to eq('Invalid UTF-8')
+ end
end
end
end