shamu 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.rubocop.yml +5 -2
- data/Gemfile +2 -2
- data/Gemfile.lock +271 -0
- data/bin/rake +1 -1
- data/bin/rspec +1 -1
- data/circle.yml +4 -1
- data/lib/shamu/json_api/builder_methods/identifier.rb +1 -1
- data/lib/shamu/json_api/presenter.rb +1 -1
- data/lib/shamu/json_api/rails/controller.rb +7 -10
- data/lib/shamu/json_api/rails/responder.rb +4 -3
- data/lib/shamu/services/active_record_crud.rb +6 -1
- data/lib/shamu/services/error.rb +1 -1
- data/lib/shamu/services/request_support.rb +1 -1
- data/lib/shamu/services/result.rb +1 -1
- data/lib/shamu/version.rb +3 -3
- data/spec/lib/shamu/active_record_support.rb +3 -3
- data/spec/lib/shamu/entities/active_record_spec.rb +4 -4
- data/spec/lib/shamu/features/toggle_spec.rb +1 -1
- data/spec/lib/shamu/json_api/rails/controller_spec.rb +3 -3
- data/spec/lib/shamu/json_api/rails/responder_spec.rb +2 -0
- data/spec/lib/shamu/json_api/response_spec.rb +1 -1
- data/spec/lib/shamu/rails/features_spec.rb +1 -1
- data/spec/lib/shamu/services/active_record_crud_spec.rb +4 -1
- data/spec/lib/shamu/services/lazy_transform_spec.rb +3 -3
- data/spec/lib/shamu/services/request_support_spec.rb +1 -1
- data/spec/lib/shamu/services/service_spec.rb +4 -4
- data/spec/spec_helper.rb +4 -7
- metadata +3 -3
- data/lib/shamu/services/service_call_failed_error.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e88c67ffd19033c4fafc5933fb288f8538a709
|
4
|
+
data.tar.gz: daaf1a9d1f8dcd9746f335ef0fa6122aa7c9dfa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74934132c1023791f4fff72aa458ae8815c72138044bc33b0de60a39d71802e7c976f8409b675a7bb67644d377576370ed3e88a79c21bce48a6b8fbca698c7b3
|
7
|
+
data.tar.gz: '00095f967a07a2517a92721450ab45b2ee991d43f526fcde7b9bb853ea8f98dd4dd014f000d8ff46247e83be0cd62cb93513491df24b79f1a73be1c1f293b3e0'
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.3
|
3
3
|
|
4
4
|
|
5
5
|
Lint/AmbiguousRegexpLiteral:
|
@@ -51,6 +51,9 @@ Style/EmptyLinesAroundClassBody:
|
|
51
51
|
Style/EmptyLinesAroundModuleBody:
|
52
52
|
Enabled: false
|
53
53
|
|
54
|
+
Style/FrozenStringLiteralComment:
|
55
|
+
Enabled: false
|
56
|
+
|
54
57
|
Style/DoubleNegation:
|
55
58
|
Enabled: false
|
56
59
|
|
@@ -124,4 +127,4 @@ Style/CaseEquality:
|
|
124
127
|
Enabled: false
|
125
128
|
|
126
129
|
Style/WordArray:
|
127
|
-
Enabled: false
|
130
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org"
|
|
3
3
|
# Specify your gem"s dependencies in shamu.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem
|
6
|
+
gem "rake"
|
7
7
|
|
8
8
|
group :test do
|
9
9
|
gem "activerecord", "~> 5.0"
|
@@ -26,7 +26,7 @@ group :test do
|
|
26
26
|
gem "fuubar"
|
27
27
|
gem "yard"
|
28
28
|
gem "yard-activesupport-concern"
|
29
|
-
gem "simplecov"
|
29
|
+
gem "simplecov"
|
30
30
|
gem "ruby_gntp", "~> 0.3.4"
|
31
31
|
gem "awesome_print"
|
32
32
|
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,271 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shamu (0.0.13)
|
5
|
+
activemodel (>= 5.0)
|
6
|
+
activesupport (>= 5.0)
|
7
|
+
crc32 (~> 1)
|
8
|
+
listen (~> 3)
|
9
|
+
loofah (~> 2)
|
10
|
+
multi_json (~> 1.11.2)
|
11
|
+
rack (>= 1)
|
12
|
+
scorpion-ioc (~> 0.6)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
actioncable (5.0.3)
|
18
|
+
actionpack (= 5.0.3)
|
19
|
+
nio4r (>= 1.2, < 3.0)
|
20
|
+
websocket-driver (~> 0.6.1)
|
21
|
+
actionmailer (5.0.3)
|
22
|
+
actionpack (= 5.0.3)
|
23
|
+
actionview (= 5.0.3)
|
24
|
+
activejob (= 5.0.3)
|
25
|
+
mail (~> 2.5, >= 2.5.4)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
actionpack (5.0.3)
|
28
|
+
actionview (= 5.0.3)
|
29
|
+
activesupport (= 5.0.3)
|
30
|
+
rack (~> 2.0)
|
31
|
+
rack-test (~> 0.6.3)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
34
|
+
actionview (5.0.3)
|
35
|
+
activesupport (= 5.0.3)
|
36
|
+
builder (~> 3.1)
|
37
|
+
erubis (~> 2.7.0)
|
38
|
+
rails-dom-testing (~> 2.0)
|
39
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
40
|
+
activejob (5.0.3)
|
41
|
+
activesupport (= 5.0.3)
|
42
|
+
globalid (>= 0.3.6)
|
43
|
+
activemodel (5.0.3)
|
44
|
+
activesupport (= 5.0.3)
|
45
|
+
activerecord (5.0.3)
|
46
|
+
activemodel (= 5.0.3)
|
47
|
+
activesupport (= 5.0.3)
|
48
|
+
arel (~> 7.0)
|
49
|
+
activesupport (5.0.3)
|
50
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
51
|
+
i18n (~> 0.7)
|
52
|
+
minitest (~> 5.1)
|
53
|
+
tzinfo (~> 1.1)
|
54
|
+
arel (7.1.4)
|
55
|
+
ast (2.3.0)
|
56
|
+
awesome_print (1.7.0)
|
57
|
+
builder (3.2.3)
|
58
|
+
byebug (9.0.6)
|
59
|
+
codeclimate-test-reporter (1.0.8)
|
60
|
+
simplecov (<= 0.13)
|
61
|
+
coderay (1.1.1)
|
62
|
+
combustion (0.6.0)
|
63
|
+
activesupport (>= 3.0.0)
|
64
|
+
railties (>= 3.0.0)
|
65
|
+
thor (>= 0.14.6)
|
66
|
+
concurrent-ruby (1.0.5)
|
67
|
+
crc32 (1.0.1)
|
68
|
+
diff-lcs (1.3)
|
69
|
+
docile (1.1.5)
|
70
|
+
erubis (2.7.0)
|
71
|
+
ffi (1.9.18)
|
72
|
+
formatador (0.2.5)
|
73
|
+
fuubar (2.2.0)
|
74
|
+
rspec-core (~> 3.0)
|
75
|
+
ruby-progressbar (~> 1.4)
|
76
|
+
globalid (0.4.0)
|
77
|
+
activesupport (>= 4.2.0)
|
78
|
+
guard (2.12.9)
|
79
|
+
formatador (>= 0.2.4)
|
80
|
+
listen (>= 2.7, <= 4.0)
|
81
|
+
lumberjack (~> 1.0)
|
82
|
+
nenv (~> 0.1)
|
83
|
+
notiffany (~> 0.0)
|
84
|
+
pry (>= 0.9.12)
|
85
|
+
shellany (~> 0.0)
|
86
|
+
thor (>= 0.18.1)
|
87
|
+
guard-compat (1.2.1)
|
88
|
+
guard-rspec (4.7.3)
|
89
|
+
guard (~> 2.1)
|
90
|
+
guard-compat (~> 1.1)
|
91
|
+
rspec (>= 2.99.0, < 4.0)
|
92
|
+
guard-rubocop (1.2.0)
|
93
|
+
guard (~> 2.0)
|
94
|
+
rubocop (~> 0.20)
|
95
|
+
i18n (0.8.1)
|
96
|
+
json (2.1.0)
|
97
|
+
kaminari (0.16.3)
|
98
|
+
actionpack (>= 3.0.0)
|
99
|
+
activesupport (>= 3.0.0)
|
100
|
+
listen (3.1.5)
|
101
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
102
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
103
|
+
ruby_dep (~> 1.2)
|
104
|
+
loofah (2.0.3)
|
105
|
+
nokogiri (>= 1.5.9)
|
106
|
+
lumberjack (1.0.12)
|
107
|
+
mail (2.6.5)
|
108
|
+
mime-types (>= 1.16, < 4)
|
109
|
+
method_source (0.8.2)
|
110
|
+
mime-types (3.1)
|
111
|
+
mime-types-data (~> 3.2015)
|
112
|
+
mime-types-data (3.2016.0521)
|
113
|
+
mini_portile2 (2.1.0)
|
114
|
+
minitest (5.10.2)
|
115
|
+
multi_json (1.11.3)
|
116
|
+
nenv (0.3.0)
|
117
|
+
nio4r (2.0.0)
|
118
|
+
nokogiri (1.7.2)
|
119
|
+
mini_portile2 (~> 2.1.0)
|
120
|
+
notiffany (0.1.1)
|
121
|
+
nenv (~> 0.1)
|
122
|
+
shellany (~> 0.0)
|
123
|
+
parser (2.4.0.0)
|
124
|
+
ast (~> 2.2)
|
125
|
+
powerpack (0.1.1)
|
126
|
+
pry (0.10.4)
|
127
|
+
coderay (~> 1.1.0)
|
128
|
+
method_source (~> 0.8.1)
|
129
|
+
slop (~> 3.4)
|
130
|
+
pry-byebug (3.4.2)
|
131
|
+
byebug (~> 9.0)
|
132
|
+
pry (~> 0.10)
|
133
|
+
rack (2.0.3)
|
134
|
+
rack-test (0.6.3)
|
135
|
+
rack (>= 1.0)
|
136
|
+
rails (5.0.3)
|
137
|
+
actioncable (= 5.0.3)
|
138
|
+
actionmailer (= 5.0.3)
|
139
|
+
actionpack (= 5.0.3)
|
140
|
+
actionview (= 5.0.3)
|
141
|
+
activejob (= 5.0.3)
|
142
|
+
activemodel (= 5.0.3)
|
143
|
+
activerecord (= 5.0.3)
|
144
|
+
activesupport (= 5.0.3)
|
145
|
+
bundler (>= 1.3.0, < 2.0)
|
146
|
+
railties (= 5.0.3)
|
147
|
+
sprockets-rails (>= 2.0.0)
|
148
|
+
rails-dom-testing (2.0.3)
|
149
|
+
activesupport (>= 4.2.0)
|
150
|
+
nokogiri (>= 1.6)
|
151
|
+
rails-html-sanitizer (1.0.3)
|
152
|
+
loofah (~> 2.0)
|
153
|
+
railties (5.0.3)
|
154
|
+
actionpack (= 5.0.3)
|
155
|
+
activesupport (= 5.0.3)
|
156
|
+
method_source
|
157
|
+
rake (>= 0.8.7)
|
158
|
+
thor (>= 0.18.1, < 2.0)
|
159
|
+
rainbow (2.2.2)
|
160
|
+
rake
|
161
|
+
rake (12.0.0)
|
162
|
+
rb-fsevent (0.9.8)
|
163
|
+
rb-inotify (0.9.8)
|
164
|
+
ffi (>= 0.5.0)
|
165
|
+
responders (2.1.2)
|
166
|
+
railties (>= 4.2.0, < 5.1)
|
167
|
+
rspec (3.6.0)
|
168
|
+
rspec-core (~> 3.6.0)
|
169
|
+
rspec-expectations (~> 3.6.0)
|
170
|
+
rspec-mocks (~> 3.6.0)
|
171
|
+
rspec-core (3.6.0)
|
172
|
+
rspec-support (~> 3.6.0)
|
173
|
+
rspec-expectations (3.6.0)
|
174
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
175
|
+
rspec-support (~> 3.6.0)
|
176
|
+
rspec-its (1.2.0)
|
177
|
+
rspec-core (>= 3.0.0)
|
178
|
+
rspec-expectations (>= 3.0.0)
|
179
|
+
rspec-mocks (3.6.0)
|
180
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
181
|
+
rspec-support (~> 3.6.0)
|
182
|
+
rspec-rails (3.6.0)
|
183
|
+
actionpack (>= 3.0)
|
184
|
+
activesupport (>= 3.0)
|
185
|
+
railties (>= 3.0)
|
186
|
+
rspec-core (~> 3.6.0)
|
187
|
+
rspec-expectations (~> 3.6.0)
|
188
|
+
rspec-mocks (~> 3.6.0)
|
189
|
+
rspec-support (~> 3.6.0)
|
190
|
+
rspec-support (3.6.0)
|
191
|
+
rspec-wait (0.0.9)
|
192
|
+
rspec (>= 3, < 4)
|
193
|
+
rspec_junit_formatter (0.2.3)
|
194
|
+
builder (< 4)
|
195
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
196
|
+
rubocop (0.39.0)
|
197
|
+
parser (>= 2.3.0.7, < 3.0)
|
198
|
+
powerpack (~> 0.1)
|
199
|
+
rainbow (>= 1.99.1, < 3.0)
|
200
|
+
ruby-progressbar (~> 1.7)
|
201
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
202
|
+
ruby-progressbar (1.8.1)
|
203
|
+
ruby_dep (1.5.0)
|
204
|
+
ruby_gntp (0.3.4)
|
205
|
+
scorpion-ioc (0.6.0)
|
206
|
+
rails (>= 4.0)
|
207
|
+
shellany (0.0.1)
|
208
|
+
simplecov (0.13.0)
|
209
|
+
docile (~> 1.1.0)
|
210
|
+
json (>= 1.8, < 3)
|
211
|
+
simplecov-html (~> 0.10.0)
|
212
|
+
simplecov-html (0.10.1)
|
213
|
+
slop (3.6.0)
|
214
|
+
spring (2.0.1)
|
215
|
+
activesupport (>= 4.2)
|
216
|
+
sprockets (3.7.1)
|
217
|
+
concurrent-ruby (~> 1.0)
|
218
|
+
rack (> 1, < 3)
|
219
|
+
sprockets-rails (3.2.0)
|
220
|
+
actionpack (>= 4.0)
|
221
|
+
activesupport (>= 4.0)
|
222
|
+
sprockets (>= 3.0.0)
|
223
|
+
sqlite3 (1.3.13)
|
224
|
+
thor (0.19.4)
|
225
|
+
thread_safe (0.3.6)
|
226
|
+
tzinfo (1.2.3)
|
227
|
+
thread_safe (~> 0.1)
|
228
|
+
unicode-display_width (1.2.1)
|
229
|
+
websocket-driver (0.6.5)
|
230
|
+
websocket-extensions (>= 0.1.0)
|
231
|
+
websocket-extensions (0.1.2)
|
232
|
+
yard (0.9.9)
|
233
|
+
yard-activesupport-concern (0.0.1)
|
234
|
+
yard (>= 0.8)
|
235
|
+
|
236
|
+
PLATFORMS
|
237
|
+
ruby
|
238
|
+
|
239
|
+
DEPENDENCIES
|
240
|
+
actionpack (~> 5.0)
|
241
|
+
activerecord (~> 5.0)
|
242
|
+
awesome_print
|
243
|
+
bundler (~> 1.6)
|
244
|
+
byebug
|
245
|
+
codeclimate-test-reporter
|
246
|
+
combustion (~> 0.5)
|
247
|
+
fuubar
|
248
|
+
guard (~> 2.12.8)
|
249
|
+
guard-rspec
|
250
|
+
guard-rubocop
|
251
|
+
i18n (~> 0.7)
|
252
|
+
kaminari (~> 0.16.3)
|
253
|
+
pry-byebug
|
254
|
+
rake
|
255
|
+
responders (~> 2.1.2)
|
256
|
+
rspec (~> 3.00)
|
257
|
+
rspec-its
|
258
|
+
rspec-rails
|
259
|
+
rspec-wait
|
260
|
+
rspec_junit_formatter (~> 0.2.2)
|
261
|
+
rubocop (~> 0.39.0)
|
262
|
+
ruby_gntp (~> 0.3.4)
|
263
|
+
shamu!
|
264
|
+
simplecov
|
265
|
+
spring
|
266
|
+
sqlite3 (~> 1.3.11)
|
267
|
+
yard
|
268
|
+
yard-activesupport-concern
|
269
|
+
|
270
|
+
BUNDLED WITH
|
271
|
+
1.14.6
|
data/bin/rake
CHANGED
data/bin/rspec
CHANGED
data/circle.yml
CHANGED
@@ -73,8 +73,8 @@ module Shamu
|
|
73
73
|
if result.valid?
|
74
74
|
if result.entity
|
75
75
|
status ||= case request.method
|
76
|
-
when
|
77
|
-
when
|
76
|
+
when "POST" then :created
|
77
|
+
when "DELETE" then :no_content
|
78
78
|
else :ok
|
79
79
|
end
|
80
80
|
|
@@ -125,8 +125,6 @@ module Shamu
|
|
125
125
|
response.as_json
|
126
126
|
end
|
127
127
|
|
128
|
-
private
|
129
|
-
|
130
128
|
# @!visibility public
|
131
129
|
#
|
132
130
|
# Add page-based pagination links for the resources to the builder.
|
@@ -230,7 +228,8 @@ module Shamu
|
|
230
228
|
# @return [JsonApi::Context] the builder context honoring any filter
|
231
229
|
# parameters sent by the client.
|
232
230
|
def json_context( fields: :not_set, namespaces: :not_set, presenters: :not_set )
|
233
|
-
Shamu::JsonApi::Context.new
|
231
|
+
Shamu::JsonApi::Context.new \
|
232
|
+
fields: fields == :not_set ? json_context_fields : fields,
|
234
233
|
namespaces: namespaces == :not_set ? json_context_namespaces : namespaces,
|
235
234
|
presenters: presenters == :not_set ? json_context_presenters : presenters
|
236
235
|
end
|
@@ -245,15 +244,13 @@ module Shamu
|
|
245
244
|
payload = map_json_resource_payload( json_request_payload )
|
246
245
|
|
247
246
|
request.params.each do |key, value|
|
248
|
-
if ID_PATTERN =~ key
|
249
|
-
payload[ key.to_sym ] ||= value
|
250
|
-
end
|
247
|
+
payload[ key.to_sym ] ||= value if ID_PATTERN =~ key
|
251
248
|
end
|
252
249
|
|
253
250
|
payload
|
254
251
|
end
|
255
252
|
|
256
|
-
def map_json_resource_payload( resource )
|
253
|
+
def map_json_resource_payload( resource ) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
257
254
|
payload = resource[ :attributes ] ? resource[ :attributes ].dup : {}
|
258
255
|
payload[ :id ] = resource[ :id ] if resource.key?( :id )
|
259
256
|
|
@@ -262,7 +259,7 @@ module Shamu
|
|
262
259
|
attr_key = "#{ key.to_s.singularize }_id"
|
263
260
|
|
264
261
|
if value[ :data ].is_a?( Array )
|
265
|
-
attr_key +=
|
262
|
+
attr_key += "s" if value[ :data ].is_a?( Array )
|
266
263
|
|
267
264
|
payload[ attr_key.to_sym ] = value[ :data ].map { |d| d[ :id ] }
|
268
265
|
payload[ key ] = value[ :data ].map { |d| map_json_resource_payload( d ) }
|
@@ -35,12 +35,13 @@ module Shamu
|
|
35
35
|
controller.json_resource resource, **given_options
|
36
36
|
end
|
37
37
|
|
38
|
-
super json, given_options
|
38
|
+
super json.to_json, given_options
|
39
39
|
end
|
40
40
|
|
41
41
|
# @visibility private
|
42
42
|
def display_errors
|
43
|
-
controller.render format => controller.json_validation_errors( resource_errors ),
|
43
|
+
controller.render format => controller.json_validation_errors( resource_errors ).to_json,
|
44
|
+
:status => :unprocessable_entity
|
44
45
|
end
|
45
46
|
|
46
47
|
private
|
@@ -52,4 +53,4 @@ module Shamu
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
55
|
-
end
|
56
|
+
end
|
@@ -163,6 +163,8 @@ module Shamu
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
+
# rubocop:disable Metrics/MethodLength
|
167
|
+
|
166
168
|
# Define an change `method` on the service that takes the id of the
|
167
169
|
# resource to modify and a corresponding {Request} parameter.
|
168
170
|
#
|
@@ -195,6 +197,9 @@ module Shamu
|
|
195
197
|
end
|
196
198
|
end
|
197
199
|
|
200
|
+
# rubocop:enabled Metrics/MethodLength
|
201
|
+
|
202
|
+
|
198
203
|
# Define an `update` method on the service that takes the id of the
|
199
204
|
# resource to update and a {Request} parameter. After applying the
|
200
205
|
# changes the record is persisted and the updated entity result is
|
@@ -252,7 +257,7 @@ module Shamu
|
|
252
257
|
define_method :find do |id|
|
253
258
|
wrap_not_found do
|
254
259
|
record = yield( id )
|
255
|
-
authorize! :read,
|
260
|
+
authorize! :read, build_entity( record )
|
256
261
|
end
|
257
262
|
end
|
258
263
|
else
|
data/lib/shamu/services/error.rb
CHANGED
@@ -27,7 +27,7 @@ module Shamu
|
|
27
27
|
def initialize( result )
|
28
28
|
@result = result
|
29
29
|
|
30
|
-
super translate( :service_request_failed, errors: result.errors.full_messages.join(
|
30
|
+
super translate( :service_request_failed, errors: result.errors.full_messages.join( ", " ) )
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/shamu/version.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Shamu
|
3
3
|
# The primary version number
|
4
|
-
VERSION_NUMBER = "0.0.
|
4
|
+
VERSION_NUMBER = "0.0.13"
|
5
5
|
|
6
6
|
# Version suffix such as 'beta' or 'alpha'
|
7
|
-
VERSION_SUFFIX = ""
|
7
|
+
VERSION_SUFFIX = ""
|
8
8
|
|
9
9
|
# Published version number
|
10
|
-
VERSION = "#{ VERSION_NUMBER }#{ VERSION_SUFFIX }"
|
10
|
+
VERSION = "#{ VERSION_NUMBER }#{ VERSION_SUFFIX }"
|
11
11
|
end
|
@@ -4,8 +4,8 @@ require "shamu/entities/active_record"
|
|
4
4
|
module ActiveRecordSpec
|
5
5
|
class Favorite < ::ActiveRecord::Base
|
6
6
|
self.table_name = "favorites"
|
7
|
-
extend Shamu::Entities::ActiveRecord
|
8
|
-
include Shamu::Entities::ActiveRecordSoftDestroy
|
7
|
+
extend ::Shamu::Entities::ActiveRecord
|
8
|
+
include ::Shamu::Entities::ActiveRecordSoftDestroy
|
9
9
|
|
10
10
|
scope :by_name, ->( name ) { where( name: name ) }
|
11
11
|
scope :by_label, ->( label ) { where( label: label ) }
|
@@ -29,4 +29,4 @@ module ActiveRecordSpec
|
|
29
29
|
class FavoriteScope < Shamu::Entities::ListScope
|
30
30
|
attribute :name
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "shamu/entities/active_record"
|
3
2
|
require "active_record"
|
3
|
+
require "shamu/entities/active_record"
|
4
4
|
|
5
5
|
describe Shamu::Entities::ActiveRecord do
|
6
6
|
use_active_record
|
@@ -48,8 +48,8 @@ describe Shamu::Entities::ActiveRecord do
|
|
48
48
|
scope = klass.new( since: since_date, until: until_date )
|
49
49
|
relation = ActiveRecordSpec::Favorite.by_list_scope( scope )
|
50
50
|
|
51
|
-
expect( relation.
|
52
|
-
expect( relation.
|
51
|
+
expect( relation.where_clause.any? { |w| w.left.name == :since } ).to be_truthy
|
52
|
+
expect( relation.where_clause.any? { |w| w.left.name == :until } ).to be_truthy
|
53
53
|
end
|
54
54
|
|
55
55
|
it "sorts by attribute" do
|
@@ -63,4 +63,4 @@ describe Shamu::Entities::ActiveRecord do
|
|
63
63
|
expect( relation.order_values.any? { |o| o.expr.name == :name } ).to be_truthy
|
64
64
|
end
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|
@@ -103,13 +103,13 @@ describe JsonApiControllerSpec::ResourcesController, type: :controller do
|
|
103
103
|
describe "#render_resource" do
|
104
104
|
it "adds Location header" do
|
105
105
|
get :show, params: { id: 1 }
|
106
|
-
expect( response.headers ).to include
|
106
|
+
expect( response.headers ).to include "Location"
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
110
|
describe "#render_result" do
|
111
111
|
it "returns status created on #create" do
|
112
|
-
post :create, params: { name:
|
112
|
+
post :create, params: { name: "example" }
|
113
113
|
expect( response.status ).to eq 201
|
114
114
|
expect( response.body ).to include "data"
|
115
115
|
end
|
@@ -203,7 +203,7 @@ describe JsonApiControllerSpec::ResourcesController, type: :controller do
|
|
203
203
|
},
|
204
204
|
relationships: {
|
205
205
|
book: {
|
206
|
-
data: { type: "book", id: "5", attributes: { title: "Bibliography" }
|
206
|
+
data: { type: "book", id: "5", attributes: { title: "Bibliography" } }
|
207
207
|
},
|
208
208
|
stores: {
|
209
209
|
data: [
|
@@ -14,6 +14,8 @@ module JsonApiResponderSpec
|
|
14
14
|
class ResourcesController < ActionController::Base
|
15
15
|
include Shamu::JsonApi::Rails::Controller
|
16
16
|
|
17
|
+
public :json_resource, :json_collection, :json_validation_errors, :json_error
|
18
|
+
|
17
19
|
respond_to :json_api, :json
|
18
20
|
self.responder = Responder
|
19
21
|
|
@@ -69,4 +69,4 @@ describe Shamu::JsonApi::Response do
|
|
69
69
|
expect( response.compile ).to include errors: include( hash_including( source: { pointer: "/data/attributes/title" } ) ) # rubocop:disable Metrics/LineLength
|
70
70
|
expect( response.compile ).to include errors: include( hash_including( source: { pointer: "/data" } ) )
|
71
71
|
end
|
72
|
-
end
|
72
|
+
end
|
@@ -39,7 +39,7 @@ describe Shamu::Rails::Features, type: :controller do
|
|
39
39
|
controller.render plain: ""
|
40
40
|
end
|
41
41
|
|
42
|
-
get :show, params: { id: 1, Shamu::Features::EnvStore::RACK_PARAMS_KEY => override }
|
42
|
+
get :show, params: { id: 1, Shamu::Features::EnvStore::RACK_PARAMS_KEY => override }
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
@@ -298,7 +298,10 @@ describe Shamu::Services::ActiveRecordCrud do
|
|
298
298
|
it "yields to block if block given" do
|
299
299
|
find_klass = Class.new( klass )
|
300
300
|
expect do |b|
|
301
|
-
find_klass.find
|
301
|
+
find_klass.find do |_|
|
302
|
+
b.to_proc.call
|
303
|
+
ActiveRecordSpec::Favorite.all.first
|
304
|
+
end
|
302
305
|
scorpion.new( find_klass ).find( entity.id )
|
303
306
|
end.to yield_control
|
304
307
|
end
|
@@ -4,12 +4,12 @@ describe Shamu::Services::LazyTransform do
|
|
4
4
|
let( :source ) { [ 1, 2, 3 ] }
|
5
5
|
|
6
6
|
def transformer( &block )
|
7
|
-
->( records )
|
7
|
+
->( records ) do
|
8
8
|
records.map do |r|
|
9
9
|
yield
|
10
10
|
r
|
11
11
|
end
|
12
|
-
|
12
|
+
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "short-circuits count" do
|
@@ -69,7 +69,7 @@ describe Shamu::Services::LazyTransform do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "yields transformed values" do
|
72
|
-
transformed = Shamu::Services::LazyTransform.new( source ) { |vs| vs.map { |v| v * v
|
72
|
+
transformed = Shamu::Services::LazyTransform.new( source ) { |vs| vs.map { |v| v * v } }
|
73
73
|
expect( transformed.to_a ).to eq [ 1, 4, 9 ]
|
74
74
|
end
|
75
75
|
|
@@ -81,7 +81,7 @@ describe Shamu::Services::RequestSupport do
|
|
81
81
|
end.request_class( :change )
|
82
82
|
end.to raise_error Shamu::Services::IncompleteSetupError, /Request/
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
it "singularizes service namespace" do
|
86
86
|
service = scorpion.new RequestSupportSpec::UsersService
|
87
87
|
expect( service.request_class( :change ) ).to be RequestSupportSpec::UserRequest::Change
|
@@ -54,11 +54,11 @@ describe Shamu::Services::Service do
|
|
54
54
|
let( :service ) { scorpion.new ServiceSpec::Service }
|
55
55
|
|
56
56
|
def transformer( &block )
|
57
|
-
->( records )
|
57
|
+
->( records ) do
|
58
58
|
records.map do |r|
|
59
59
|
yield || r
|
60
60
|
end
|
61
|
-
|
61
|
+
end
|
62
62
|
end
|
63
63
|
|
64
64
|
|
@@ -136,7 +136,7 @@ describe Shamu::Services::Service do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it "matches on a custom field" do
|
139
|
-
list = service.entity_lookup_list( records, [record.amount], ServiceSpec::NullEntity, match: :amount ) do |records|
|
139
|
+
list = service.entity_lookup_list( records, [record.amount], ServiceSpec::NullEntity, match: :amount ) do |records| # rubocop:disable Metrics/LineLength
|
140
140
|
records.map { |r| scorpion.fetch ServiceSpec::Entity, { record: r }, {} }
|
141
141
|
end
|
142
142
|
|
@@ -145,7 +145,7 @@ describe Shamu::Services::Service do
|
|
145
145
|
|
146
146
|
it "matches with a custom proc" do
|
147
147
|
matcher = ->( record ) { record.amount }
|
148
|
-
list = service.entity_lookup_list( records, [record.amount], ServiceSpec::NullEntity, match: matcher ) do |records|
|
148
|
+
list = service.entity_lookup_list( records, [record.amount], ServiceSpec::NullEntity, match: matcher ) do |records| # rubocop:disable Metrics/LineLength
|
149
149
|
records.map { |r| scorpion.fetch ServiceSpec::Entity, { record: r }, {} }
|
150
150
|
end
|
151
151
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require "simplecov"
|
2
|
-
|
3
|
-
|
4
|
-
CodeClimate::TestReporter.start
|
5
|
-
else
|
6
|
-
SimpleCov.start
|
7
|
-
end
|
2
|
+
SimpleCov.start
|
3
|
+
|
8
4
|
require "pry"
|
9
5
|
require "bundler/setup"
|
10
6
|
|
@@ -24,7 +20,8 @@ RSpec.configure do |config|
|
|
24
20
|
|
25
21
|
config.order = "random"
|
26
22
|
|
27
|
-
config.filter_gems_from_backtrace "activesupport", "actionpack", "actionview", "scorpion-ioc", "rspec-wait",
|
23
|
+
config.filter_gems_from_backtrace "activesupport", "actionpack", "actionview", "scorpion-ioc", "rspec-wait",
|
24
|
+
"rspec-core", "rspec", "rspec-support", "rspec-expectations"
|
28
25
|
|
29
26
|
config.filter_run focus: true
|
30
27
|
config.filter_run_excluding :broken => true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shamu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- ".yardopts"
|
210
210
|
- CHANGELOG.md
|
211
211
|
- Gemfile
|
212
|
+
- Gemfile.lock
|
212
213
|
- Guardfile
|
213
214
|
- LABELS.md
|
214
215
|
- LICENSE
|
@@ -353,7 +354,6 @@ files:
|
|
353
354
|
- lib/shamu/services/request_support.rb
|
354
355
|
- lib/shamu/services/result.rb
|
355
356
|
- lib/shamu/services/service.rb
|
356
|
-
- lib/shamu/services/service_call_failed_error.rb
|
357
357
|
- lib/shamu/sessions.rb
|
358
358
|
- lib/shamu/sessions/README.md
|
359
359
|
- lib/shamu/sessions/cookie_store.rb
|