jsonapi-serializers 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/jsonapi-serializers/serializer.rb +1 -1
- data/lib/jsonapi-serializers/version.rb +1 -1
- data/spec/serializer_spec.rb +20 -0
- data/spec/support/factory.rb +5 -0
- data/spec/support/serializers.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e720f6b16c3cb7ac850907d34061333a89ebc82
|
4
|
+
data.tar.gz: 2702a9fc740389ea33fcecaf09693b66265ec4ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a0fe500512489e94bc37fd9782eb47a0b00caea5cd9af124b8553db8984c1ca7cb16ea28cf3d34420065296b78a68ae0409bcd4c6af1d165a1136986f669320
|
7
|
+
data.tar.gz: b89771e54eb2e45615b6c1c7dfeca693398aec729c27822276842a683cf7f3e5af7f6e4da89f947302983242ca0a69afc3caa387ecf0a3b13af1f03859d21157
|
data/README.md
CHANGED
@@ -652,6 +652,8 @@ end
|
|
652
652
|
|
653
653
|
## Release notes
|
654
654
|
|
655
|
+
* v0.6.3: Fix support for underscore-formatted attribute names.
|
656
|
+
* v0.6.2: Internal style updates and performance fixes.
|
655
657
|
* v0.6.1: Spec compliance fix, include intermediate resources on compound documents.
|
656
658
|
* v0.6.0: Support for polymorphic collections and inheriting serializer attributes.
|
657
659
|
* v0.5.0: Support for explicit serializer discovery.
|
@@ -385,7 +385,7 @@ module JSONAPI
|
|
385
385
|
"'#{attribute_name}' is not a valid include.")
|
386
386
|
end
|
387
387
|
|
388
|
-
if attribute_name.
|
388
|
+
if attribute_name != serializer.format_name(attribute_name)
|
389
389
|
expected_name = serializer.format_name(attribute_name)
|
390
390
|
|
391
391
|
raise JSONAPI::Serializer::InvalidIncludeError.new(
|
data/spec/serializer_spec.rb
CHANGED
@@ -847,4 +847,24 @@ describe JSONAPI::Serializer do
|
|
847
847
|
})
|
848
848
|
end
|
849
849
|
end
|
850
|
+
|
851
|
+
describe 'include validation' do
|
852
|
+
it 'raises an exception when join character is invalid' do
|
853
|
+
expect do
|
854
|
+
JSONAPI::Serializer.serialize(create(:post), include: 'long_comments');
|
855
|
+
end.to raise_error(JSONAPI::Serializer::InvalidIncludeError)
|
856
|
+
|
857
|
+
expect do
|
858
|
+
JSONAPI::Serializer.serialize(create(:post), include: 'long-comments');
|
859
|
+
end.not_to raise_error
|
860
|
+
|
861
|
+
expect do
|
862
|
+
JSONAPI::Serializer.serialize(create(:underscore_test), include: 'tagged-posts');
|
863
|
+
end.to raise_error(JSONAPI::Serializer::InvalidIncludeError)
|
864
|
+
|
865
|
+
expect do
|
866
|
+
JSONAPI::Serializer.serialize(create(:underscore_test), include: 'tagged_posts');
|
867
|
+
end.not_to raise_error
|
868
|
+
end
|
869
|
+
end
|
850
870
|
end
|
data/spec/support/factory.rb
CHANGED
data/spec/support/serializers.rb
CHANGED
@@ -32,6 +32,14 @@ module MyApp
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
class UnderscoreTest
|
36
|
+
attr_accessor :id
|
37
|
+
|
38
|
+
def tagged_posts
|
39
|
+
[]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
35
43
|
class PostSerializer
|
36
44
|
include JSONAPI::Serializer
|
37
45
|
|
@@ -44,6 +52,16 @@ module MyApp
|
|
44
52
|
has_many :long_comments
|
45
53
|
end
|
46
54
|
|
55
|
+
class UnderscoreTestSerializer
|
56
|
+
include JSONAPI::Serializer
|
57
|
+
|
58
|
+
has_many :tagged_posts
|
59
|
+
|
60
|
+
def format_name(attribute_name)
|
61
|
+
attribute_name.to_s.underscore
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
47
65
|
class LongCommentSerializer
|
48
66
|
include JSONAPI::Serializer
|
49
67
|
|