locomotivecms_wagon 2.0.0.pre.alpha.1 → 2.0.0.pre.alpha.2

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: 8531aa80c7fdee5e9e863387e699827b4ae7ae18
4
- data.tar.gz: 6f6efe6257adde660654dc4b931a624a1d094520
3
+ metadata.gz: 899fd4c2ed0a4643d64986400f4364f9122a095b
4
+ data.tar.gz: e32bb56243302ce2cec3a665515f44f35a2ba377
5
5
  SHA512:
6
- metadata.gz: 58bbaf91c7ee0dfeb1271e6424e247e1a77100325248756ceeb921e3d1f3a3d3503ae8477cf89e6426d5c47f44fbb098d55c1791760628aa833e7f07e2c9868a
7
- data.tar.gz: 4da3d8c28daf5ecc343f66240b5e15f99bc455d3faa4a746a73d70b899733de98de14adec8331979d3961b4cd56f669a7390e19cd2c3e64b9c3c6f0724014119
6
+ metadata.gz: e7e5423622eadcdf38ff4a033470ce27cba8c8827c0728f66a53440549c18e9be6a95616dbbd5cb6fc6c69746b0d7f7a99eb1f4fb49d2be45a2e228c45c12dda
7
+ data.tar.gz: 11befc5b800ab97d419da76d0010170cc81cc632d373fb3614ee4de20c4791da23093cdf4109e85f278406ea692d1448cc7661d0d24ce7320960084a8e6fc59f
data/Gemfile CHANGED
@@ -21,12 +21,14 @@ gem 'therubyracer'
21
21
  # gem 'locomotivecms_steam', path: '../in_progress/steam', require: false
22
22
  # gem 'locomotivecms_common', path: '../in_progress/common', require: false
23
23
 
24
+ group :development, :test do
25
+ gem 'pry-byebug', '~> 3.1.0'
26
+ end
27
+
24
28
  group :test do
25
29
  gem 'rspec', '~> 3.2.0'
26
30
  gem 'json_spec', '~> 1.1.4'
27
31
 
28
- gem 'pry-byebug', '~> 3.1.0'
29
-
30
32
  gem 'webmock'
31
33
  gem 'vcr'
32
34
 
@@ -44,7 +44,7 @@ module Locomotive::Wagon
44
44
  private
45
45
 
46
46
  def remote_fields_for(slug)
47
- (remote_entities[slug].try(:fields) || []).map { |f| f[:name] }
47
+ (remote_entities[slug].try(:fields) || []).map { |f| f['name'] }
48
48
  end
49
49
 
50
50
  def remote_entities
@@ -1,5 +1,4 @@
1
1
  require 'tempfile'
2
- require 'pry'
3
2
 
4
3
  module Locomotive::Wagon
5
4
 
@@ -7,19 +7,27 @@ module Locomotive::Wagon
7
7
  def to_hash
8
8
  {}.tap do |hash|
9
9
  __attributes__.each do |name|
10
- if !(value = self.send(name)).nil?
11
- if value.is_a?(Array) && value.first.respond_to?(:__attributes__)
12
- hash[name] = value.map(&:to_hash)
13
- elsif value.respond_to?(:translations)
14
- hash[name] = value.translations unless value.translations.empty?
15
- else
16
- hash[name] = value
17
- end
18
- end
10
+ value = self.public_send(name)
11
+
12
+ next if value.nil?
13
+
14
+ hash[name] = prepare_value_for_hash(value)
19
15
  end
20
16
  end
21
17
  end
22
18
 
19
+ def prepare_value_for_hash(value)
20
+ if value.is_a?(Array) && value.first.respond_to?(:__attributes__)
21
+ value.map(&:to_hash)
22
+ elsif value.is_a?(Array) && value.empty?
23
+ nil # reset the array
24
+ elsif value.respond_to?(:translations)
25
+ !value.translations.empty? ? value.translations : nil
26
+ else
27
+ value
28
+ end
29
+ end
30
+
23
31
  end
24
32
 
25
33
  end
@@ -40,6 +40,7 @@ module Locomotive
40
40
  end
41
41
 
42
42
  def decorate_file_field(value)
43
+ return nil if value.nil? || value.filename.blank?
43
44
  asset_io(File.join(value.base, value.filename))
44
45
  end
45
46
 
@@ -1,5 +1,5 @@
1
1
  module Locomotive
2
2
  module Wagon
3
- VERSION = '2.0.0-alpha.1'
3
+ VERSION = '2.0.0-alpha.2'
4
4
  end
5
5
  end
@@ -1,214 +1,5 @@
1
1
  ---
2
2
  http_interactions:
3
- - request:
4
- method: post
5
- uri: http://localhost:3000/locomotive/api/v3/tokens.json?email=john@doe.net&password=asimplepassword
6
- body:
7
- encoding: UTF-8
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- Content-Length:
13
- - '0'
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- User-Agent:
17
- - Ruby
18
- response:
19
- status:
20
- code: 401
21
- message: Unauthorized
22
- headers:
23
- Content-Type:
24
- - application/json
25
- X-Error-Detail:
26
- - Invalid email or password.
27
- Content-Length:
28
- - '40'
29
- Cache-Control:
30
- - no-cache
31
- X-Request-Id:
32
- - fb0a7852-232e-4c8b-8ab3-456cfbab2078
33
- X-Runtime:
34
- - '0.664468'
35
- Connection:
36
- - keep-alive
37
- Server:
38
- - thin
39
- body:
40
- encoding: UTF-8
41
- string: '{"message":"Invalid email or password."}'
42
- http_version:
43
- recorded_at: Wed, 08 Apr 2015 09:48:56 GMT
44
- - request:
45
- method: post
46
- uri: http://localhost:3000/locomotive/api/v3/my_account.json?account%5Bemail%5D=john@doe.net&account%5Bname%5D=John&account%5Bpassword%5D=asimplepassword
47
- body:
48
- encoding: UTF-8
49
- string: ''
50
- headers:
51
- Accept:
52
- - application/json
53
- Content-Length:
54
- - '0'
55
- Accept-Encoding:
56
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
- User-Agent:
58
- - Ruby
59
- response:
60
- status:
61
- code: 201
62
- message: Created
63
- headers:
64
- Content-Type:
65
- - application/json
66
- Content-Length:
67
- - '411'
68
- Etag:
69
- - W/"d5f22e786ad106187b381c8d685a3e92"
70
- Cache-Control:
71
- - max-age=0, private, must-revalidate
72
- X-Request-Id:
73
- - aee412b7-82df-4978-bd1f-f8f3314ead2d
74
- X-Runtime:
75
- - '0.061719'
76
- Connection:
77
- - keep-alive
78
- Server:
79
- - thin
80
- body:
81
- encoding: UTF-8
82
- string: '{"_id":"5524f98864696407ae100000","created_at":"2015-04-08T09:48:56Z","updated_at":"2015-04-08T09:48:56Z","name":"John","email":"john@doe.net","locale":"en","encrypted_password":"39f8358678144ef6715b9420a7a65706552272fb","password_salt":"sV9PWhfxDRy4b1pj6jLd","api_key":"8e5586fe34c5628d8e1ace2a8a750ae922ae2884","super_admin":false,"password":"asimplepassword","password_confirmation":null,"local_admin":false}'
83
- http_version:
84
- recorded_at: Wed, 08 Apr 2015 09:48:56 GMT
85
- - request:
86
- method: post
87
- uri: http://localhost:3000/locomotive/api/v3/tokens.json?email=admin@locomotivecms.com&password=locomotive
88
- body:
89
- encoding: UTF-8
90
- string: ''
91
- headers:
92
- Accept:
93
- - application/json
94
- Content-Length:
95
- - '0'
96
- Accept-Encoding:
97
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
98
- User-Agent:
99
- - Ruby
100
- response:
101
- status:
102
- code: 201
103
- message: Created
104
- headers:
105
- Content-Type:
106
- - application/json
107
- Content-Length:
108
- - '32'
109
- Etag:
110
- - W/"333586de1d24c181814b7fd1fc093943"
111
- Cache-Control:
112
- - max-age=0, private, must-revalidate
113
- X-Request-Id:
114
- - 7b0c6596-42b7-4466-94a3-5347b7fc9234
115
- X-Runtime:
116
- - '0.019200'
117
- Connection:
118
- - keep-alive
119
- Server:
120
- - thin
121
- body:
122
- encoding: UTF-8
123
- string: '{"token":"by7uUTBWyg5LzGTfyykK"}'
124
- http_version:
125
- recorded_at: Wed, 08 Apr 2015 10:50:39 GMT
126
- - request:
127
- method: get
128
- uri: http://localhost:3000/locomotive/api/v3/my_account.json?auth_token=by7uUTBWyg5LzGTfyykK
129
- body:
130
- encoding: US-ASCII
131
- string: ''
132
- headers:
133
- Accept:
134
- - application/json
135
- X-Locomotive-Account-Email:
136
- - admin@locomotivecms.com
137
- X-Locomotive-Account-Token:
138
- - by7uUTBWyg5LzGTfyykK
139
- Accept-Encoding:
140
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
141
- User-Agent:
142
- - Ruby
143
- response:
144
- status:
145
- code: 200
146
- message: OK
147
- headers:
148
- Content-Type:
149
- - application/json
150
- Content-Length:
151
- - '409'
152
- Etag:
153
- - W/"de9362bbb5bdda2f08c588cb8bccc53e"
154
- Cache-Control:
155
- - max-age=0, private, must-revalidate
156
- X-Request-Id:
157
- - 38706597-257a-401c-9769-c8b9d27c237a
158
- X-Runtime:
159
- - '0.036344'
160
- Connection:
161
- - keep-alive
162
- Server:
163
- - thin
164
- body:
165
- encoding: UTF-8
166
- string: '{"_id":"5524f99e646964184d000000","created_at":"2015-04-08T09:49:18Z","updated_at":"2015-04-08T09:49:18Z","name":"Admin","email":"admin@locomotivecms.com","locale":"en","encrypted_password":"a8f4f98e0c5a2578d750112f3df78338fa97e198","password_salt":"bQipQKDzKFhXnpXEYxoh","api_key":"d49cd50f6f0d2b163f48fc73cb249f0244c37074","super_admin":false,"password":null,"password_confirmation":null,"local_admin":true}'
167
- http_version:
168
- recorded_at: Wed, 08 Apr 2015 10:50:39 GMT
169
- - request:
170
- method: get
171
- uri: http://localhost:3000/locomotive/api/v3/my_account.json?auth_token=by7uUTBWyg5LzGTfyykK
172
- body:
173
- encoding: US-ASCII
174
- string: ''
175
- headers:
176
- Accept:
177
- - application/json
178
- X-Locomotive-Account-Email:
179
- - admin@locomotivecms.com
180
- X-Locomotive-Account-Token:
181
- - by7uUTBWyg5LzGTfyykK
182
- Accept-Encoding:
183
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
184
- User-Agent:
185
- - Ruby
186
- response:
187
- status:
188
- code: 200
189
- message: OK
190
- headers:
191
- Content-Type:
192
- - application/json
193
- Content-Length:
194
- - '409'
195
- Etag:
196
- - W/"de9362bbb5bdda2f08c588cb8bccc53e"
197
- Cache-Control:
198
- - max-age=0, private, must-revalidate
199
- X-Request-Id:
200
- - 92225521-e544-4a18-a1b5-7f0c45177ad0
201
- X-Runtime:
202
- - '0.017949'
203
- Connection:
204
- - keep-alive
205
- Server:
206
- - thin
207
- body:
208
- encoding: UTF-8
209
- string: '{"_id":"5524f99e646964184d000000","created_at":"2015-04-08T09:49:18Z","updated_at":"2015-04-08T09:49:18Z","name":"Admin","email":"admin@locomotivecms.com","locale":"en","encrypted_password":"a8f4f98e0c5a2578d750112f3df78338fa97e198","password_salt":"bQipQKDzKFhXnpXEYxoh","api_key":"d49cd50f6f0d2b163f48fc73cb249f0244c37074","super_admin":false,"password":null,"password_confirmation":null,"local_admin":true}'
210
- http_version:
211
- recorded_at: Wed, 08 Apr 2015 10:50:39 GMT
212
3
  - request:
213
4
  method: post
214
5
  uri: http://localhost:3000/locomotive/api/v3/tokens.json
@@ -238,9 +29,9 @@ http_interactions:
238
29
  Cache-Control:
239
30
  - no-cache
240
31
  X-Request-Id:
241
- - a6c974fb-44dc-46e1-9c36-4fbecb291f3b
32
+ - 7fb8047a-d658-4749-a06f-6d8ffdb31979
242
33
  X-Runtime:
243
- - '0.444182'
34
+ - '0.020220'
244
35
  Connection:
245
36
  - keep-alive
246
37
  Server:
@@ -249,7 +40,7 @@ http_interactions:
249
40
  encoding: UTF-8
250
41
  string: '{"message":"Invalid email or password."}'
251
42
  http_version:
252
- recorded_at: Sun, 19 Apr 2015 21:26:18 GMT
43
+ recorded_at: Tue, 19 May 2015 14:11:30 GMT
253
44
  - request:
254
45
  method: post
255
46
  uri: http://localhost:3000/locomotive/api/v3/my_account.json
@@ -275,22 +66,22 @@ http_interactions:
275
66
  Content-Length:
276
67
  - '250'
277
68
  Etag:
278
- - W/"7f1ccfe9ba64fa9c9fe9e3cc62a4a6ae"
69
+ - W/"77a6faa0568f7ba809893a63188e0841"
279
70
  Cache-Control:
280
71
  - max-age=0, private, must-revalidate
281
72
  X-Request-Id:
282
- - 7d9b6b49-14b6-452b-ad41-448ccd3030da
73
+ - 9db2c62e-ad67-441a-873e-7f89212ce6bb
283
74
  X-Runtime:
284
- - '0.060605'
75
+ - '0.022082'
285
76
  Connection:
286
77
  - keep-alive
287
78
  Server:
288
79
  - thin
289
80
  body:
290
81
  encoding: UTF-8
291
- string: '{"_id":"55341d7a64696402c1620000","created_at":"2015-04-19T21:26:18Z","updated_at":"2015-04-19T21:26:18Z","name":"John","email":"john@doe.net","locale":"en","api_key":"f4aabd29e179e2dea96d5f50e8570b06322c79d6","super_admin":false,"local_admin":false}'
82
+ string: '{"_id":"555b4492646964986c220000","created_at":"2015-05-19T14:11:30Z","updated_at":"2015-05-19T14:11:30Z","name":"John","email":"john@doe.net","locale":"en","api_key":"c17eb23cfde7a2f7f3d08689dd20470cf9bd95a8","super_admin":false,"local_admin":false}'
292
83
  http_version:
293
- recorded_at: Sun, 19 Apr 2015 21:26:18 GMT
84
+ recorded_at: Tue, 19 May 2015 14:11:30 GMT
294
85
  - request:
295
86
  method: post
296
87
  uri: http://localhost:3000/locomotive/api/v3/tokens.json
@@ -316,35 +107,35 @@ http_interactions:
316
107
  Content-Length:
317
108
  - '32'
318
109
  Etag:
319
- - W/"d1f7b30db41123dbdfabce85ebf9a043"
110
+ - W/"6b081cb1b0d50389aeec251b56dc5e74"
320
111
  Cache-Control:
321
112
  - max-age=0, private, must-revalidate
322
113
  X-Request-Id:
323
- - f68a6e28-a329-4837-9717-e1bf3dffcb4d
114
+ - 1907747b-b550-4ec4-9da6-9e7f282e435f
324
115
  X-Runtime:
325
- - '0.015913'
116
+ - '0.017065'
326
117
  Connection:
327
118
  - keep-alive
328
119
  Server:
329
120
  - thin
330
121
  body:
331
122
  encoding: UTF-8
332
- string: '{"token":"B1UseoZ1BSQUr86t5-Kz"}'
123
+ string: '{"token":"6UA3Po7vVz4Ry34swEqa"}'
333
124
  http_version:
334
- recorded_at: Sun, 19 Apr 2015 21:26:18 GMT
125
+ recorded_at: Tue, 19 May 2015 14:11:30 GMT
335
126
  - request:
336
127
  method: get
337
128
  uri: http://localhost:3000/locomotive/api/v3/my_account.json
338
129
  body:
339
130
  encoding: UTF-8
340
- string: auth_token=B1UseoZ1BSQUr86t5-Kz
131
+ string: auth_token=6UA3Po7vVz4Ry34swEqa
341
132
  headers:
342
133
  Accept:
343
134
  - application/json
344
135
  X-Locomotive-Account-Email:
345
136
  - admin@locomotivecms.com
346
137
  X-Locomotive-Account-Token:
347
- - B1UseoZ1BSQUr86t5-Kz
138
+ - 6UA3Po7vVz4Ry34swEqa
348
139
  Content-Type:
349
140
  - application/x-www-form-urlencoded
350
141
  Accept-Encoding:
@@ -359,37 +150,38 @@ http_interactions:
359
150
  Content-Type:
360
151
  - application/json
361
152
  Content-Length:
362
- - '261'
153
+ - '264'
363
154
  Etag:
364
- - W/"294f1e257d98163da949834493fbbf45"
155
+ - W/"d661a7257212c7c3bdbddfbef6296311"
365
156
  Cache-Control:
366
157
  - max-age=0, private, must-revalidate
367
158
  X-Request-Id:
368
- - ce060fe8-b9b2-47f5-9b85-7378ebe75007
159
+ - 6ec73621-c20a-4248-912a-fdc96683df1d
369
160
  X-Runtime:
370
- - '0.031785'
161
+ - '0.015687'
371
162
  Connection:
372
163
  - keep-alive
373
164
  Server:
374
165
  - thin
375
166
  body:
376
167
  encoding: UTF-8
377
- string: '{"_id":"5533ee1d6469643196000000","created_at":"2015-04-19T18:04:13Z","updated_at":"2015-04-19T18:04:13Z","name":"Admin","email":"admin@locomotivecms.com","locale":"en","api_key":"d49cd50f6f0d2b163f48fc73cb249f0244c37074","super_admin":false,"local_admin":true}'
168
+ string: '{"_id":"5555b35a646964e1ca000000","created_at":"2015-05-15T08:50:34Z","updated_at":"2015-05-19T14:03:41Z","name":"John
169
+ Doe","email":"admin@locomotivecms.com","locale":"en","api_key":"d49cd50f6f0d2b163f48fc73cb249f0244c37074","super_admin":false,"local_admin":true}'
378
170
  http_version:
379
- recorded_at: Sun, 19 Apr 2015 21:26:18 GMT
171
+ recorded_at: Tue, 19 May 2015 14:11:30 GMT
380
172
  - request:
381
173
  method: get
382
174
  uri: http://localhost:3000/locomotive/api/v3/my_account.json
383
175
  body:
384
176
  encoding: UTF-8
385
- string: auth_token=B1UseoZ1BSQUr86t5-Kz
177
+ string: auth_token=6UA3Po7vVz4Ry34swEqa
386
178
  headers:
387
179
  Accept:
388
180
  - application/json
389
181
  X-Locomotive-Account-Email:
390
182
  - admin@locomotivecms.com
391
183
  X-Locomotive-Account-Token:
392
- - B1UseoZ1BSQUr86t5-Kz
184
+ - 6UA3Po7vVz4Ry34swEqa
393
185
  Content-Type:
394
186
  - application/x-www-form-urlencoded
395
187
  Accept-Encoding:
@@ -404,22 +196,23 @@ http_interactions:
404
196
  Content-Type:
405
197
  - application/json
406
198
  Content-Length:
407
- - '261'
199
+ - '264'
408
200
  Etag:
409
- - W/"294f1e257d98163da949834493fbbf45"
201
+ - W/"d661a7257212c7c3bdbddfbef6296311"
410
202
  Cache-Control:
411
203
  - max-age=0, private, must-revalidate
412
204
  X-Request-Id:
413
- - 4ce9cefd-14b4-4ed2-8e35-b66e2ec9e1ec
205
+ - 68f440fc-1603-4bd7-a028-7f3741011060
414
206
  X-Runtime:
415
- - '0.016007'
207
+ - '0.014680'
416
208
  Connection:
417
209
  - keep-alive
418
210
  Server:
419
211
  - thin
420
212
  body:
421
213
  encoding: UTF-8
422
- string: '{"_id":"5533ee1d6469643196000000","created_at":"2015-04-19T18:04:13Z","updated_at":"2015-04-19T18:04:13Z","name":"Admin","email":"admin@locomotivecms.com","locale":"en","api_key":"d49cd50f6f0d2b163f48fc73cb249f0244c37074","super_admin":false,"local_admin":true}'
214
+ string: '{"_id":"5555b35a646964e1ca000000","created_at":"2015-05-15T08:50:34Z","updated_at":"2015-05-19T14:03:41Z","name":"John
215
+ Doe","email":"admin@locomotivecms.com","locale":"en","api_key":"d49cd50f6f0d2b163f48fc73cb249f0244c37074","super_admin":false,"local_admin":true}'
423
216
  http_version:
424
- recorded_at: Sun, 19 Apr 2015 21:26:18 GMT
217
+ recorded_at: Tue, 19 May 2015 14:11:30 GMT
425
218
  recorded_with: VCR 2.9.3