Skip to content

Commit 5fecef5

Browse files
coreywardsenid231
authored andcommitted
Test path params are excluded from serialized attributes
1 parent 4a4f757 commit 5fecef5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/unit/serializing_test.rb

+19
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ class LimitedField < TestResource
66
self.read_only_attributes += ['foo']
77
end
88

9+
class NestedResource < TestResource
10+
belongs_to :bar
11+
end
12+
913
class CustomSerializerAttributes < TestResource
1014

1115
protected
@@ -317,4 +321,19 @@ def test_underscored_relationship_key_serialization
317321
assert_equal expected, article.as_json_api['relationships']
318322
end
319323
end
324+
325+
def test_ensure_nested_path_params_not_serialized
326+
resource = NestedResource.new(foo: 'bar', id: 1, bar_id: 99)
327+
328+
expected = {
329+
'id' => 1,
330+
'type' => "nested_resources",
331+
'attributes' => {
332+
'foo' => 'bar'
333+
}
334+
}
335+
336+
assert_equal expected, resource.as_json_api
337+
end
338+
320339
end

0 commit comments

Comments
 (0)