diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-10-16 11:35:08 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-10-16 11:35:08 +0300 |
commit | 59af98f133ee229479c6159b15391deb4782a294 (patch) | |
tree | 8a1034a4d2239a8939c90f0d5d7b1edd9f3f0af7 /spec | |
parent | 6ea674d1796488f784083eab53becb86330343cb (diff) | |
parent | c6a4c9231e983f2bd5f0c2115a5c9c16fd18bfb2 (diff) |
Merge branch 'rails5-fix-utf' into 'master'
Use InvalidUTF8ErrorHandler only for rails 4
Closes #51908
See merge request gitlab-org/gitlab-ce!22340
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 26 |
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 |