mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
- Better minitest 4/5 support - Better DSL - Already available with no changes - Consistent interface
27 lines
832 B
Ruby
27 lines
832 B
Ruby
require 'test_helper'
|
|
|
|
module ActiveModel
|
|
class Serializer
|
|
class IncludeTree
|
|
class FromStringTest < ActiveSupport::TestCase
|
|
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
|