mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:08 -05:00
Custom cookie serializer test
Adapted from
b23ffd0dac/actionpack/test/dispatch/cookies_test.rb (L382-L413)
This commit is contained in:
committed by
Charlie Somerville
parent
0342deaa22
commit
67b3fd5cb8
@@ -63,6 +63,11 @@ class CookiesTest < ActionController::TestCase
|
||||
head :ok
|
||||
end
|
||||
|
||||
def set_signed_string_cookie
|
||||
cookies.signed[:foo] = 'bar'
|
||||
head :ok
|
||||
end
|
||||
|
||||
def raise_data_overflow
|
||||
cookies.signed[:foo] = 'bye!' * 1024
|
||||
head :ok
|
||||
@@ -332,6 +337,22 @@ class CookiesTest < ActionController::TestCase
|
||||
}
|
||||
end
|
||||
|
||||
class ActionDispatch::Session::CustomJsonSerializer
|
||||
def self.load(value)
|
||||
JSON.load(value) + " and loaded"
|
||||
end
|
||||
|
||||
def self.dump(value)
|
||||
JSON.dump(value + " was dumped")
|
||||
end
|
||||
end
|
||||
|
||||
def test_signed_cookie_using_serializer_object
|
||||
@request.env["action_dispatch.session_serializer"] = ActionDispatch::Session::CustomJsonSerializer
|
||||
get :set_signed_string_cookie
|
||||
assert_equal 'bar was dumped and loaded', @controller.send(:cookies).signed[:foo]
|
||||
end
|
||||
|
||||
def test_cookie_with_all_domain_option
|
||||
get :set_cookie_with_domain
|
||||
assert_response :success
|
||||
|
||||
Reference in New Issue
Block a user