mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Test for having scope option to render override the controller's serialization scope
This commit is contained in:
parent
21817bc795
commit
1e7c69c729
@ -131,6 +131,12 @@ class RenderJsonTest < ActionController::TestCase
|
|||||||
render :json => JsonSerializable.new, :options => true
|
render :json => JsonSerializable.new, :options => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_json_with_serializer_and_scope_option
|
||||||
|
@current_user = Struct.new(:as_json).new(:current_user => true)
|
||||||
|
@scope = Struct.new(:as_json).new(:current_user => false)
|
||||||
|
render :json => JsonSerializable.new, :scope => @scope
|
||||||
|
end
|
||||||
|
|
||||||
def render_json_with_serializer_api_but_without_serializer
|
def render_json_with_serializer_api_but_without_serializer
|
||||||
@current_user = Struct.new(:as_json).new(:current_user => true)
|
@current_user = Struct.new(:as_json).new(:current_user => true)
|
||||||
render :json => JsonSerializable.new(true)
|
render :json => JsonSerializable.new(true)
|
||||||
@ -259,6 +265,11 @@ class RenderJsonTest < ActionController::TestCase
|
|||||||
assert_match '"options":true', @response.body
|
assert_match '"options":true', @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_render_json_with_serializer_and_scope_option
|
||||||
|
get :render_json_with_serializer_and_scope_option
|
||||||
|
assert_match '"scope":{"current_user":false}', @response.body
|
||||||
|
end
|
||||||
|
|
||||||
def test_render_json_with_serializer_api_but_without_serializer
|
def test_render_json_with_serializer_api_but_without_serializer
|
||||||
get :render_json_with_serializer_api_but_without_serializer
|
get :render_json_with_serializer_api_but_without_serializer
|
||||||
assert_match '{"serializable_object":true}', @response.body
|
assert_match '{"serializable_object":true}', @response.body
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user