Skip to content

Commit 8179beb

Browse files
committed
Fix tests.
1 parent 42ee7e8 commit 8179beb

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

test/adapter/json_api/collection_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ def test_include_multiple_posts
5858
end
5959

6060
def test_limiting_fields
61-
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, fields: ['title'])
62-
61+
actual = ActiveModel::SerializableResource.new(
62+
[@first_post, @second_post], adapter: :json_api,
63+
fields: { posts: ['title'] })
64+
.serializable_hash
6365
expected = [
6466
{
6567
id: '1',
@@ -86,7 +88,7 @@ def test_limiting_fields
8688
}
8789
}
8890
]
89-
assert_equal(expected, @adapter.serializable_hash[:data])
91+
assert_equal(expected, actual[:data])
9092
end
9193
end
9294
end

test/serializers/attributes_test.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ def test_attributes_definition
1818
@profile_serializer.class._attributes)
1919
end
2020

21-
def test_attributes_with_fields_option
22-
assert_equal({ name: 'Name 1' },
23-
@profile_serializer.attributes(fields: [:name]))
24-
end
25-
2621
def test_attributes_inheritance_definition
2722
assert_equal([:id, :body], @serializer_klass._attributes)
2823
end

test/serializers/fieldset_test.rb

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,11 @@ module ActiveModel
44
class Serializer
55
class FieldsetTest < Minitest::Test
66
def test_fieldset_with_hash
7-
fieldset = ActiveModel::Serializer::Fieldset.new({ 'post' => %w(id title), 'coment' => ['body'] })
7+
fieldset = ActiveModel::Serializer::Fieldset.new('post' => %w(id title), 'comment' => ['body'])
8+
expected = { :post => [:id, :title], :comment => [:body] }
89

9-
assert_equal(
10-
{ :post => [:id, :title], :coment => [:body] },
11-
fieldset.fields
12-
)
13-
end
14-
15-
def test_fieldset_with_array_of_fields_and_root_name
16-
fieldset = ActiveModel::Serializer::Fieldset.new(['title'], 'post')
17-
18-
assert_equal(
19-
{ :post => [:title] },
20-
fieldset.fields
21-
)
10+
assert_equal(expected, fieldset.fields)
2211
end
2312
end
2413
end
25-
end
14+
end

0 commit comments

Comments
 (0)