active_model_serializers/test/include_tree/from_include_args_test.rb

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