Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
beauby committed Oct 5, 2015
1 parent 42ee7e8 commit 387d548
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Fixes:
- [#1214](https://github.com/rails-api/active_model_serializers/pull/1214) retrieve the key from the reflection options when building associations (@NullVoxPopuli, @hut8)

Misc:
- [#1232](https://github.com/rails-api/active_model_serializers/pull/1232) fields option no longer handled at serializer level (@beauby)
- [#1178](https://github.com/rails-api/active_model_serializers/pull/1178) env CAPTURE_STDERR=false lets devs see hard failures (@bf4)
- [#1177](https://github.com/rails-api/active_model_serializers/pull/1177) Remove Adapter autoloads in favor of require (@bf4)
- [#1117](https://github.com/rails-api/active_model_serializers/pull/1117) FlattenJson adapter no longer inherits Json adapter, renamed to Attributes (@bf4)
Expand Down
8 changes: 5 additions & 3 deletions test/adapter/json_api/collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ def test_include_multiple_posts
end

def test_limiting_fields
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, fields: ['title'])

actual = ActiveModel::SerializableResource.new(
[@first_post, @second_post], adapter: :json_api,
fields: { posts: ['title'] })
.serializable_hash
expected = [
{
id: '1',
Expand All @@ -86,7 +88,7 @@ def test_limiting_fields
}
}
]
assert_equal(expected, @adapter.serializable_hash[:data])
assert_equal(expected, actual[:data])
end
end
end
Expand Down
5 changes: 0 additions & 5 deletions test/serializers/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ def test_attributes_definition
@profile_serializer.class._attributes)
end

def test_attributes_with_fields_option
assert_equal({ name: 'Name 1' },
@profile_serializer.attributes(fields: [:name]))
end

def test_attributes_inheritance_definition
assert_equal([:id, :body], @serializer_klass._attributes)
end
Expand Down
19 changes: 4 additions & 15 deletions test/serializers/fieldset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,11 @@ module ActiveModel
class Serializer
class FieldsetTest < Minitest::Test
def test_fieldset_with_hash
fieldset = ActiveModel::Serializer::Fieldset.new({ 'post' => %w(id title), 'coment' => ['body'] })
fieldset = ActiveModel::Serializer::Fieldset.new('post' => %w(id title), 'comment' => ['body'])
expected = { :post => [:id, :title], :comment => [:body] }

assert_equal(
{ :post => [:id, :title], :coment => [:body] },
fieldset.fields
)
end

def test_fieldset_with_array_of_fields_and_root_name
fieldset = ActiveModel::Serializer::Fieldset.new(['title'], 'post')

assert_equal(
{ :post => [:title] },
fieldset.fields
)
assert_equal(expected, fieldset.fields)
end
end
end
end
end

0 comments on commit 387d548

Please sign in to comment.