grape_fast_jsonapi 0.2.4 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c949823976af65fb4896c7a49333309978436c22324d79f296d6fb02fc4734db
4
- data.tar.gz: 6381b94d235e84227841b123ae7b70a9b819d244473bd62180c59738997eca5c
3
+ metadata.gz: 124200e814c960ae250ca18ae8239bfb6cce25b6819d9e71672aef83b9fb1fad
4
+ data.tar.gz: 6155dd8491942fd0b0f7342032af4f8a423fc297193c5113cc6582f157bf52d3
5
5
  SHA512:
6
- metadata.gz: 61dc166df0aa1a94506aaa609016a805810bbf8d3589c1457764324cd418d75cc4cad8891235d056e22a8ea2d751efcb528ad236a7c7b93c764d5b17a1594331
7
- data.tar.gz: 9f812886c303cc04a96a6b3e4380da40805e7614a3cfd36324823c52831e47dc3a3aaa6423302d01cf2e6ea3b1543b2990eda387edad8eb79d26f4b0cd349fbc
6
+ metadata.gz: e94748c505d38c59d7d895a022343891b5895c0dd18242c4bc53f6389c89cf4584c6d94eddc54b0b7712fa23ef6cee9321506714c634a9001eb1843cd467b447
7
+ data.tar.gz: c5ee861778ebdbec255d56a11a9ea814f01d1775da2beed6871ffd5f7c7935bb7e4896eeb526de23fadd6f82542b87b9058cbc8bc805a4257ae3019405416f9f
data/.circleci/config.yml CHANGED
@@ -7,9 +7,11 @@ jobs:
7
7
  build:
8
8
  docker:
9
9
  # specify the version you desire here
10
- - image: circleci/ruby:2.5.3-node-browsers
10
+ - image: circleci/ruby:2.6.3-node-browsers
11
11
  environment:
12
12
  RAILS_ENV: test
13
+ PGHOST: 127.0.0.1
14
+ PGUSER: root
13
15
 
14
16
  # Specify service dependencies here if necessary
15
17
  # CircleCI maintains a library of pre-built images
data/CHANGELOG.md CHANGED
@@ -1,24 +1,30 @@
1
1
  ## Changelog
2
2
 
3
- ### v0.2.5 (Next)
3
+ ### v0.2.6 (Next)
4
4
 
5
5
  * Your contribution here.
6
6
 
7
+ ### v0.2.5 (January 23, 2020)
8
+
9
+ * [#18](https://github.com/EmCousin/grape_fast_jsonapi/pull/18) - Revert to model_name instead of class-name - [@dblommesteijn](https://github.com/dblommesteijn)
10
+
11
+ Note : This PR fixes a bug when serializing a ActiveRecord::Relation instance, the formatter was looking for a formatter `ActiveRecord::RelationSerializer` serializer that doesn't exist, insteafd of looking for the serializer corresponding to its model name.
12
+
7
13
  ### v0.2.4 (December 16, 2019)
8
14
 
9
15
  * [#15](https://github.com/EmCousin/grape_fast_jsonapi/pull/15) - Handle serializers which don't have any attributes - [@vesan](https://github.com/vesan)
10
16
 
11
17
  ### v0.2.3 (December 12, 2019)
12
18
 
13
- * Reverted v0.2.2 and bumped `loofah` using `dependabot`
19
+ * Reverted v0.2.2 and bumped `loofah` using `dependabot` - [@EmCousin](https://github.com/EmCousin).
14
20
 
15
21
  ### v0.2.2 (December 12, 2019)
16
22
 
17
- * Fixed low severity vulnerabiliy issue with `loofah` dependency
23
+ * Fixed low severity vulnerabiliy issue with `loofah` dependency - [@EmCousin](https://github.com/EmCousin).
18
24
 
19
25
  ### v0.2.1 (September 18, 2019)
20
26
 
21
- * [#12](https://github.com/EmCousin/grape_fast_jsonapi/pull/12) - Removed call to `rails` and fixed a potential security issue
27
+ * [#12](https://github.com/EmCousin/grape_fast_jsonapi/pull/12) - Removed call to `rails` and fixed a potential security issue - [@EmCousin](https://github.com/EmCousin).
22
28
 
23
29
  ### v0.2.0 (February 8, 2019)
24
30
 
data/Gemfile.lock CHANGED
@@ -1,97 +1,108 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape_fast_jsonapi (0.2.4)
4
+ grape_fast_jsonapi (0.2.5)
5
5
  fast_jsonapi (>= 1.5)
6
6
  grape
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (6.0.0)
12
- actionpack (= 6.0.0)
11
+ actioncable (6.0.2.1)
12
+ actionpack (= 6.0.2.1)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (6.0.0)
16
- actionpack (= 6.0.0)
17
- activejob (= 6.0.0)
18
- activerecord (= 6.0.0)
19
- activestorage (= 6.0.0)
20
- activesupport (= 6.0.0)
15
+ actionmailbox (6.0.2.1)
16
+ actionpack (= 6.0.2.1)
17
+ activejob (= 6.0.2.1)
18
+ activerecord (= 6.0.2.1)
19
+ activestorage (= 6.0.2.1)
20
+ activesupport (= 6.0.2.1)
21
21
  mail (>= 2.7.1)
22
- actionmailer (6.0.0)
23
- actionpack (= 6.0.0)
24
- actionview (= 6.0.0)
25
- activejob (= 6.0.0)
22
+ actionmailer (6.0.2.1)
23
+ actionpack (= 6.0.2.1)
24
+ actionview (= 6.0.2.1)
25
+ activejob (= 6.0.2.1)
26
26
  mail (~> 2.5, >= 2.5.4)
27
27
  rails-dom-testing (~> 2.0)
28
- actionpack (6.0.0)
29
- actionview (= 6.0.0)
30
- activesupport (= 6.0.0)
31
- rack (~> 2.0)
28
+ actionpack (6.0.2.1)
29
+ actionview (= 6.0.2.1)
30
+ activesupport (= 6.0.2.1)
31
+ rack (~> 2.0, >= 2.0.8)
32
32
  rack-test (>= 0.6.3)
33
33
  rails-dom-testing (~> 2.0)
34
34
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
- actiontext (6.0.0)
36
- actionpack (= 6.0.0)
37
- activerecord (= 6.0.0)
38
- activestorage (= 6.0.0)
39
- activesupport (= 6.0.0)
35
+ actiontext (6.0.2.1)
36
+ actionpack (= 6.0.2.1)
37
+ activerecord (= 6.0.2.1)
38
+ activestorage (= 6.0.2.1)
39
+ activesupport (= 6.0.2.1)
40
40
  nokogiri (>= 1.8.5)
41
- actionview (6.0.0)
42
- activesupport (= 6.0.0)
41
+ actionview (6.0.2.1)
42
+ activesupport (= 6.0.2.1)
43
43
  builder (~> 3.1)
44
44
  erubi (~> 1.4)
45
45
  rails-dom-testing (~> 2.0)
46
46
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
- activejob (6.0.0)
48
- activesupport (= 6.0.0)
47
+ activejob (6.0.2.1)
48
+ activesupport (= 6.0.2.1)
49
49
  globalid (>= 0.3.6)
50
- activemodel (6.0.0)
51
- activesupport (= 6.0.0)
52
- activerecord (6.0.0)
53
- activemodel (= 6.0.0)
54
- activesupport (= 6.0.0)
55
- activestorage (6.0.0)
56
- actionpack (= 6.0.0)
57
- activejob (= 6.0.0)
58
- activerecord (= 6.0.0)
50
+ activemodel (6.0.2.1)
51
+ activesupport (= 6.0.2.1)
52
+ activerecord (6.0.2.1)
53
+ activemodel (= 6.0.2.1)
54
+ activesupport (= 6.0.2.1)
55
+ activestorage (6.0.2.1)
56
+ actionpack (= 6.0.2.1)
57
+ activejob (= 6.0.2.1)
58
+ activerecord (= 6.0.2.1)
59
59
  marcel (~> 0.3.1)
60
- activesupport (6.0.0)
60
+ activesupport (6.0.2.1)
61
61
  concurrent-ruby (~> 1.0, >= 1.0.2)
62
62
  i18n (>= 0.7, < 2)
63
63
  minitest (~> 5.1)
64
64
  tzinfo (~> 1.1)
65
- zeitwerk (~> 2.1, >= 2.1.8)
66
- axiom-types (0.1.1)
67
- descendants_tracker (~> 0.0.4)
68
- ice_nine (~> 0.11.0)
69
- thread_safe (~> 0.3, >= 0.3.1)
70
- builder (3.2.3)
71
- coercible (1.0.0)
72
- descendants_tracker (~> 0.0.1)
65
+ zeitwerk (~> 2.2)
66
+ builder (3.2.4)
73
67
  concurrent-ruby (1.1.5)
74
- crass (1.0.5)
75
- descendants_tracker (0.0.4)
76
- thread_safe (~> 0.3, >= 0.3.1)
68
+ crass (1.0.6)
77
69
  diff-lcs (1.3)
78
- equalizer (0.0.11)
79
- erubi (1.8.0)
70
+ dry-configurable (0.9.0)
71
+ concurrent-ruby (~> 1.0)
72
+ dry-core (~> 0.4, >= 0.4.7)
73
+ dry-container (0.7.2)
74
+ concurrent-ruby (~> 1.0)
75
+ dry-configurable (~> 0.1, >= 0.1.3)
76
+ dry-core (0.4.9)
77
+ concurrent-ruby (~> 1.0)
78
+ dry-equalizer (0.3.0)
79
+ dry-inflector (0.2.0)
80
+ dry-logic (1.0.5)
81
+ concurrent-ruby (~> 1.0)
82
+ dry-core (~> 0.2)
83
+ dry-equalizer (~> 0.2)
84
+ dry-types (1.2.2)
85
+ concurrent-ruby (~> 1.0)
86
+ dry-container (~> 0.3)
87
+ dry-core (~> 0.4, >= 0.4.4)
88
+ dry-equalizer (~> 0.3)
89
+ dry-inflector (~> 0.1, >= 0.1.2)
90
+ dry-logic (~> 1.0, >= 1.0.2)
91
+ erubi (1.9.0)
80
92
  fast_jsonapi (1.5)
81
93
  activesupport (>= 4.2)
82
94
  globalid (0.4.2)
83
95
  activesupport (>= 4.2.0)
84
- grape (1.2.4)
96
+ grape (1.3.0)
85
97
  activesupport
86
98
  builder
99
+ dry-types (>= 1.1)
87
100
  mustermann-grape (~> 1.0.0)
88
101
  rack (>= 1.3.0)
89
102
  rack-accept
90
- virtus (>= 1.0.0)
91
- i18n (1.6.0)
103
+ i18n (1.8.2)
92
104
  concurrent-ruby (~> 1.0)
93
- ice_nine (0.11.2)
94
- loofah (2.3.1)
105
+ loofah (2.4.0)
95
106
  crass (~> 1.0.2)
96
107
  nokogiri (>= 1.5.9)
97
108
  mail (2.7.1)
@@ -102,78 +113,75 @@ GEM
102
113
  mimemagic (0.3.3)
103
114
  mini_mime (1.0.2)
104
115
  mini_portile2 (2.4.0)
105
- minitest (5.11.3)
106
- mustermann (1.0.3)
107
- mustermann-grape (1.0.0)
108
- mustermann (~> 1.0.0)
109
- nio4r (2.5.1)
110
- nokogiri (1.10.5)
116
+ minitest (5.14.0)
117
+ mustermann (1.1.1)
118
+ ruby2_keywords (~> 0.0.1)
119
+ mustermann-grape (1.0.1)
120
+ mustermann (>= 1.0.0)
121
+ nio4r (2.5.2)
122
+ nokogiri (1.10.7)
111
123
  mini_portile2 (~> 2.4.0)
112
- rack (2.0.7)
124
+ rack (2.1.1)
113
125
  rack-accept (0.4.5)
114
126
  rack (>= 0.4)
115
127
  rack-test (1.1.0)
116
128
  rack (>= 1.0, < 3)
117
- rails (6.0.0)
118
- actioncable (= 6.0.0)
119
- actionmailbox (= 6.0.0)
120
- actionmailer (= 6.0.0)
121
- actionpack (= 6.0.0)
122
- actiontext (= 6.0.0)
123
- actionview (= 6.0.0)
124
- activejob (= 6.0.0)
125
- activemodel (= 6.0.0)
126
- activerecord (= 6.0.0)
127
- activestorage (= 6.0.0)
128
- activesupport (= 6.0.0)
129
+ rails (6.0.2.1)
130
+ actioncable (= 6.0.2.1)
131
+ actionmailbox (= 6.0.2.1)
132
+ actionmailer (= 6.0.2.1)
133
+ actionpack (= 6.0.2.1)
134
+ actiontext (= 6.0.2.1)
135
+ actionview (= 6.0.2.1)
136
+ activejob (= 6.0.2.1)
137
+ activemodel (= 6.0.2.1)
138
+ activerecord (= 6.0.2.1)
139
+ activestorage (= 6.0.2.1)
140
+ activesupport (= 6.0.2.1)
129
141
  bundler (>= 1.3.0)
130
- railties (= 6.0.0)
142
+ railties (= 6.0.2.1)
131
143
  sprockets-rails (>= 2.0.0)
132
144
  rails-dom-testing (2.0.3)
133
145
  activesupport (>= 4.2.0)
134
146
  nokogiri (>= 1.6)
135
- rails-html-sanitizer (1.2.0)
136
- loofah (~> 2.2, >= 2.2.2)
137
- railties (6.0.0)
138
- actionpack (= 6.0.0)
139
- activesupport (= 6.0.0)
147
+ rails-html-sanitizer (1.3.0)
148
+ loofah (~> 2.3)
149
+ railties (6.0.2.1)
150
+ actionpack (= 6.0.2.1)
151
+ activesupport (= 6.0.2.1)
140
152
  method_source
141
153
  rake (>= 0.8.7)
142
154
  thor (>= 0.20.3, < 2.0)
143
- rake (12.3.3)
144
- rspec (3.8.0)
145
- rspec-core (~> 3.8.0)
146
- rspec-expectations (~> 3.8.0)
147
- rspec-mocks (~> 3.8.0)
148
- rspec-core (3.8.2)
149
- rspec-support (~> 3.8.0)
150
- rspec-expectations (3.8.4)
155
+ rake (13.0.1)
156
+ rspec (3.9.0)
157
+ rspec-core (~> 3.9.0)
158
+ rspec-expectations (~> 3.9.0)
159
+ rspec-mocks (~> 3.9.0)
160
+ rspec-core (3.9.1)
161
+ rspec-support (~> 3.9.1)
162
+ rspec-expectations (3.9.0)
151
163
  diff-lcs (>= 1.2.0, < 2.0)
152
- rspec-support (~> 3.8.0)
153
- rspec-mocks (3.8.1)
164
+ rspec-support (~> 3.9.0)
165
+ rspec-mocks (3.9.1)
154
166
  diff-lcs (>= 1.2.0, < 2.0)
155
- rspec-support (~> 3.8.0)
156
- rspec-support (3.8.2)
157
- sprockets (3.7.2)
167
+ rspec-support (~> 3.9.0)
168
+ rspec-support (3.9.2)
169
+ ruby2_keywords (0.0.2)
170
+ sprockets (4.0.0)
158
171
  concurrent-ruby (~> 1.0)
159
172
  rack (> 1, < 3)
160
173
  sprockets-rails (3.2.1)
161
174
  actionpack (>= 4.0)
162
175
  activesupport (>= 4.0)
163
176
  sprockets (>= 3.0.0)
164
- thor (0.20.3)
177
+ thor (1.0.1)
165
178
  thread_safe (0.3.6)
166
- tzinfo (1.2.5)
179
+ tzinfo (1.2.6)
167
180
  thread_safe (~> 0.1)
168
- virtus (1.0.5)
169
- axiom-types (~> 0.1)
170
- coercible (~> 1.0)
171
- descendants_tracker (~> 0.0, >= 0.0.3)
172
- equalizer (~> 0.0, >= 0.0.9)
173
181
  websocket-driver (0.7.1)
174
182
  websocket-extensions (>= 0.1.0)
175
183
  websocket-extensions (0.1.4)
176
- zeitwerk (2.1.10)
184
+ zeitwerk (2.2.2)
177
185
 
178
186
  PLATFORMS
179
187
  ruby
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![CircleCI](https://circleci.com/gh/EmCousin/grape_fast_jsonapi/tree/master.svg?style=svg)](https://circleci.com/gh/EmCousin/grape_fast_jsonapi/tree/master)
2
+
1
3
  # Grape::FastJsonapi
2
4
 
3
5
  Use [fast_jsonapi](https://github.com/Netflix/fast_jsonapi) with [Grape](https://github.com/ruby-grape/grape).
@@ -58,7 +58,7 @@ module Grape
58
58
  klass_name ||= begin
59
59
  object = object.first if object.is_a?(Array)
60
60
 
61
- object.class.name + 'Serializer'
61
+ (object.try(:model_name) || object.class).name + 'Serializer'
62
62
  end
63
63
 
64
64
  klass_name&.safe_constantize
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Grape
4
4
  module FastJsonapi
5
- VERSION = '0.2.4'.freeze
5
+ VERSION = '0.2.5'.freeze
6
6
  end
7
7
  end
@@ -11,6 +11,9 @@ describe Grape::Formatter::FastJsonapi do
11
11
  let(:blog_post) do
12
12
  BlogPost.new(id: 1, title: "Blog Post title", body: "Blog post body")
13
13
  end
14
+ let(:admin) do
15
+ UserAdmin.new(id: 1, first_name: 'Jean Luc', last_name: 'Picard', password: 'supersecretpassword', email: 'jeanluc@picard.com')
16
+ end
14
17
 
15
18
  describe '.call' do
16
19
  subject { described_class.call(object, env) }
@@ -28,6 +31,11 @@ describe Grape::Formatter::FastJsonapi do
28
31
  let(:another_user_serializer) { AnotherUserSerializer.new(object, {}) }
29
32
  let(:blog_post_serializer) { BlogPostSerializer.new(object, {}) }
30
33
 
34
+ context 'when the object has a model_name defined' do
35
+ let(:object) { admin }
36
+ it { is_expected.to eq ::Grape::Json.dump(user_serializer.serializable_hash) }
37
+ end
38
+
31
39
  context 'when the object is a active serializable model instance' do
32
40
  let(:object) { user }
33
41
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe Grape::FastJsonapi::VERSION do
4
- it { is_expected.to eq '0.2.4' }
4
+ it { is_expected.to eq '0.2.5' }
5
5
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UserAdmin
4
+ include ActiveModel::Serialization
5
+
6
+ attr_accessor :id, :first_name, :last_name, :password, :email
7
+
8
+ def initialize(params = {})
9
+ params.each do |k, v|
10
+ instance_variable_set("@#{k}", v) unless v.nil?
11
+ end
12
+ end
13
+
14
+ def attributes
15
+ {
16
+ 'id' => nil,
17
+ 'first_name' => nil,
18
+ 'last_name' => nil,
19
+ 'password' => nil,
20
+ 'email' => nil
21
+ }
22
+ end
23
+
24
+ def blog_post_ids
25
+ []
26
+ end
27
+
28
+ def model_name
29
+ ActiveModel::Name.new(User)
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_fast_jsonapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Cousin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-16 00:00:00.000000000 Z
11
+ date: 2020-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -94,6 +94,7 @@ files:
94
94
  - spec/spec_helper.rb
95
95
  - spec/support/models/blog_post.rb
96
96
  - spec/support/models/user.rb
97
+ - spec/support/models/user_admin.rb
97
98
  - spec/support/serializers/another_blog_post_serializer.rb
98
99
  - spec/support/serializers/another_user_serializer.rb
99
100
  - spec/support/serializers/blog_post_serializer.rb
@@ -128,6 +129,7 @@ test_files:
128
129
  - spec/spec_helper.rb
129
130
  - spec/support/models/blog_post.rb
130
131
  - spec/support/models/user.rb
132
+ - spec/support/models/user_admin.rb
131
133
  - spec/support/serializers/another_blog_post_serializer.rb
132
134
  - spec/support/serializers/another_user_serializer.rb
133
135
  - spec/support/serializers/blog_post_serializer.rb