forest_liana 7.4.0 → 7.4.4

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
  SHA256:
3
- metadata.gz: adc1d7ec157183e6001f0c62980ae41cac6812a06e4fb8d1d5189609e478c2c6
4
- data.tar.gz: 21ccd896ff434a672683d6d384aa70e80b531c95189294551c3466a5ead3a5b6
3
+ metadata.gz: 16a2236c1fb56bf4751022ce232fd55ce9e2ef8cd925a49ea079e37ce5656edb
4
+ data.tar.gz: 411b5dce2c2c1738635686dc76c1649f07af658fe0f23f2a5f3b8a4593e03f42
5
5
  SHA512:
6
- metadata.gz: ce716a35923e78b2d00f066aa717e2a4fcd62506fe9073d370cbf30af90b1474a26cf940cd0a2aed1cf959b6c93cfe9314268e4a9ed048042ec3f04b9a227826
7
- data.tar.gz: 5bb96fed2cc7218d162d4f0ac9df00b6270efa909deaab5ed84289cebe41606b36230423844584b9d65efd7b19588f06f42f90798d6515a05c0a2e2c2755011d
6
+ metadata.gz: f568c5ea47d043290d0b478ba44b2b2275e28d94d434724689918419ece741152de215f83de9d3e54ec27905eacb23261b1c3b1d1c11db2458ac601086103307
7
+ data.tar.gz: 6c748812910133203f75c272504214df64c706371b894ff995393e1535837381a1840d34b05b05568328edb0c1de5c5c976816b3360bf30d8d21280a85a6440a
@@ -32,7 +32,7 @@ module ForestLiana
32
32
  field[:value] = nil unless field[:value]
33
33
  field
34
34
  end
35
- {:fields => fields, :params => params}
35
+ {:fields => fields, :params => params, :user => forest_user}
36
36
  end
37
37
 
38
38
  def get_smart_action_change_ctx(fields, field_changed)
@@ -42,7 +42,7 @@ module ForestLiana
42
42
  ForestLiana::WidgetsHelper.set_field_widget(field)
43
43
  field
44
44
  end
45
- {:field_changed => found_field_changed, :fields => fields, :params => params}
45
+ {:field_changed => found_field_changed, :fields => fields, :params => params, :user => forest_user}
46
46
  end
47
47
 
48
48
  def handle_result(result, action)
@@ -57,10 +57,12 @@ module ForestLiana
57
57
  @collections_sent.each do |collection|
58
58
  collection['actions'].each do |action|
59
59
  c = get_collection(collection['name'])
60
- a = get_action(c, action['name'])
61
- load = !a.hooks.nil? && a.hooks.key?(:load) && a.hooks[:load].is_a?(Proc)
62
- change = !a.hooks.nil? && a.hooks.key?(:change) && a.hooks[:change].is_a?(Hash) ? a.hooks[:change].keys : []
63
- action['hooks'] = {'load' => load, 'change' => change}
60
+ unless c.nil?
61
+ a = get_action(c, action['name'])
62
+ load = !a.hooks.nil? && a.hooks.key?(:load) && a.hooks[:load].is_a?(Proc)
63
+ change = !a.hooks.nil? && a.hooks.key?(:change) && a.hooks[:change].is_a?(Hash) ? a.hooks[:change].keys : []
64
+ action['hooks'] = {'load' => load, 'change' => change}
65
+ end
64
66
  end
65
67
  end
66
68
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "7.4.0"
2
+ VERSION = "7.4.4"
3
3
  end
@@ -136,13 +136,26 @@ describe 'Requesting Actions routes', :type => :request do
136
136
  }
137
137
  }
138
138
 
139
+ use_user_context_action_definition = {
140
+ name: 'use_user_context',
141
+ fields: [foo],
142
+ hooks: {
143
+ :load => -> (context) {
144
+ foo = context[:fields].find{|field| field[:field] == 'foo'}
145
+ foo[:value] = context[:user]['first_name']
146
+ context[:fields]
147
+ }
148
+ }
149
+ }
150
+
139
151
  action = ForestLiana::Model::Action.new(action_definition)
140
152
  fail_action = ForestLiana::Model::Action.new(fail_action_definition)
141
153
  cheat_action = ForestLiana::Model::Action.new(cheat_action_definition)
142
154
  enums_action = ForestLiana::Model::Action.new(enums_action_definition)
143
155
  multiple_enums_action = ForestLiana::Model::Action.new(multiple_enums_action_definition)
156
+ use_user_context_action = ForestLiana::Model::Action.new(use_user_context_action_definition)
144
157
  island = ForestLiana.apimap.find {|collection| collection.name.to_s == ForestLiana.name_for(Island)}
145
- island.actions = [action, fail_action, cheat_action, enums_action, multiple_enums_action]
158
+ island.actions = [action, fail_action, cheat_action, enums_action, multiple_enums_action, use_user_context_action]
146
159
 
147
160
  describe 'call /load' do
148
161
  params = {
@@ -174,6 +187,12 @@ describe 'Requesting Actions routes', :type => :request do
174
187
  expect(response.status).to eq(500)
175
188
  expect(JSON.parse(response.body)).to eq({'error' => 'Error in smart action load hook: hook must return an array of fields'})
176
189
  end
190
+
191
+ it 'should return the first_name of the user who call the action' do
192
+ post '/forest/actions/use_user_context/hooks/load', params: JSON.dump(params), headers: headers
193
+ expect(response.status).to eq(200)
194
+ expect(JSON.parse(response.body)).to eq({'fields' => [foo.merge({:value => 'Michael'}).transform_keys { |key| key.to_s.camelize(:lower) }.stringify_keys]})
195
+ end
177
196
  end
178
197
 
179
198
  describe 'call /change' do
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: 7.4.0
4
+ version: 7.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-04 00:00:00.000000000 Z
11
+ date: 2021-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -511,170 +511,170 @@ specification_version: 4
511
511
  summary: Official Rails Liana for Forest
512
512
  test_files:
513
513
  - test/test_helper.rb
514
- - test/dummy/config.ru
514
+ - test/services/forest_liana/operator_date_interval_parser_test.rb
515
+ - test/services/forest_liana/schema_adapter_test.rb
516
+ - test/routing/route_test.rb
517
+ - test/forest_liana_test.rb
518
+ - test/dummy/Rakefile
515
519
  - test/dummy/bin/setup
516
520
  - test/dummy/bin/bundle
517
521
  - test/dummy/bin/rake
518
522
  - test/dummy/bin/rails
519
- - test/dummy/Rakefile
520
523
  - test/dummy/db/schema.rb
521
- - test/dummy/db/migrate/20150612112520_create_has_and_belongs_to_many_field.rb
522
- - test/dummy/db/migrate/20150623115554_create_has_many_class_name_field.rb
524
+ - test/dummy/db/migrate/20150608131603_create_decimal_field.rb
525
+ - test/dummy/db/migrate/20150814081918_create_has_many_through_field.rb
526
+ - test/dummy/db/migrate/20160627172951_create_tree.rb
527
+ - test/dummy/db/migrate/20160628173505_add_timestamps.rb
523
528
  - test/dummy/db/migrate/20150608130516_create_date_field.rb
524
- - test/dummy/db/migrate/20150608132621_create_string_field.rb
529
+ - test/dummy/db/migrate/20181111162121_create_references_table.rb
525
530
  - test/dummy/db/migrate/20160627172810_create_owner.rb
526
- - test/dummy/db/migrate/20170614141921_create_serialize_field.rb
527
- - test/dummy/db/migrate/20150608131430_create_integer_field.rb
531
+ - test/dummy/db/migrate/20150608132621_create_string_field.rb
532
+ - test/dummy/db/migrate/20150609114636_create_belongs_to_class_name_field.rb
533
+ - test/dummy/db/migrate/20150616150629_create_polymorphic_field.rb
528
534
  - test/dummy/db/migrate/20150608133038_create_belongs_to_field.rb
535
+ - test/dummy/db/migrate/20150608133044_create_has_one_field.rb
529
536
  - test/dummy/db/migrate/20150608131610_create_float_field.rb
530
- - test/dummy/db/migrate/20160628173505_add_timestamps.rb
531
537
  - test/dummy/db/migrate/20150608150016_create_has_many_field.rb
532
- - test/dummy/db/migrate/20150608131603_create_decimal_field.rb
533
- - test/dummy/db/migrate/20150616150629_create_polymorphic_field.rb
534
- - test/dummy/db/migrate/20150609114636_create_belongs_to_class_name_field.rb
535
- - test/dummy/db/migrate/20181111162121_create_references_table.rb
536
- - test/dummy/db/migrate/20160627172951_create_tree.rb
537
- - test/dummy/db/migrate/20150608133044_create_has_one_field.rb
538
- - test/dummy/db/migrate/20150814081918_create_has_many_through_field.rb
539
538
  - test/dummy/db/migrate/20150608132159_create_boolean_field.rb
540
- - test/dummy/public/422.html
541
- - test/dummy/public/favicon.ico
542
- - test/dummy/public/500.html
543
- - test/dummy/public/404.html
539
+ - test/dummy/db/migrate/20170614141921_create_serialize_field.rb
540
+ - test/dummy/db/migrate/20150623115554_create_has_many_class_name_field.rb
541
+ - test/dummy/db/migrate/20150612112520_create_has_and_belongs_to_many_field.rb
542
+ - test/dummy/db/migrate/20150608131430_create_integer_field.rb
543
+ - test/dummy/config.ru
544
544
  - test/dummy/README.rdoc
545
- - test/dummy/config/secrets.yml
546
- - test/dummy/config/environments/test.rb
545
+ - test/dummy/config/environment.rb
546
+ - test/dummy/config/locales/en.yml
547
+ - test/dummy/config/database.yml
547
548
  - test/dummy/config/environments/production.rb
549
+ - test/dummy/config/environments/test.rb
548
550
  - test/dummy/config/environments/development.rb
549
- - test/dummy/config/boot.rb
550
551
  - test/dummy/config/routes.rb
551
- - test/dummy/config/locales/en.yml
552
- - test/dummy/config/application.rb
553
- - test/dummy/config/database.yml
554
- - test/dummy/config/environment.rb
555
- - test/dummy/config/initializers/cookies_serializer.rb
552
+ - test/dummy/config/secrets.yml
553
+ - test/dummy/config/initializers/backtrace_silencers.rb
556
554
  - test/dummy/config/initializers/wrap_parameters.rb
555
+ - test/dummy/config/initializers/mime_types.rb
556
+ - test/dummy/config/initializers/cookies_serializer.rb
557
557
  - test/dummy/config/initializers/inflections.rb
558
+ - test/dummy/config/initializers/filter_parameter_logging.rb
558
559
  - test/dummy/config/initializers/session_store.rb
559
560
  - test/dummy/config/initializers/assets.rb
560
- - test/dummy/config/initializers/backtrace_silencers.rb
561
- - test/dummy/config/initializers/mime_types.rb
562
- - test/dummy/config/initializers/filter_parameter_logging.rb
561
+ - test/dummy/config/application.rb
562
+ - test/dummy/config/boot.rb
563
563
  - test/dummy/app/helpers/application_helper.rb
564
- - test/dummy/app/views/layouts/application.html.erb
565
- - test/dummy/app/controllers/application_controller.rb
566
- - test/dummy/app/models/date_field.rb
564
+ - test/dummy/app/models/belongs_to_field.rb
565
+ - test/dummy/app/models/tree.rb
566
+ - test/dummy/app/models/boolean_field.rb
567
+ - test/dummy/app/models/polymorphic_field.rb
568
+ - test/dummy/app/models/reference.rb
567
569
  - test/dummy/app/models/belongs_to_class_name_field.rb
568
- - test/dummy/app/models/float_field.rb
569
- - test/dummy/app/models/has_many_through_field.rb
570
- - test/dummy/app/models/decimal_field.rb
570
+ - test/dummy/app/models/integer_field.rb
571
+ - test/dummy/app/models/date_field.rb
571
572
  - test/dummy/app/models/serialize_field.rb
572
- - test/dummy/app/models/has_and_belongs_to_many_field.rb
573
- - test/dummy/app/models/has_many_field.rb
573
+ - test/dummy/app/models/decimal_field.rb
574
574
  - test/dummy/app/models/owner.rb
575
- - test/dummy/app/models/polymorphic_field.rb
576
- - test/dummy/app/models/tree.rb
575
+ - test/dummy/app/models/has_many_field.rb
576
+ - test/dummy/app/models/has_many_class_name_field.rb
577
577
  - test/dummy/app/models/string_field.rb
578
- - test/dummy/app/models/belongs_to_field.rb
579
- - test/dummy/app/models/integer_field.rb
580
578
  - test/dummy/app/models/has_one_field.rb
581
- - test/dummy/app/models/boolean_field.rb
582
- - test/dummy/app/models/has_many_class_name_field.rb
583
- - test/dummy/app/models/reference.rb
579
+ - test/dummy/app/models/has_many_through_field.rb
580
+ - test/dummy/app/models/float_field.rb
581
+ - test/dummy/app/models/has_and_belongs_to_many_field.rb
584
582
  - test/dummy/app/assets/javascripts/application.js
585
583
  - test/dummy/app/assets/stylesheets/application.css
586
584
  - test/dummy/app/assets/config/manifest.js
587
- - test/routing/route_test.rb
588
- - test/services/forest_liana/schema_adapter_test.rb
589
- - test/services/forest_liana/operator_date_interval_parser_test.rb
590
- - test/fixtures/belongs_to_field.yml
591
- - test/fixtures/tree.yml
585
+ - test/dummy/app/controllers/application_controller.rb
586
+ - test/dummy/app/views/layouts/application.html.erb
587
+ - test/dummy/public/favicon.ico
588
+ - test/dummy/public/422.html
589
+ - test/dummy/public/404.html
590
+ - test/dummy/public/500.html
591
+ - test/fixtures/serialize_field.yml
592
+ - test/fixtures/has_one_field.yml
592
593
  - test/fixtures/owner.yml
593
- - test/fixtures/reference.yml
594
+ - test/fixtures/has_many_field.yml
594
595
  - test/fixtures/has_many_through_field.yml
595
- - test/fixtures/has_one_field.yml
596
- - test/fixtures/serialize_field.yml
596
+ - test/fixtures/tree.yml
597
+ - test/fixtures/reference.yml
598
+ - test/fixtures/belongs_to_field.yml
597
599
  - test/fixtures/string_field.yml
598
- - test/fixtures/has_many_field.yml
599
- - test/forest_liana_test.rb
600
600
  - spec/helpers/forest_liana/query_helper_spec.rb
601
601
  - spec/helpers/forest_liana/schema_helper_spec.rb
602
- - spec/requests/stats_spec.rb
603
- - spec/requests/resources_spec.rb
604
- - spec/requests/authentications_spec.rb
605
- - spec/requests/actions_controller_spec.rb
606
- - spec/dummy/config.ru
602
+ - spec/services/forest_liana/permissions_checker_acl_disabled_spec.rb
603
+ - spec/services/forest_liana/has_many_getter_spec.rb
604
+ - spec/services/forest_liana/smart_action_field_validator_spec.rb
605
+ - spec/services/forest_liana/permissions_checker_live_queries_spec.rb
606
+ - spec/services/forest_liana/schema_adapter_spec.rb
607
+ - spec/services/forest_liana/scope_manager_spec.rb
608
+ - spec/services/forest_liana/permissions_formatter_spec.rb
609
+ - spec/services/forest_liana/filters_parser_spec.rb
610
+ - spec/services/forest_liana/apimap_sorter_spec.rb
611
+ - spec/services/forest_liana/pie_stat_getter_spec.rb
612
+ - spec/services/forest_liana/resources_getter_spec.rb
613
+ - spec/services/forest_liana/permissions_getter_spec.rb
614
+ - spec/services/forest_liana/line_stat_getter_spec.rb
615
+ - spec/services/forest_liana/value_stat_getter_spec.rb
616
+ - spec/services/forest_liana/resource_updater_spec.rb
617
+ - spec/services/forest_liana/permissions_checker_acl_enabled_spec.rb
618
+ - spec/services/forest_liana/ip_whitelist_checker_spec.rb
619
+ - spec/spec_helper.rb
620
+ - spec/lib/forest_liana/bootstrapper_spec.rb
621
+ - spec/lib/forest_liana/schema_file_updater_spec.rb
622
+ - spec/config/initializers/logger_spec.rb
623
+ - spec/rails_helper.rb
624
+ - spec/dummy/Rakefile
607
625
  - spec/dummy/bin/setup
608
626
  - spec/dummy/bin/bundle
609
627
  - spec/dummy/bin/rake
610
628
  - spec/dummy/bin/rails
611
- - spec/dummy/lib/forest_liana/collections/user.rb
612
- - spec/dummy/lib/forest_liana/collections/island.rb
613
- - spec/dummy/lib/forest_liana/collections/location.rb
614
- - spec/dummy/Rakefile
615
629
  - spec/dummy/db/schema.rb
616
- - spec/dummy/db/migrate/20190716130830_add_age_to_tree.rb
630
+ - spec/dummy/db/migrate/20190716135241_add_type_to_user.rb
617
631
  - spec/dummy/db/migrate/20190226174951_create_tree.rb
632
+ - spec/dummy/db/migrate/20210326110524_create_references.rb
618
633
  - spec/dummy/db/migrate/20210526084712_create_products.rb
619
634
  - spec/dummy/db/migrate/20190226172951_create_user.rb
620
- - spec/dummy/db/migrate/20210326110524_create_references.rb
621
- - spec/dummy/db/migrate/20190226173051_create_isle.rb
622
- - spec/dummy/db/migrate/20210326140855_create_locations.rb
623
- - spec/dummy/db/migrate/20190716135241_add_type_to_user.rb
624
635
  - spec/dummy/db/migrate/20210511141752_create_owners.rb
636
+ - spec/dummy/db/migrate/20190716130830_add_age_to_tree.rb
637
+ - spec/dummy/db/migrate/20210326140855_create_locations.rb
638
+ - spec/dummy/db/migrate/20190226173051_create_isle.rb
639
+ - spec/dummy/config.ru
625
640
  - spec/dummy/README.rdoc
626
- - spec/dummy/config/secrets.yml
627
- - spec/dummy/config/environments/test.rb
641
+ - spec/dummy/lib/forest_liana/collections/user.rb
642
+ - spec/dummy/lib/forest_liana/collections/island.rb
643
+ - spec/dummy/lib/forest_liana/collections/location.rb
644
+ - spec/dummy/config/environment.rb
645
+ - spec/dummy/config/database.yml
628
646
  - spec/dummy/config/environments/production.rb
647
+ - spec/dummy/config/environments/test.rb
629
648
  - spec/dummy/config/environments/development.rb
630
- - spec/dummy/config/boot.rb
631
649
  - spec/dummy/config/routes.rb
632
- - spec/dummy/config/application.rb
633
- - spec/dummy/config/database.yml
634
- - spec/dummy/config/environment.rb
635
- - spec/dummy/config/initializers/cookies_serializer.rb
650
+ - spec/dummy/config/secrets.yml
651
+ - spec/dummy/config/initializers/backtrace_silencers.rb
636
652
  - spec/dummy/config/initializers/wrap_parameters.rb
653
+ - spec/dummy/config/initializers/mime_types.rb
654
+ - spec/dummy/config/initializers/cookies_serializer.rb
655
+ - spec/dummy/config/initializers/forest_liana.rb
637
656
  - spec/dummy/config/initializers/inflections.rb
657
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
638
658
  - spec/dummy/config/initializers/session_store.rb
639
- - spec/dummy/config/initializers/forest_liana.rb
640
659
  - spec/dummy/config/initializers/assets.rb
641
- - spec/dummy/config/initializers/backtrace_silencers.rb
642
- - spec/dummy/config/initializers/mime_types.rb
643
- - spec/dummy/config/initializers/filter_parameter_logging.rb
660
+ - spec/dummy/config/application.rb
661
+ - spec/dummy/config/boot.rb
644
662
  - spec/dummy/app/helpers/application_helper.rb
645
- - spec/dummy/app/views/layouts/application.html.erb
646
- - spec/dummy/app/controllers/forest/islands_controller.rb
647
- - spec/dummy/app/controllers/application_controller.rb
648
- - spec/dummy/app/models/product.rb
649
- - spec/dummy/app/models/user.rb
650
- - spec/dummy/app/models/owner.rb
651
663
  - spec/dummy/app/models/tree.rb
664
+ - spec/dummy/app/models/reference.rb
665
+ - spec/dummy/app/models/user.rb
652
666
  - spec/dummy/app/models/island.rb
667
+ - spec/dummy/app/models/owner.rb
668
+ - spec/dummy/app/models/product.rb
653
669
  - spec/dummy/app/models/location.rb
654
- - spec/dummy/app/models/reference.rb
670
+ - spec/dummy/app/config/routes.rb
655
671
  - spec/dummy/app/assets/javascripts/application.js
656
672
  - spec/dummy/app/assets/stylesheets/application.css
657
673
  - spec/dummy/app/assets/config/manifest.js
658
- - spec/dummy/app/config/routes.rb
659
- - spec/rails_helper.rb
660
- - spec/services/forest_liana/permissions_getter_spec.rb
661
- - spec/services/forest_liana/filters_parser_spec.rb
662
- - spec/services/forest_liana/schema_adapter_spec.rb
663
- - spec/services/forest_liana/permissions_checker_acl_disabled_spec.rb
664
- - spec/services/forest_liana/smart_action_field_validator_spec.rb
665
- - spec/services/forest_liana/apimap_sorter_spec.rb
666
- - spec/services/forest_liana/permissions_formatter_spec.rb
667
- - spec/services/forest_liana/line_stat_getter_spec.rb
668
- - spec/services/forest_liana/pie_stat_getter_spec.rb
669
- - spec/services/forest_liana/has_many_getter_spec.rb
670
- - spec/services/forest_liana/permissions_checker_acl_enabled_spec.rb
671
- - spec/services/forest_liana/ip_whitelist_checker_spec.rb
672
- - spec/services/forest_liana/resources_getter_spec.rb
673
- - spec/services/forest_liana/value_stat_getter_spec.rb
674
- - spec/services/forest_liana/scope_manager_spec.rb
675
- - spec/services/forest_liana/permissions_checker_live_queries_spec.rb
676
- - spec/services/forest_liana/resource_updater_spec.rb
677
- - spec/lib/forest_liana/bootstrapper_spec.rb
678
- - spec/lib/forest_liana/schema_file_updater_spec.rb
679
- - spec/spec_helper.rb
680
- - spec/config/initializers/logger_spec.rb
674
+ - spec/dummy/app/controllers/application_controller.rb
675
+ - spec/dummy/app/controllers/forest/islands_controller.rb
676
+ - spec/dummy/app/views/layouts/application.html.erb
677
+ - spec/requests/resources_spec.rb
678
+ - spec/requests/authentications_spec.rb
679
+ - spec/requests/actions_controller_spec.rb
680
+ - spec/requests/stats_spec.rb