From 9c728077f0d2f8a166d31704918067b2cf526f8b Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Fri, 22 Mar 2019 15:56:02 -0300 Subject: [PATCH] 14873: Fixes deprecation notes on functional tests. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../api/app/controllers/application_controller.rb | 6 +++--- .../test/functional/application_controller_test.rb | 12 ++++++------ .../test/functional/user_sessions_controller_test.rb | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index 814b4cd8fd..572531a3a0 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -187,7 +187,7 @@ class ApplicationController < ActionController::Base # The obvious render(json: ...) forces a slow JSON encoder. See # #3021 and commit logs. Might be fixed in Rails 4.1. render({ - text: SafeJSON.dump(response).html_safe, + plain: SafeJSON.dump(response).html_safe, content_type: 'application/json' }.merge opts) end @@ -431,8 +431,8 @@ class ApplicationController < ActionController::Base end def respond_with_json_by_default - html_index = request.accepts.index(Mime::HTML) - if html_index.nil? or request.accepts[0...html_index].include?(Mime::JSON) + html_index = request.accepts.index(Mime[:html]) + if html_index.nil? or request.accepts[0...html_index].include?(Mime[:json]) request.format = :json end end diff --git a/services/api/test/functional/application_controller_test.rb b/services/api/test/functional/application_controller_test.rb index 27b046e3c2..b5f71acb53 100644 --- a/services/api/test/functional/application_controller_test.rb +++ b/services/api/test/functional/application_controller_test.rb @@ -34,19 +34,19 @@ class ApplicationControllerTest < ActionController::TestCase test "requesting nonexistent object returns 404 error" do authorize_with :admin - get(:show, id: BAD_UUID) + get(:show, params: {id: BAD_UUID}) check_404 end test "requesting object without read permission returns 404 error" do authorize_with :spectator - get(:show, id: specimens(:owned_by_active_user).uuid) + get(:show, params: {id: specimens(:owned_by_active_user).uuid}) check_404 end test "submitting bad object returns error" do authorize_with :spectator - post(:create, specimen: {badattr: "badvalue"}) + post(:create, params: {specimen: {badattr: "badvalue"}}) assert_response 422 check_error_token end @@ -77,7 +77,7 @@ class ApplicationControllerTest < ActionController::TestCase test "bogus boolean parameter #{bogus.inspect} returns error" do @controller = Arvados::V1::GroupsController.new authorize_with :active - post :create, { + post :create, params: { group: {}, ensure_unique_name: bogus } @@ -94,7 +94,7 @@ class ApplicationControllerTest < ActionController::TestCase test "boolean parameter #{boolparam.inspect} acceptable" do @controller = Arvados::V1::GroupsController.new authorize_with :active - post :create, { + post :create, params: { group: {}, ensure_unique_name: boolparam } @@ -105,7 +105,7 @@ class ApplicationControllerTest < ActionController::TestCase test "boolean parameter #{boolparam.inspect} accepted as #{bool.inspect}" do @controller = Arvados::V1::GroupsController.new authorize_with :active - post :create, { + post :create, params: { group: { name: groups(:aproject).name, owner_uuid: groups(:aproject).owner_uuid diff --git a/services/api/test/functional/user_sessions_controller_test.rb b/services/api/test/functional/user_sessions_controller_test.rb index e3048159f4..cee8245b25 100644 --- a/services/api/test/functional/user_sessions_controller_test.rb +++ b/services/api/test/functional/user_sessions_controller_test.rb @@ -9,7 +9,7 @@ class UserSessionsControllerTest < ActionController::TestCase test "new user from new api client" do authorize_with :inactive api_client_page = 'http://client.example.com/home' - get :login, return_to: api_client_page + get :login, params: {return_to: api_client_page} assert_response :redirect assert_equal(0, @response.redirect_url.index(api_client_page + '?'), 'Redirect url ' + @response.redirect_url + @@ -21,7 +21,7 @@ class UserSessionsControllerTest < ActionController::TestCase authorize_with :inactive api_client_page = 'http://client.example.com/home' remote_prefix = 'zbbbb' - get :login, return_to: api_client_page, remote: remote_prefix + get :login, params: {return_to: api_client_page, remote: remote_prefix} assert_response :redirect api_client_auth = assigns(:api_client_auth) assert_not_nil api_client_auth @@ -32,7 +32,7 @@ class UserSessionsControllerTest < ActionController::TestCase authorize_with :inactive api_client_page = 'http://client.example.com/home' remote_prefix = 'invalid_cluster_id' - get :login, return_to: api_client_page, remote: remote_prefix + get :login, params: {return_to: api_client_page, remote: remote_prefix} assert_response 400 end end -- 2.30.2