2

I'm trying to update from rails 4.2.6 to rails 5.0.0.1 but get the following warning when running my tests:

DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only keyword arguments in future Rails versions.

Examples:

get :show, params: { id: 1 }, session: { user_id: 1 } process :update, method: :post, params: { id: 1 } (called from block in at /home/ubuntu/workspace/my_app/test/controllers/tractions_controller_test.rb:25)

I've been making the appropriate changes to accommodate for this change. However for the integration test line below, I don't know how to change it properly:

delete api_sessions_path, { api_session: { org_id: nil } }, { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email }

So the test passes but with the deprecation warning. If I change it to the two options below the test fails with a syntax error. How to properly adjust the line?

delete api_sessions_path, params: { api_session: { org_id: nil } }, { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email }
delete api_sessions_path, params: { { api_session: { org_id: nil } }, { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email } }

Update: I've also tried using session with the options below but that produces the error ArgumentError: unknown keyword: session.

delete api_sessions_path, session: { api_session: { org_id: nil } }, params: { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email }
delete api_sessions_path, params: { api_session: { org_id: nil } }, session: { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email }
delete api_sessions_path, params: { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email }, session: { api_session: { org_id: nil } }
delete api_sessions_path, session: { api_session: { org_id: nil } }, { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email }
Marty
  • 2,132
  • 4
  • 21
  • 47
  • 1
    Note: I'm guessing. The edge-rails seems to indicate you may need to use more hash-keys than just params eg looking at `get` here: http://edgeapi.rubyonrails.org/classes/ActionController/TestCase/Behavior.html#method-i-delete it shows that there's also `session` and a few others. perhaps the HTTP tokens need to be using `session` instead of `params`? – Taryn East Oct 24 '16 at 21:17
  • Thanks, I've tried it (see update to post) but this doesn't seem to work. – Marty Oct 25 '16 at 09:04

1 Answers1

2

I found the solution. The headers tag had to be added:

delete api_sessions_path, params: { api_session: { org_id: nil } }, headers: { "HTTP_API_TOKEN": "token", "HTTP_USER_EMAIL": @user.email }
Marty
  • 2,132
  • 4
  • 21
  • 47