mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 14:29:31 +00:00
27 lines
823 B
Ruby
27 lines
823 B
Ruby
require 'test_helper'
|
|
|
|
module ActiveModel
|
|
class Serializer
|
|
class IncludeTree
|
|
class FromStringTest < Minitest::Test
|
|
def test_simple_array
|
|
input = [:comments, :author]
|
|
actual = ActiveModel::Serializer::IncludeTree.from_include_args(input)
|
|
assert(actual.key?(:author))
|
|
assert(actual.key?(:comments))
|
|
end
|
|
|
|
def test_nested_array
|
|
input = [:comments, posts: [:author, comments: [:author]]]
|
|
actual = ActiveModel::Serializer::IncludeTree.from_include_args(input)
|
|
assert(actual.key?(:posts))
|
|
assert(actual[:posts].key?(:author))
|
|
assert(actual[:posts].key?(:comments))
|
|
assert(actual[:posts][:comments].key?(:author))
|
|
assert(actual.key?(:comments))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|