Skip to content

Instantly share code, notes, and snippets.

@lukesarnacki
Created January 14, 2014 09:28
Show Gist options
  • Save lukesarnacki/8415600 to your computer and use it in GitHub Desktop.
Save lukesarnacki/8415600 to your computer and use it in GitHub Desktop.
class ActionDispatch::Session::JsonSerializer
def self.load(value)
JSON.load(value) + " and loaded"
end
def self.dump(value)
JSON.dump(value + " was dumped")
end
end
def test_encrypted_cookie_using_json_serializer
@request.env["action_dispatch.session_serializer"] = :json_serializer
get :set_encrypted_cookie
cookies = @controller.send :cookies
assert_not_equal 'bar', cookies[:foo]
assert_raises TypeError do
cookies.signed[:foo]
end
assert_equal 'bar was dumped and loaded', cookies.encrypted[:foo]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment