Rename ArraySerializer to CollectionSerializer for clarity

This commit is contained in:
Benjamin Fleischer
2015-10-07 05:07:00 -05:00
parent 737784c9b7
commit 2c8b9b796d
19 changed files with 213 additions and 148 deletions

View File

@@ -23,7 +23,7 @@ module ActiveModel
def test_with_serializer_option
@blog.special_attribute = 'Special'
@blog.articles = [@first_post, @second_post]
serializer = ArraySerializer.new([@blog], serializer: CustomBlogSerializer)
serializer = CollectionSerializer.new([@blog], serializer: CustomBlogSerializer)
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
expected = { blogs: [{
@@ -35,7 +35,7 @@ module ActiveModel
end
def test_include_multiple_posts
serializer = ArraySerializer.new([@first_post, @second_post])
serializer = CollectionSerializer.new([@first_post, @second_post])
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
expected = { posts: [{
@@ -70,14 +70,14 @@ module ActiveModel
def test_root_is_underscored
virtual_value = VirtualValue.new(id: 1)
serializer = ArraySerializer.new([virtual_value])
serializer = CollectionSerializer.new([virtual_value])
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
assert_equal 1, adapter.serializable_hash[:virtual_values].length
end
def test_include_option
serializer = ArraySerializer.new([@first_post, @second_post])
serializer = CollectionSerializer.new([@first_post, @second_post])
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer, include: '')
actual = adapter.serializable_hash
expected = { posts: [{ id: 1, title: 'Hello!!', body: 'Hello, world!!' },

View File

@@ -19,7 +19,7 @@ module ActiveModel
@second_post.author = @author
@author.posts = [@first_post, @second_post]
@serializer = ArraySerializer.new([@first_post, @second_post])
@serializer = CollectionSerializer.new([@first_post, @second_post])
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer)
ActionController::Base.cache_store.clear
end

View File

@@ -45,7 +45,7 @@ module ActiveModel
end
def test_include_multiple_posts_and_linked_array
serializer = ArraySerializer.new([@first_post, @second_post])
serializer = CollectionSerializer.new([@first_post, @second_post])
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(
serializer,
include: [:comments, author: [:bio]]
@@ -226,7 +226,7 @@ module ActiveModel
end
def test_multiple_references_to_same_resource
serializer = ArraySerializer.new([@first_comment, @second_comment])
serializer = CollectionSerializer.new([@first_comment, @second_comment])
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(
serializer,
include: [:post]