forest_liana 1.6.11 → 1.6.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ serialize_field_1:
2
+ id: 1
3
+ field: value 1
4
+
5
+ serialize_field_2:
6
+ id: 2
7
+ field: value 2
8
+
9
+ serialize_field_3:
10
+ id: 3
11
+ field: value 3
12
+
13
+ serialize_field_4:
14
+ id: 4
15
+ field: value 4
16
+
17
+ serialize_field_5:
18
+ id: 5
19
+ field: value 5
@@ -0,0 +1,68 @@
1
+ module ForestLiana
2
+ class ResourceUpdaterTest < ActiveSupport::TestCase
3
+
4
+ collection = ForestLiana::Model::Collection.new({
5
+ name: 'serialize_fields',
6
+ fields: [{
7
+ type: 'String',
8
+ field: 'field'
9
+ }]
10
+ })
11
+
12
+ ForestLiana.apimap << collection
13
+ ForestLiana.models << SerializeField
14
+
15
+ test 'Update a record on a "serialize" attribute with a missing value' do
16
+ params = ActionController::Parameters.new(
17
+ id: 1,
18
+ data: {
19
+ id: 1,
20
+ type: "serialize_field",
21
+ attributes: {}
22
+ }
23
+ )
24
+ updater = ResourceUpdater.new(SerializeField, params)
25
+ updater.perform
26
+
27
+ assert updater.record.valid?
28
+ assert updater.record.field == []
29
+ end
30
+
31
+ test 'Update a record on a "serialize" attribute with a bad format value' do
32
+ params = ActionController::Parameters.new(
33
+ id: 1,
34
+ data: {
35
+ id: 1,
36
+ type: "serialize_field",
37
+ attributes: {
38
+ field: "Lucas"
39
+ }
40
+ }
41
+ )
42
+ updater = ResourceUpdater.new(SerializeField, params)
43
+ updater.perform
44
+
45
+ assert updater.record.valid?
46
+ assert updater.record.field == "value 1"
47
+ assert updater.errors[0][:detail] == "Bad format for 'field' attribute value."
48
+ end
49
+
50
+ test 'Update a record on a "serialize" attribute with a well formated value' do
51
+ params = ActionController::Parameters.new(
52
+ id: 1,
53
+ data: {
54
+ id: 1,
55
+ type: "serialize_field",
56
+ attributes: {
57
+ field: "[\"test\", \"test\"]"
58
+ }
59
+ }
60
+ )
61
+ updater = ResourceUpdater.new(SerializeField, params)
62
+ updater.perform
63
+
64
+ assert updater.record.valid?
65
+ assert updater.record.field == ["test", "test"]
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.11
4
+ version: 1.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-13 00:00:00.000000000 Z
11
+ date: 2017-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -195,6 +195,7 @@ files:
195
195
  - app/services/forest_liana/value_stat_getter.rb
196
196
  - app/views/layouts/forest_liana/application.html.erb
197
197
  - config/initializers/arel-helpers.rb
198
+ - config/initializers/errors.rb
198
199
  - config/initializers/logger.rb
199
200
  - config/initializers/time_formats.rb
200
201
  - config/routes.rb
@@ -225,6 +226,7 @@ files:
225
226
  - test/dummy/app/models/integer_field.rb
226
227
  - test/dummy/app/models/owner.rb
227
228
  - test/dummy/app/models/polymorphic_field.rb
229
+ - test/dummy/app/models/serialize_field.rb
228
230
  - test/dummy/app/models/string_field.rb
229
231
  - test/dummy/app/models/tree.rb
230
232
  - test/dummy/app/views/layouts/application.html.erb
@@ -268,6 +270,7 @@ files:
268
270
  - test/dummy/db/migrate/20160627172810_create_owner.rb
269
271
  - test/dummy/db/migrate/20160627172951_create_tree.rb
270
272
  - test/dummy/db/migrate/20160628173505_add_timestamps.rb
273
+ - test/dummy/db/migrate/20170614141921_create_serialize_field.rb
271
274
  - test/dummy/db/schema.rb
272
275
  - test/dummy/db/test.sqlite3
273
276
  - test/dummy/log/test.log
@@ -280,10 +283,12 @@ files:
280
283
  - test/fixtures/has_many_through_field.yml
281
284
  - test/fixtures/has_one_field.yml
282
285
  - test/fixtures/owner.yml
286
+ - test/fixtures/serialize_field.yml
283
287
  - test/fixtures/string_field.yml
284
288
  - test/fixtures/tree.yml
285
289
  - test/forest_liana_test.rb
286
290
  - test/integration/navigation_test.rb
291
+ - test/services/forest_liana/resource_updater_test.rb
287
292
  - test/services/forest_liana/resources_getter_test.rb
288
293
  - test/services/forest_liana/schema_adapter_test.rb
289
294
  - test/services/forest_liana/value_stat_getter_test.rb
@@ -331,6 +336,7 @@ test_files:
331
336
  - test/dummy/app/models/integer_field.rb
332
337
  - test/dummy/app/models/owner.rb
333
338
  - test/dummy/app/models/polymorphic_field.rb
339
+ - test/dummy/app/models/serialize_field.rb
334
340
  - test/dummy/app/models/string_field.rb
335
341
  - test/dummy/app/models/tree.rb
336
342
  - test/dummy/app/views/layouts/application.html.erb
@@ -374,6 +380,7 @@ test_files:
374
380
  - test/dummy/db/migrate/20160627172810_create_owner.rb
375
381
  - test/dummy/db/migrate/20160627172951_create_tree.rb
376
382
  - test/dummy/db/migrate/20160628173505_add_timestamps.rb
383
+ - test/dummy/db/migrate/20170614141921_create_serialize_field.rb
377
384
  - test/dummy/db/schema.rb
378
385
  - test/dummy/db/test.sqlite3
379
386
  - test/dummy/log/test.log
@@ -388,10 +395,12 @@ test_files:
388
395
  - test/fixtures/has_many_through_field.yml
389
396
  - test/fixtures/has_one_field.yml
390
397
  - test/fixtures/owner.yml
398
+ - test/fixtures/serialize_field.yml
391
399
  - test/fixtures/string_field.yml
392
400
  - test/fixtures/tree.yml
393
401
  - test/forest_liana_test.rb
394
402
  - test/integration/navigation_test.rb
403
+ - test/services/forest_liana/resource_updater_test.rb
395
404
  - test/services/forest_liana/resources_getter_test.rb
396
405
  - test/services/forest_liana/schema_adapter_test.rb
397
406
  - test/services/forest_liana/value_stat_getter_test.rb