From b6c22274bc8a5676712bdd6537e7895b25122229 Mon Sep 17 00:00:00 2001 From: Sanghyun Park Date: Mon, 16 Apr 2018 22:17:29 +1000 Subject: [PATCH] Use Rails 5 HTTP action methods in controller and request specs. --- .../application_metal_controller_spec.rb | 17 ++++---- .../applications_controller_spec.rb | 42 ++++++++++++------- .../authorizations_controller_spec.rb | 24 +++++------ .../protected_resources_controller_spec.rb | 28 ++++++------- .../controllers/token_info_controller_spec.rb | 4 +- spec/controllers/tokens_controller_spec.rb | 18 ++++---- spec/requests/endpoints/token_spec.rb | 10 +++-- .../requests/flows/client_credentials_spec.rb | 10 ++--- spec/requests/flows/implicit_grant_spec.rb | 24 ++++++----- spec/requests/flows/revoke_token_spec.rb | 20 ++++----- spec/support/http_method_shim.rb | 30 ++++++------- 11 files changed, 121 insertions(+), 106 deletions(-) diff --git a/spec/controllers/application_metal_controller_spec.rb b/spec/controllers/application_metal_controller_spec.rb index 90e143454..f4c28869a 100644 --- a/spec/controllers/application_metal_controller_spec.rb +++ b/spec/controllers/application_metal_controller_spec.rb @@ -23,14 +23,15 @@ def index let(:flag) { true } it '200 for the correct media type' do - @request.headers['Content-Type'] = 'application/x-www-form-urlencoded' - get :index, {}, as: :url_encoded_form + # @request.headers['Content-Type'] = 'application/x-www-form-urlencoded' + # get :index, {}, as: :url_encoded_form + get :index, params: {}, as: :url_encoded_form expect(response).to have_http_status 200 end it 'returns a 415 for an incorrect media type' do - @request.headers['Content-Type'] = 'application/json' - get :index, {}, as: :json + # @request.headers['Content-Type'] = 'application/json' + get :index, as: :json expect(response).to have_http_status 415 end end @@ -39,14 +40,14 @@ def index let(:flag) { false } it 'returns a 200 for the correct media type' do - @request.headers['Content-Type'] = 'application/x-www-form-urlencoded' - get :index, {}, as: :url_encoded_form + # @request.headers['Content-Type'] = 'application/x-www-form-urlencoded' + get :index, as: :url_encoded_form expect(response).to have_http_status 200 end it 'returns a 200 for an incorrect media type' do - @request.headers['Content-Type'] = 'application/json' - get :index, {}, as: :json + # @request.headers['Content-Type'] = 'application/json' + get :index, as: :json expect(response).to have_http_status 200 end end diff --git a/spec/controllers/applications_controller_spec.rb b/spec/controllers/applications_controller_spec.rb index 63fc856e2..9c8960189 100644 --- a/spec/controllers/applications_controller_spec.rb +++ b/spec/controllers/applications_controller_spec.rb @@ -16,9 +16,12 @@ module Doorkeeper it 'does not create application' do expect do - post :create, doorkeeper_application: { - name: 'Example', - redirect_uri: 'https://example.com' } + post :create, + params: { + doorkeeper_application: { + name: 'Example', + redirect_uri: 'https://example.com' } + } end.not_to change { Doorkeeper::Application.count } end end @@ -43,9 +46,13 @@ module Doorkeeper it 'creates application' do expect do - post :create, doorkeeper_application: { - name: 'Example', - redirect_uri: 'https://example.com' } + post :create, + params: { + doorkeeper_application: { + name: 'Example', + redirect_uri: 'https://example.com' + } + } end.to change { Doorkeeper::Application.count }.by(1) expect(response).to be_redirect @@ -53,20 +60,27 @@ module Doorkeeper it 'does not allow mass assignment of uid or secret' do application = FactoryBot.create(:application) - put :update, id: application.id, doorkeeper_application: { - uid: '1A2B3C4D', - secret: '1A2B3C4D' - } + put :update, + params: { + id: application.id, + doorkeeper_application: { + uid: '1A2B3C4D', + secret: '1A2B3C4D' + } + } expect(application.reload.uid).not_to eq '1A2B3C4D' end it 'updates application' do application = FactoryBot.create(:application) - put :update, id: application.id, doorkeeper_application: { - name: 'Example', - redirect_uri: 'https://example.com' - } + put :update, + params: { + id: application.id, doorkeeper_application: { + name: 'Example', + redirect_uri: 'https://example.com' + } + } expect(application.reload.name).to eq 'Example' end diff --git a/spec/controllers/authorizations_controller_spec.rb b/spec/controllers/authorizations_controller_spec.rb index 894eff858..b0077bfbf 100644 --- a/spec/controllers/authorizations_controller_spec.rb +++ b/spec/controllers/authorizations_controller_spec.rb @@ -41,7 +41,7 @@ def translated_error_message(key) describe 'POST #create' do before do - post :create, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri + post :create, params: { client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri } end it 'redirects after authorization' do @@ -76,7 +76,7 @@ def translated_error_message(key) describe "POST #create in API mode" do before do allow(Doorkeeper.configuration).to receive(:api_only).and_return(true) - post :create, client_id: client.uid, response_type: "token", redirect_uri: client.redirect_uri + post :create, params: { client_id: client.uid, response_type: "token", redirect_uri: client.redirect_uri } end let(:response_json_body) { JSON.parse(response.body) } @@ -114,7 +114,7 @@ def translated_error_message(key) describe 'POST #create with errors' do before do default_scopes_exist :public - post :create, client_id: client.uid, response_type: 'token', scope: 'invalid', redirect_uri: client.redirect_uri + post :create, params: { client_id: client.uid, response_type: 'token', scope: 'invalid', redirect_uri: client.redirect_uri } end it 'redirects after authorization' do @@ -146,7 +146,7 @@ def translated_error_message(key) before do allow(Doorkeeper.configuration).to receive(:api_only).and_return(true) default_scopes_exist :public - post :create, client_id: client.uid, response_type: 'token', scope: 'invalid', redirect_uri: client.redirect_uri + post :create, params: { client_id: client.uid, response_type: 'token', scope: 'invalid', redirect_uri: client.redirect_uri } end let(:response_json_body) { JSON.parse(response.body) } @@ -182,7 +182,7 @@ def translated_error_message(key) allow(Doorkeeper.configuration).to receive(:reuse_access_token).and_return(true) access_token.save! - post :create, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri + post :create, params: { client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri } end it 'returns the existing access token in a fragment' do @@ -200,7 +200,7 @@ def translated_error_message(key) true end) client.update_attribute :redirect_uri, 'urn:ietf:wg:oauth:2.0:oob' - get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri + get :new, params: { client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri } end it 'should redirect immediately' do @@ -224,7 +224,7 @@ def translated_error_message(key) true end) client.update_attribute :redirect_uri, 'urn:ietf:wg:oauth:2.0:oob' - get :new, client_id: client.uid, response_type: 'code', redirect_uri: client.redirect_uri + get :new, params: { client_id: client.uid, response_type: 'code', redirect_uri: client.redirect_uri } end it 'should redirect immediately' do @@ -246,7 +246,7 @@ def translated_error_message(key) allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc do true end) - get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri + get :new, params: { client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri } end it 'should redirect immediately' do @@ -278,7 +278,7 @@ def translated_error_message(key) describe 'GET #new in API mode' do before do allow(Doorkeeper.configuration).to receive(:api_only).and_return(true) - get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri + get :new, params: { client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri } end it 'should render success' do @@ -303,7 +303,7 @@ def translated_error_message(key) allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc { true }) allow(Doorkeeper.configuration).to receive(:api_only).and_return(true) - get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri + get :new, params: { client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri } end it 'should render success' do @@ -340,7 +340,7 @@ def translated_error_message(key) describe 'GET #new with errors' do before do default_scopes_exist :public - get :new, an_invalid: 'request' + get :new, params: { an_invalid: 'request' } end it 'does not redirect' do @@ -357,7 +357,7 @@ def translated_error_message(key) after do allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc { true }) client.update_attribute :redirect_uri, 'urn:ietf:wg:oauth:2.0:oob' - get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri + get :new, params: { client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri } end it 'should call :before_successful_authorization callback' do diff --git a/spec/controllers/protected_resources_controller_spec.rb b/spec/controllers/protected_resources_controller_spec.rb index a4c25e920..917f1ba13 100644 --- a/spec/controllers/protected_resources_controller_spec.rb +++ b/spec/controllers/protected_resources_controller_spec.rb @@ -33,12 +33,12 @@ def index it 'access_token param' do expect(Doorkeeper::AccessToken).to receive(:by_token).with(token_string).and_return(token) - get :index, access_token: token_string + get :index, params: { access_token: token_string } end it 'bearer_token param' do expect(Doorkeeper::AccessToken).to receive(:by_token).with(token_string).and_return(token) - get :index, bearer_token: token_string + get :index, params: { bearer_token: token_string } end it 'Authorization header' do @@ -71,25 +71,25 @@ def index context 'with valid token', token: :valid do it 'allows into index action' do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response).to be_successful end it 'allows into show action' do - get :show, id: '4', access_token: token_string + get :show, params: { id: '4', access_token: token_string } expect(response).to be_successful end end context 'with invalid token', token: :invalid do it 'does not allow into index action' do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.status).to eq 401 expect(response.header['WWW-Authenticate']).to match(/^Bearer/) end it 'does not allow into show action' do - get :show, id: '4', access_token: token_string + get :show, params: { id: '4', access_token: token_string } expect(response.status).to eq 401 expect(response.header['WWW-Authenticate']).to match(/^Bearer/) end @@ -115,7 +115,7 @@ def index Doorkeeper::AccessToken ).to receive(:by_token).with(token_string).and_return(token) - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response).to be_successful end @@ -129,7 +129,7 @@ def index ).to receive(:by_token).with(token_string).and_return(token) expect(token).to receive(:acceptable?).with([:write]).and_return(false) - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.status).to eq 403 expect(response.header).to_not include('WWW-Authenticate') end @@ -163,7 +163,7 @@ def doorkeeper_unauthorized_render_options(error: nil) end it 'it renders a custom JSON response', token: :invalid do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.status).to eq 401 expect(response.content_type).to eq('application/json') expect(response.header['WWW-Authenticate']).to match(/^Bearer/) @@ -193,7 +193,7 @@ def doorkeeper_unauthorized_render_options(error: nil); end end it 'it renders a custom text response', token: :invalid do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.status).to eq 401 expect(response.content_type).to eq('text/plain') expect(response.header['WWW-Authenticate']).to match(/^Bearer/) @@ -243,7 +243,7 @@ def doorkeeper_forbidden_render_options(*) end it 'renders a custom JSON response' do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.header).to_not include('WWW-Authenticate') expect(response.content_type).to eq('application/json') expect(response.status).to eq 403 @@ -265,7 +265,7 @@ def doorkeeper_forbidden_render_options(*) end it 'overrides the default status code' do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.status).to eq 404 end end @@ -282,7 +282,7 @@ def doorkeeper_forbidden_render_options(*) end it 'renders a custom status code and text response' do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.header).to_not include('WWW-Authenticate') expect(response.status).to eq 403 expect(response.body).to eq('Forbidden') @@ -301,7 +301,7 @@ def doorkeeper_forbidden_render_options(*) end it 'overrides the default status code' do - get :index, access_token: token_string + get :index, params: { access_token: token_string } expect(response.status).to eq 404 end end diff --git a/spec/controllers/token_info_controller_spec.rb b/spec/controllers/token_info_controller_spec.rb index a58a06c59..9c8444e77 100644 --- a/spec/controllers/token_info_controller_spec.rb +++ b/spec/controllers/token_info_controller_spec.rb @@ -6,13 +6,13 @@ describe 'successful request' do it 'responds with token info' do - get :show, access_token: doorkeeper_token.token + get :show, params: { access_token: doorkeeper_token.token } expect(response.body).to eq(doorkeeper_token.to_json) end it 'responds with a 200 status' do - get :show, access_token: doorkeeper_token.token + get :show, params: { access_token: doorkeeper_token.token } expect(response.status).to eq 200 end diff --git a/spec/controllers/tokens_controller_spec.rb b/spec/controllers/tokens_controller_spec.rb index 2e5346bb6..433a1765b 100644 --- a/spec/controllers/tokens_controller_spec.rb +++ b/spec/controllers/tokens_controller_spec.rb @@ -89,7 +89,7 @@ it 'responds with full token introspection' do request.headers['Authorization'] = "Bearer #{access_token.token}" - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } should_have_json 'active', true expect(json_response).to include('client_id', 'token_type', 'exp', 'iat') @@ -103,7 +103,7 @@ it 'responds with full token introspection' do request.headers['Authorization'] = basic_auth_header_for_client(client) - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } should_have_json 'active', true expect(json_response).to include('client_id', 'token_type', 'exp', 'iat') @@ -118,7 +118,7 @@ it 'responds with full token introspection' do request.headers['Authorization'] = basic_auth_header_for_client(client) - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } should_have_json 'active', true expect(json_response).to include('client_id', 'token_type', 'exp', 'iat') @@ -134,7 +134,7 @@ it 'responds with only active state' do request.headers['Authorization'] = basic_auth_header_for_client(different_client) - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } expect(response).to be_successful @@ -150,7 +150,7 @@ it 'responds with invalid_client error' do request.headers['Authorization'] = basic_auth_header_for_client(client) - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } expect(response).not_to be_successful response_status_should_be 401 @@ -167,7 +167,7 @@ it 'responds with only active state' do request.headers['Authorization'] = basic_auth_header_for_client(client) - post :introspect, token: SecureRandom.hex(16) + post :introspect, params: { token: SecureRandom.hex(16) } should_have_json 'active', false expect(json_response).not_to include('client_id', 'token_type', 'exp', 'iat') @@ -181,7 +181,7 @@ it 'responds with only active state' do request.headers['Authorization'] = basic_auth_header_for_client(client) - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } should_have_json 'active', false expect(json_response).not_to include('client_id', 'token_type', 'exp', 'iat') @@ -195,7 +195,7 @@ it 'responds with only active state' do request.headers['Authorization'] = basic_auth_header_for_client(client) - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } should_have_json 'active', false expect(json_response).not_to include('client_id', 'token_type', 'exp', 'iat') @@ -206,7 +206,7 @@ let(:access_token) { FactoryBot.create(:access_token) } it 'responds with invalid_request error' do - post :introspect, token: access_token.token + post :introspect, params: { token: access_token.token } expect(response).not_to be_successful response_status_should_be 401 diff --git a/spec/requests/endpoints/token_spec.rb b/spec/requests/endpoints/token_spec.rb index be8a639dd..51e6973a5 100644 --- a/spec/requests/endpoints/token_spec.rb +++ b/spec/requests/endpoints/token_spec.rb @@ -21,10 +21,12 @@ end it 'accepts client credentials with basic auth header' do - post token_endpoint_url( - code: @authorization.token, - redirect_uri: @client.redirect_uri - ), {}, 'HTTP_AUTHORIZATION' => basic_auth_header_for_client(@client) + post token_endpoint_url, + params: { + code: @authorization.token, + redirect_uri: @client.redirect_uri + }, + headers: { 'HTTP_AUTHORIZATION' => basic_auth_header_for_client(@client) } should_have_json 'access_token', Doorkeeper::AccessToken.first.token end diff --git a/spec/requests/flows/client_credentials_spec.rb b/spec/requests/flows/client_credentials_spec.rb index 17de92b5c..c039e962c 100644 --- a/spec/requests/flows/client_credentials_spec.rb +++ b/spec/requests/flows/client_credentials_spec.rb @@ -8,7 +8,7 @@ headers = authorization client.uid, client.secret params = { grant_type: 'client_credentials' } - post '/oauth/token', params, headers + post '/oauth/token', params: params, headers: headers should_have_json 'access_token', Doorkeeper::AccessToken.first.token should_have_json_within 'expires_in', Doorkeeper.configuration.access_token_expires_in, 1 @@ -29,7 +29,7 @@ headers = authorization client.uid, client.secret params = { grant_type: 'client_credentials', scope: 'write' } - post '/oauth/token', params, headers + post '/oauth/token', params: params, headers: headers should_have_json 'access_token', Doorkeeper::AccessToken.first.token should_have_json 'scope', 'write' @@ -40,7 +40,7 @@ headers = authorization client.uid, client.secret params = { grant_type: 'client_credentials', scope: 'public' } - post '/oauth/token', params, headers + post '/oauth/token', params: params, headers: headers should_have_json 'access_token', Doorkeeper::AccessToken.first.token should_have_json 'scope', 'public' @@ -52,7 +52,7 @@ headers = authorization client.uid, client.secret params = { grant_type: 'client_credentials', scope: 'random' } - post '/oauth/token', params, headers + post '/oauth/token', params: params, headers: headers should_have_json 'error', 'invalid_scope' should_have_json 'error_description', translated_error_message(:invalid_scope) @@ -69,7 +69,7 @@ headers = {} params = { grant_type: 'client_credentials' } - post '/oauth/token', params, headers + post '/oauth/token', params: params, headers: headers should_have_json 'error', 'invalid_client' should_have_json 'error_description', translated_error_message(:invalid_client) diff --git a/spec/requests/flows/implicit_grant_spec.rb b/spec/requests/flows/implicit_grant_spec.rb index ee4886028..37d1bc2ed 100644 --- a/spec/requests/flows/implicit_grant_spec.rb +++ b/spec/requests/flows/implicit_grant_spec.rb @@ -34,11 +34,13 @@ token = client_is_authorized(@client, @resource_owner) post "/oauth/authorize", - client_id: @client.uid, - state: '', - redirect_uri: @client.redirect_uri, - response_type: 'token', - commit: 'Authorize' + params: { + client_id: @client.uid, + state: '', + redirect_uri: @client.redirect_uri, + response_type: 'token', + commit: 'Authorize' + } expect(response.location).not_to include(token.token) end @@ -49,11 +51,13 @@ token = client_is_authorized(@client, @resource_owner) post "/oauth/authorize", - client_id: @client.uid, - state: '', - redirect_uri: @client.redirect_uri, - response_type: 'token', - commit: 'Authorize' + params: { + client_id: @client.uid, + state: '', + redirect_uri: @client.redirect_uri, + response_type: 'token', + commit: 'Authorize' + } expect(response.location).to include(token.token) end diff --git a/spec/requests/flows/revoke_token_spec.rb b/spec/requests/flows/revoke_token_spec.rb index 5ae62967c..700b5de86 100644 --- a/spec/requests/flows/revoke_token_spec.rb +++ b/spec/requests/flows/revoke_token_spec.rb @@ -24,7 +24,7 @@ end it 'should revoke the access token provided' do - post revocation_token_endpoint_url, { token: access_token.token }, headers + post revocation_token_endpoint_url, params: { token: access_token.token }, headers: headers access_token.reload @@ -33,7 +33,7 @@ end it 'should revoke the refresh token provided' do - post revocation_token_endpoint_url, { token: access_token.refresh_token }, headers + post revocation_token_endpoint_url, params: { token: access_token.refresh_token }, headers: headers access_token.reload @@ -44,7 +44,7 @@ context 'with invalid token to revoke' do it 'should not revoke any tokens and respond successfully' do num_prev_revoked_tokens = Doorkeeper::AccessToken.where(revoked_at: nil).count - post revocation_token_endpoint_url, { token: 'I_AM_AN_INVALID_TOKEN' }, headers + post revocation_token_endpoint_url, params: { token: 'I_AM_AN_INVALID_TOKEN' }, headers: headers # The authorization server responds with HTTP status code 200 even if # token is invalid @@ -60,7 +60,7 @@ { 'HTTP_AUTHORIZATION' => "Basic #{credentials}" } end it 'should not revoke any tokens and respond successfully' do - post revocation_token_endpoint_url, { token: access_token.token }, headers + post revocation_token_endpoint_url, params: { token: access_token.token }, headers: headers access_token.reload @@ -71,7 +71,7 @@ context 'with no credentials and a valid token' do it 'should not revoke any tokens and respond successfully' do - post revocation_token_endpoint_url, { token: access_token.token } + post revocation_token_endpoint_url, params: { token: access_token.token } access_token.reload @@ -90,7 +90,7 @@ end it 'should not revoke the token as its unauthorized' do - post revocation_token_endpoint_url, { token: access_token.token }, headers + post revocation_token_endpoint_url, params: { token: access_token.token }, headers: headers access_token.reload @@ -109,7 +109,7 @@ end it 'should revoke the access token provided' do - post revocation_token_endpoint_url, { token: access_token.token } + post revocation_token_endpoint_url, params: { token: access_token.token } access_token.reload @@ -118,7 +118,7 @@ end it 'should revoke the refresh token provided' do - post revocation_token_endpoint_url, { token: access_token.refresh_token } + post revocation_token_endpoint_url, params: { token: access_token.refresh_token } access_token.reload @@ -135,7 +135,7 @@ end it 'should not revoke the access token provided' do - post revocation_token_endpoint_url, { token: access_token.token } + post revocation_token_endpoint_url, params: { token: access_token.token } access_token.reload @@ -144,7 +144,7 @@ end it 'should not revoke the refresh token provided' do - post revocation_token_endpoint_url, { token: access_token.token } + post revocation_token_endpoint_url, params: { token: access_token.token } access_token.reload diff --git a/spec/support/http_method_shim.rb b/spec/support/http_method_shim.rb index 0c4524bc3..0168b9445 100644 --- a/spec/support/http_method_shim.rb +++ b/spec/support/http_method_shim.rb @@ -3,35 +3,29 @@ # supported in Rails 5+. Since we support back to 4, we need some sort of shim # to avoid super noisy deprecations when running tests. module RoutingHTTPMethodShim - def get(path, params = {}, headers = nil) - super(path, params: params, headers: headers) + def get(path, **args) + super(path, args[:params], args[:headers]) end - def post(path, params = {}, headers = nil) - super(path, params: params, headers: headers) + def post(path, **args) + super(path, args[:params], args[:headers]) end - def put(path, params = {}, headers = nil) - super(path, params: params, headers: headers) + def put(path, **args) + super(path, args[:params], args[:headers]) end end module ControllerHTTPMethodShim - def get(path, params = {}, opts = {}) - opts[:params] = params - super(path, opts) - end - - def post(path, params = {}) - super(path, params: params) - end - - def put(path, params = {}) - super(path, params: params) + def process(action, http_method = 'GET', **args) + if as = args.delete(:as) + @request.headers['Content-Type'] = Mime[as].to_s + end + super(action, http_method, args[:params], args[:session], args[:flash]) end end -if ::Rails::VERSION::MAJOR >= 5 +if ::Rails::VERSION::MAJOR < 5 RSpec.configure do |config| config.include ControllerHTTPMethodShim, type: :controller config.include RoutingHTTPMethodShim, type: :request