jsonapi-serializers 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22bd1a0e4edb6afa842b9aea4e12083b376b2c3a
4
- data.tar.gz: fb1c32bdf48825ffbc32db8078c6daf1c7c31f5d
3
+ metadata.gz: 6e720f6b16c3cb7ac850907d34061333a89ebc82
4
+ data.tar.gz: 2702a9fc740389ea33fcecaf09693b66265ec4ff
5
5
  SHA512:
6
- metadata.gz: 3fb9216808ac7835e95dde7a428bc1af161d4940d72ed67737a864294777894249cbbb405e3e544a6104b798db3d6728dbc1cd163bb29bddf283bf6c438536d2
7
- data.tar.gz: fee4e082f317e1cb3486829dbdfad8016834299b39e290e664e27fdd91d0914e7a246ae43ffa0bd875d773013a91bb3f2105d7563dda3e50bb24dcd906c6320c
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.include?('_')
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(
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Serializer
3
- VERSION = '0.6.2'
3
+ VERSION = '0.6.3'
4
4
  end
5
5
  end
@@ -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
@@ -36,4 +36,9 @@ FactoryGirl.define do
36
36
  sequence(:id) {|n| n }
37
37
  sequence(:name) {|n| "User ##{n}"}
38
38
  end
39
+
40
+ factory :underscore_test, class: MyApp::UnderscoreTest do
41
+ skip_create
42
+ sequence(:id) {|n| n }
43
+ end
39
44
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Fotinakis