mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Merge remote-tracking branch 'upstream/master' into fix-jsonapi-ri
This commit is contained in:
@@ -6,7 +6,7 @@ module ActiveModel
|
||||
def setup
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@profile_serializer = ProfileSerializer.new(@profile)
|
||||
@comment = Comment.new(id: 1, body: "ZOMG!!", date: "2015")
|
||||
@comment = Comment.new(id: 1, body: 'ZOMG!!', date: '2015')
|
||||
@serializer_klass = Class.new(CommentSerializer)
|
||||
@serializer_klass_with_new_attributes = Class.new(CommentSerializer) do
|
||||
attributes :date, :likes
|
||||
@@ -15,12 +15,12 @@ module ActiveModel
|
||||
|
||||
def test_attributes_definition
|
||||
assert_equal([:name, :description],
|
||||
@profile_serializer.class._attributes)
|
||||
@profile_serializer.class._attributes)
|
||||
end
|
||||
|
||||
def test_attributes_with_fields_option
|
||||
assert_equal({name: 'Name 1'},
|
||||
@profile_serializer.attributes(fields: [:name]))
|
||||
assert_equal({ name: 'Name 1' },
|
||||
@profile_serializer.attributes(fields: [:name]))
|
||||
end
|
||||
|
||||
def test_attributes_inheritance_definition
|
||||
@@ -29,8 +29,8 @@ module ActiveModel
|
||||
|
||||
def test_attributes_inheritance
|
||||
serializer = @serializer_klass.new(@comment)
|
||||
assert_equal({id: 1, body: "ZOMG!!"},
|
||||
serializer.attributes)
|
||||
assert_equal({ id: 1, body: 'ZOMG!!' },
|
||||
serializer.attributes)
|
||||
end
|
||||
|
||||
def test_attribute_inheritance_with_new_attribute_definition
|
||||
@@ -40,8 +40,8 @@ module ActiveModel
|
||||
|
||||
def test_attribute_inheritance_with_new_attribute
|
||||
serializer = @serializer_klass_with_new_attributes.new(@comment)
|
||||
assert_equal({id: 1, body: "ZOMG!!", date: "2015", likes: nil},
|
||||
serializer.attributes)
|
||||
assert_equal({ id: 1, body: 'ZOMG!!', date: '2015', likes: nil },
|
||||
serializer.attributes)
|
||||
end
|
||||
|
||||
def test_multiple_calls_with_the_same_attribute
|
||||
|
||||
Reference in New Issue
Block a user