aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/test_case_test.rb
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2015-02-01 16:07:42 +0300
committerKir Shatrov <shatrov@me.com>2015-02-01 16:07:42 +0300
commitb19999f3a7c39fc1a959cc3c39575014d0fd2835 (patch)
tree30eca90db38b5744671b15b24e267fba589aa314 /actionpack/test/controller/test_case_test.rb
parent33030ea7cbfa026b0f9f95a2c5d2dd363a7fe6aa (diff)
downloadrails-b19999f3a7c39fc1a959cc3c39575014d0fd2835.tar.gz
rails-b19999f3a7c39fc1a959cc3c39575014d0fd2835.tar.bz2
rails-b19999f3a7c39fc1a959cc3c39575014d0fd2835.zip
Migrating xhr methods to keyword arguments syntax
in `ActionController::TestCase` and `ActionDispatch::Integration` Old syntax: `xhr :get, :create, params: { id: 1 }` New syntax example: `get :create, params: { id: 1 }, xhr: true`
Diffstat (limited to 'actionpack/test/controller/test_case_test.rb')
-rw-r--r--actionpack/test/controller/test_case_test.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index 901db63e39..02a757ad75 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -694,19 +694,34 @@ XML
end
def test_header_properly_reset_after_remote_http_request
- xhr :get, :test_params
+ get :test_params, xhr: true
assert_nil @request.env['HTTP_X_REQUESTED_WITH']
assert_nil @request.env['HTTP_ACCEPT']
end
+ def test_deprecated_xhr_with_params
+ assert_deprecated { xhr :get, :test_params, params: { id: 1 } }
+
+ assert_equal(%({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}), @response.body)
+ end
+
def test_xhr_with_params
- xhr :get, :test_params, params: { id: 1 }
+ get :test_params, params: { id: 1 }, xhr: true
assert_equal(%({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}), @response.body)
end
def test_xhr_with_session
- xhr :get, :set_session
+ get :set_session, xhr: true
+
+ assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key"
+ assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access"
+ assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access"
+ assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access"
+ end
+
+ def test_deprecated_xhr_with_session
+ assert_deprecated { xhr :get, :set_session }
assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key"
assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access"