forest_liana 6.0.5 → 6.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/forest_liana/stats_controller.rb +47 -2
- data/app/helpers/forest_liana/schema_helper.rb +6 -0
- data/app/services/forest_liana/filters_parser.rb +43 -17
- data/app/services/forest_liana/permissions_checker.rb +52 -3
- data/config/initializers/errors.rb +6 -0
- data/lib/forest_liana/version.rb +1 -1
- data/spec/dummy/app/models/island.rb +1 -0
- data/spec/dummy/app/models/location.rb +3 -0
- data/spec/dummy/app/models/reference.rb +2 -0
- data/spec/dummy/db/migrate/20210326110524_create_references.rb +8 -0
- data/spec/dummy/db/migrate/20210326140855_create_locations.rb +10 -0
- data/spec/dummy/db/schema.rb +14 -1
- data/spec/dummy/lib/forest_liana/collections/location.rb +10 -0
- data/spec/dummy/lib/forest_liana/collections/user.rb +15 -0
- data/spec/requests/stats_spec.rb +114 -0
- data/spec/services/forest_liana/permissions_checker_acl_disabled_spec.rb +3 -3
- data/spec/services/forest_liana/permissions_checker_acl_enabled_spec.rb +2 -2
- data/spec/services/forest_liana/permissions_checker_live_queries_spec.rb +131 -0
- data/spec/services/forest_liana/resources_getter_spec.rb +359 -0
- data/spec/services/forest_liana/schema_adapter_spec.rb +1 -1
- metadata +135 -119
- data/test/services/forest_liana/resources_getter_test.rb +0 -284
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: 6.
|
4
|
+
version: 6.2.2
|
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
|
+
date: 2021-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -325,6 +325,8 @@ files:
|
|
325
325
|
- spec/dummy/app/controllers/application_controller.rb
|
326
326
|
- spec/dummy/app/helpers/application_helper.rb
|
327
327
|
- spec/dummy/app/models/island.rb
|
328
|
+
- spec/dummy/app/models/location.rb
|
329
|
+
- spec/dummy/app/models/reference.rb
|
328
330
|
- spec/dummy/app/models/tree.rb
|
329
331
|
- spec/dummy/app/models/user.rb
|
330
332
|
- spec/dummy/app/views/layouts/application.html.erb
|
@@ -356,7 +358,11 @@ files:
|
|
356
358
|
- spec/dummy/db/migrate/20190226174951_create_tree.rb
|
357
359
|
- spec/dummy/db/migrate/20190716130830_add_age_to_tree.rb
|
358
360
|
- spec/dummy/db/migrate/20190716135241_add_type_to_user.rb
|
361
|
+
- spec/dummy/db/migrate/20210326110524_create_references.rb
|
362
|
+
- spec/dummy/db/migrate/20210326140855_create_locations.rb
|
359
363
|
- spec/dummy/db/schema.rb
|
364
|
+
- spec/dummy/lib/forest_liana/collections/location.rb
|
365
|
+
- spec/dummy/lib/forest_liana/collections/user.rb
|
360
366
|
- spec/helpers/forest_liana/is_same_data_structure_helper_spec.rb
|
361
367
|
- spec/helpers/forest_liana/query_helper_spec.rb
|
362
368
|
- spec/helpers/forest_liana/schema_helper_spec.rb
|
@@ -364,13 +370,16 @@ files:
|
|
364
370
|
- spec/requests/actions_controller_spec.rb
|
365
371
|
- spec/requests/authentications_spec.rb
|
366
372
|
- spec/requests/resources_spec.rb
|
373
|
+
- spec/requests/stats_spec.rb
|
367
374
|
- spec/services/forest_liana/apimap_sorter_spec.rb
|
368
375
|
- spec/services/forest_liana/filters_parser_spec.rb
|
369
376
|
- spec/services/forest_liana/ip_whitelist_checker_spec.rb
|
370
377
|
- spec/services/forest_liana/permissions_checker_acl_disabled_spec.rb
|
371
378
|
- spec/services/forest_liana/permissions_checker_acl_enabled_spec.rb
|
379
|
+
- spec/services/forest_liana/permissions_checker_live_queries_spec.rb
|
372
380
|
- spec/services/forest_liana/permissions_formatter_spec.rb
|
373
381
|
- spec/services/forest_liana/permissions_getter_spec.rb
|
382
|
+
- spec/services/forest_liana/resources_getter_spec.rb
|
374
383
|
- spec/services/forest_liana/schema_adapter_spec.rb
|
375
384
|
- spec/spec_helper.rb
|
376
385
|
- test/dummy/README.rdoc
|
@@ -460,7 +469,6 @@ files:
|
|
460
469
|
- test/services/forest_liana/has_many_getter_test.rb
|
461
470
|
- test/services/forest_liana/pie_stat_getter_test.rb
|
462
471
|
- test/services/forest_liana/resource_updater_test.rb
|
463
|
-
- test/services/forest_liana/resources_getter_test.rb
|
464
472
|
- test/services/forest_liana/schema_adapter_test.rb
|
465
473
|
- test/services/forest_liana/scope_validator_test.rb
|
466
474
|
- test/services/forest_liana/value_stat_getter_test.rb
|
@@ -489,152 +497,160 @@ signing_key:
|
|
489
497
|
specification_version: 4
|
490
498
|
summary: Official Rails Liana for Forest
|
491
499
|
test_files:
|
492
|
-
- test/dummy/
|
493
|
-
- test/dummy/
|
494
|
-
- test/dummy/
|
495
|
-
- test/dummy/
|
496
|
-
- test/dummy/
|
497
|
-
- test/dummy/
|
498
|
-
- test/dummy/
|
499
|
-
- test/dummy/
|
500
|
-
- test/dummy/
|
501
|
-
- test/dummy/
|
502
|
-
- test/dummy/
|
503
|
-
- test/dummy/
|
504
|
-
- test/dummy/
|
505
|
-
- test/dummy/
|
506
|
-
- test/dummy/
|
507
|
-
- test/dummy/
|
508
|
-
- test/dummy/
|
509
|
-
- test/dummy/
|
510
|
-
- test/dummy/
|
511
|
-
- test/dummy/
|
512
|
-
- test/dummy/
|
513
|
-
- test/dummy/
|
500
|
+
- test/dummy/db/migrate/20150608133044_create_has_one_field.rb
|
501
|
+
- test/dummy/db/migrate/20150608132159_create_boolean_field.rb
|
502
|
+
- test/dummy/db/migrate/20160627172810_create_owner.rb
|
503
|
+
- test/dummy/db/migrate/20150608131603_create_decimal_field.rb
|
504
|
+
- test/dummy/db/migrate/20150608133038_create_belongs_to_field.rb
|
505
|
+
- test/dummy/db/migrate/20150814081918_create_has_many_through_field.rb
|
506
|
+
- test/dummy/db/migrate/20160627172951_create_tree.rb
|
507
|
+
- test/dummy/db/migrate/20150608131610_create_float_field.rb
|
508
|
+
- test/dummy/db/migrate/20150608150016_create_has_many_field.rb
|
509
|
+
- test/dummy/db/migrate/20150608131430_create_integer_field.rb
|
510
|
+
- test/dummy/db/migrate/20181111162121_create_references_table.rb
|
511
|
+
- test/dummy/db/migrate/20150612112520_create_has_and_belongs_to_many_field.rb
|
512
|
+
- test/dummy/db/migrate/20150608132621_create_string_field.rb
|
513
|
+
- test/dummy/db/migrate/20170614141921_create_serialize_field.rb
|
514
|
+
- test/dummy/db/migrate/20150608130516_create_date_field.rb
|
515
|
+
- test/dummy/db/migrate/20150616150629_create_polymorphic_field.rb
|
516
|
+
- test/dummy/db/migrate/20150609114636_create_belongs_to_class_name_field.rb
|
517
|
+
- test/dummy/db/migrate/20160628173505_add_timestamps.rb
|
518
|
+
- test/dummy/db/migrate/20150623115554_create_has_many_class_name_field.rb
|
519
|
+
- test/dummy/db/schema.rb
|
520
|
+
- test/dummy/public/404.html
|
521
|
+
- test/dummy/public/500.html
|
522
|
+
- test/dummy/public/422.html
|
523
|
+
- test/dummy/public/favicon.ico
|
524
|
+
- test/dummy/Rakefile
|
514
525
|
- test/dummy/app/controllers/application_controller.rb
|
515
|
-
- test/dummy/app/models/
|
516
|
-
- test/dummy/app/models/reference.rb
|
517
|
-
- test/dummy/app/models/belongs_to_field.rb
|
518
|
-
- test/dummy/app/models/string_field.rb
|
519
|
-
- test/dummy/app/models/has_many_through_field.rb
|
520
|
-
- test/dummy/app/models/has_many_class_name_field.rb
|
521
|
-
- test/dummy/app/models/date_field.rb
|
526
|
+
- test/dummy/app/models/has_and_belongs_to_many_field.rb
|
522
527
|
- test/dummy/app/models/polymorphic_field.rb
|
528
|
+
- test/dummy/app/models/has_many_field.rb
|
529
|
+
- test/dummy/app/models/float_field.rb
|
530
|
+
- test/dummy/app/models/string_field.rb
|
531
|
+
- test/dummy/app/models/has_one_field.rb
|
532
|
+
- test/dummy/app/models/reference.rb
|
533
|
+
- test/dummy/app/models/serialize_field.rb
|
523
534
|
- test/dummy/app/models/boolean_field.rb
|
535
|
+
- test/dummy/app/models/has_many_through_field.rb
|
524
536
|
- test/dummy/app/models/belongs_to_class_name_field.rb
|
525
|
-
- test/dummy/app/models/has_one_field.rb
|
526
|
-
- test/dummy/app/models/has_many_field.rb
|
527
|
-
- test/dummy/app/models/has_and_belongs_to_many_field.rb
|
528
537
|
- test/dummy/app/models/decimal_field.rb
|
529
|
-
- test/dummy/app/models/owner.rb
|
530
|
-
- test/dummy/app/models/serialize_field.rb
|
531
538
|
- test/dummy/app/models/integer_field.rb
|
532
|
-
- test/dummy/app/models/
|
539
|
+
- test/dummy/app/models/tree.rb
|
540
|
+
- test/dummy/app/models/date_field.rb
|
541
|
+
- test/dummy/app/models/belongs_to_field.rb
|
542
|
+
- test/dummy/app/models/has_many_class_name_field.rb
|
543
|
+
- test/dummy/app/models/owner.rb
|
544
|
+
- test/dummy/app/assets/stylesheets/application.css
|
545
|
+
- test/dummy/app/assets/javascripts/application.js
|
546
|
+
- test/dummy/app/assets/config/manifest.js
|
533
547
|
- test/dummy/app/helpers/application_helper.rb
|
534
|
-
- test/dummy/
|
535
|
-
- test/dummy/config.ru
|
548
|
+
- test/dummy/app/views/layouts/application.html.erb
|
536
549
|
- test/dummy/README.rdoc
|
537
|
-
- test/dummy/
|
550
|
+
- test/dummy/config.ru
|
551
|
+
- test/dummy/config/environment.rb
|
552
|
+
- test/dummy/config/secrets.yml
|
553
|
+
- test/dummy/config/boot.rb
|
554
|
+
- test/dummy/config/database.yml
|
555
|
+
- test/dummy/config/routes.rb
|
556
|
+
- test/dummy/config/application.rb
|
557
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
558
|
+
- test/dummy/config/initializers/mime_types.rb
|
559
|
+
- test/dummy/config/initializers/session_store.rb
|
560
|
+
- test/dummy/config/initializers/inflections.rb
|
561
|
+
- test/dummy/config/initializers/assets.rb
|
562
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
563
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
564
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
565
|
+
- test/dummy/config/environments/test.rb
|
566
|
+
- test/dummy/config/environments/production.rb
|
567
|
+
- test/dummy/config/environments/development.rb
|
568
|
+
- test/dummy/config/locales/en.yml
|
538
569
|
- test/dummy/bin/rake
|
539
570
|
- test/dummy/bin/bundle
|
571
|
+
- test/dummy/bin/rails
|
540
572
|
- test/dummy/bin/setup
|
541
|
-
- test/
|
542
|
-
- test/
|
543
|
-
- test/dummy/public/404.html
|
544
|
-
- test/dummy/public/500.html
|
545
|
-
- test/dummy/db/schema.rb
|
546
|
-
- test/dummy/db/migrate/20150608131430_create_integer_field.rb
|
547
|
-
- test/dummy/db/migrate/20181111162121_create_references_table.rb
|
548
|
-
- test/dummy/db/migrate/20150608130516_create_date_field.rb
|
549
|
-
- test/dummy/db/migrate/20160627172810_create_owner.rb
|
550
|
-
- test/dummy/db/migrate/20150609114636_create_belongs_to_class_name_field.rb
|
551
|
-
- test/dummy/db/migrate/20170614141921_create_serialize_field.rb
|
552
|
-
- test/dummy/db/migrate/20150608132159_create_boolean_field.rb
|
553
|
-
- test/dummy/db/migrate/20150616150629_create_polymorphic_field.rb
|
554
|
-
- test/dummy/db/migrate/20160627172951_create_tree.rb
|
555
|
-
- test/dummy/db/migrate/20150608132621_create_string_field.rb
|
556
|
-
- test/dummy/db/migrate/20150608150016_create_has_many_field.rb
|
557
|
-
- test/dummy/db/migrate/20150612112520_create_has_and_belongs_to_many_field.rb
|
558
|
-
- test/dummy/db/migrate/20150814081918_create_has_many_through_field.rb
|
559
|
-
- test/dummy/db/migrate/20150608133038_create_belongs_to_field.rb
|
560
|
-
- test/dummy/db/migrate/20150623115554_create_has_many_class_name_field.rb
|
561
|
-
- test/dummy/db/migrate/20160628173505_add_timestamps.rb
|
562
|
-
- test/dummy/db/migrate/20150608133044_create_has_one_field.rb
|
563
|
-
- test/dummy/db/migrate/20150608131610_create_float_field.rb
|
564
|
-
- test/dummy/db/migrate/20150608131603_create_decimal_field.rb
|
565
|
-
- test/fixtures/tree.yml
|
566
|
-
- test/fixtures/has_many_through_field.yml
|
567
|
-
- test/fixtures/owner.yml
|
568
|
-
- test/fixtures/has_many_field.yml
|
569
|
-
- test/fixtures/string_field.yml
|
570
|
-
- test/fixtures/serialize_field.yml
|
571
|
-
- test/fixtures/has_one_field.yml
|
572
|
-
- test/fixtures/reference.yml
|
573
|
-
- test/fixtures/belongs_to_field.yml
|
574
|
-
- test/services/forest_liana/value_stat_getter_test.rb
|
575
|
-
- test/services/forest_liana/resources_getter_test.rb
|
573
|
+
- test/test_helper.rb
|
574
|
+
- test/forest_liana_test.rb
|
576
575
|
- test/services/forest_liana/has_many_getter_test.rb
|
577
576
|
- test/services/forest_liana/resource_updater_test.rb
|
578
|
-
- test/services/forest_liana/pie_stat_getter_test.rb
|
579
577
|
- test/services/forest_liana/schema_adapter_test.rb
|
580
578
|
- test/services/forest_liana/scope_validator_test.rb
|
579
|
+
- test/services/forest_liana/value_stat_getter_test.rb
|
580
|
+
- test/services/forest_liana/pie_stat_getter_test.rb
|
581
|
+
- test/fixtures/owner.yml
|
582
|
+
- test/fixtures/has_many_through_field.yml
|
583
|
+
- test/fixtures/reference.yml
|
584
|
+
- test/fixtures/has_many_field.yml
|
585
|
+
- test/fixtures/has_one_field.yml
|
586
|
+
- test/fixtures/belongs_to_field.yml
|
587
|
+
- test/fixtures/string_field.yml
|
588
|
+
- test/fixtures/serialize_field.yml
|
589
|
+
- test/fixtures/tree.yml
|
581
590
|
- test/routing/route_test.rb
|
582
|
-
-
|
583
|
-
-
|
584
|
-
- spec/dummy/
|
585
|
-
- spec/dummy/
|
591
|
+
- spec/dummy/db/migrate/20190716135241_add_type_to_user.rb
|
592
|
+
- spec/dummy/db/migrate/20210326110524_create_references.rb
|
593
|
+
- spec/dummy/db/migrate/20190226173051_create_isle.rb
|
594
|
+
- spec/dummy/db/migrate/20190226174951_create_tree.rb
|
595
|
+
- spec/dummy/db/migrate/20190716130830_add_age_to_tree.rb
|
596
|
+
- spec/dummy/db/migrate/20190226172951_create_user.rb
|
597
|
+
- spec/dummy/db/migrate/20210326140855_create_locations.rb
|
598
|
+
- spec/dummy/db/schema.rb
|
599
|
+
- spec/dummy/lib/forest_liana/collections/location.rb
|
600
|
+
- spec/dummy/lib/forest_liana/collections/user.rb
|
601
|
+
- spec/dummy/Rakefile
|
602
|
+
- spec/dummy/app/controllers/application_controller.rb
|
603
|
+
- spec/dummy/app/models/island.rb
|
604
|
+
- spec/dummy/app/models/reference.rb
|
605
|
+
- spec/dummy/app/models/location.rb
|
606
|
+
- spec/dummy/app/models/tree.rb
|
607
|
+
- spec/dummy/app/models/user.rb
|
608
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
609
|
+
- spec/dummy/app/assets/javascripts/application.js
|
610
|
+
- spec/dummy/app/assets/config/manifest.js
|
611
|
+
- spec/dummy/app/config/routes.rb
|
612
|
+
- spec/dummy/app/helpers/application_helper.rb
|
613
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
614
|
+
- spec/dummy/README.rdoc
|
615
|
+
- spec/dummy/config.ru
|
586
616
|
- spec/dummy/config/environment.rb
|
587
617
|
- spec/dummy/config/secrets.yml
|
588
|
-
- spec/dummy/config/environments/development.rb
|
589
|
-
- spec/dummy/config/environments/test.rb
|
590
|
-
- spec/dummy/config/environments/production.rb
|
591
618
|
- spec/dummy/config/boot.rb
|
592
|
-
- spec/dummy/config/
|
619
|
+
- spec/dummy/config/database.yml
|
620
|
+
- spec/dummy/config/routes.rb
|
621
|
+
- spec/dummy/config/application.rb
|
622
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
623
|
+
- spec/dummy/config/initializers/forest_liana.rb
|
593
624
|
- spec/dummy/config/initializers/mime_types.rb
|
594
|
-
- spec/dummy/config/initializers/
|
595
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
625
|
+
- spec/dummy/config/initializers/session_store.rb
|
596
626
|
- spec/dummy/config/initializers/inflections.rb
|
597
|
-
- spec/dummy/config/initializers/forest_liana.rb
|
598
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
599
627
|
- spec/dummy/config/initializers/assets.rb
|
628
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
600
629
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
601
|
-
- spec/dummy/config/
|
602
|
-
- spec/dummy/
|
603
|
-
- spec/dummy/
|
604
|
-
- spec/dummy/
|
605
|
-
- spec/dummy/app/assets/javascripts/application.js
|
606
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
607
|
-
- spec/dummy/app/controllers/application_controller.rb
|
608
|
-
- spec/dummy/app/models/tree.rb
|
609
|
-
- spec/dummy/app/models/user.rb
|
610
|
-
- spec/dummy/app/models/island.rb
|
611
|
-
- spec/dummy/app/helpers/application_helper.rb
|
612
|
-
- spec/dummy/Rakefile
|
613
|
-
- spec/dummy/config.ru
|
614
|
-
- spec/dummy/README.rdoc
|
615
|
-
- spec/dummy/bin/rails
|
630
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
631
|
+
- spec/dummy/config/environments/test.rb
|
632
|
+
- spec/dummy/config/environments/production.rb
|
633
|
+
- spec/dummy/config/environments/development.rb
|
616
634
|
- spec/dummy/bin/rake
|
617
635
|
- spec/dummy/bin/bundle
|
636
|
+
- spec/dummy/bin/rails
|
618
637
|
- spec/dummy/bin/setup
|
619
|
-
- spec/dummy/db/schema.rb
|
620
|
-
- spec/dummy/db/migrate/20190226173051_create_isle.rb
|
621
|
-
- spec/dummy/db/migrate/20190226174951_create_tree.rb
|
622
|
-
- spec/dummy/db/migrate/20190226172951_create_user.rb
|
623
|
-
- spec/dummy/db/migrate/20190716135241_add_type_to_user.rb
|
624
|
-
- spec/dummy/db/migrate/20190716130830_add_age_to_tree.rb
|
625
|
-
- spec/requests/resources_spec.rb
|
626
|
-
- spec/requests/authentications_spec.rb
|
627
|
-
- spec/requests/actions_controller_spec.rb
|
628
|
-
- spec/spec_helper.rb
|
629
|
-
- spec/services/forest_liana/filters_parser_spec.rb
|
630
638
|
- spec/services/forest_liana/permissions_checker_acl_disabled_spec.rb
|
639
|
+
- spec/services/forest_liana/resources_getter_spec.rb
|
640
|
+
- spec/services/forest_liana/permissions_formatter_spec.rb
|
641
|
+
- spec/services/forest_liana/permissions_checker_live_queries_spec.rb
|
642
|
+
- spec/services/forest_liana/permissions_getter_spec.rb
|
631
643
|
- spec/services/forest_liana/schema_adapter_spec.rb
|
632
|
-
- spec/services/forest_liana/permissions_checker_acl_enabled_spec.rb
|
633
644
|
- spec/services/forest_liana/apimap_sorter_spec.rb
|
634
|
-
- spec/services/forest_liana/
|
645
|
+
- spec/services/forest_liana/permissions_checker_acl_enabled_spec.rb
|
635
646
|
- spec/services/forest_liana/ip_whitelist_checker_spec.rb
|
636
|
-
- spec/services/forest_liana/
|
647
|
+
- spec/services/forest_liana/filters_parser_spec.rb
|
637
648
|
- spec/rails_helper.rb
|
638
|
-
- spec/
|
649
|
+
- spec/requests/resources_spec.rb
|
650
|
+
- spec/requests/authentications_spec.rb
|
651
|
+
- spec/requests/actions_controller_spec.rb
|
652
|
+
- spec/requests/stats_spec.rb
|
639
653
|
- spec/helpers/forest_liana/is_same_data_structure_helper_spec.rb
|
654
|
+
- spec/helpers/forest_liana/schema_helper_spec.rb
|
640
655
|
- spec/helpers/forest_liana/query_helper_spec.rb
|
656
|
+
- spec/spec_helper.rb
|
@@ -1,284 +0,0 @@
|
|
1
|
-
module ForestLiana
|
2
|
-
class ResourcesGetterTest < ActiveSupport::TestCase
|
3
|
-
|
4
|
-
test 'StringField page 1 size 15' do
|
5
|
-
getter = ResourcesGetter.new(StringField, {
|
6
|
-
page: { size: 15, number: 1 },
|
7
|
-
sort: '-id',
|
8
|
-
timezone: 'America/Nome'
|
9
|
-
})
|
10
|
-
getter.perform
|
11
|
-
records = getter.records
|
12
|
-
count = getter.count
|
13
|
-
|
14
|
-
assert records.count == 15
|
15
|
-
assert count = 30
|
16
|
-
assert records.first.id == 30
|
17
|
-
assert records.last.id == 16
|
18
|
-
end
|
19
|
-
|
20
|
-
test 'on a model having a reserved name' do
|
21
|
-
getter = ResourcesGetter.new(Reference, {
|
22
|
-
page: { size: 10, number: 1 },
|
23
|
-
sort: '-id',
|
24
|
-
timezone: 'America/Nome'
|
25
|
-
})
|
26
|
-
getter.perform
|
27
|
-
records = getter.records
|
28
|
-
count = getter.count
|
29
|
-
|
30
|
-
assert records.count == 1
|
31
|
-
assert count = 1
|
32
|
-
assert records.first.id == 1
|
33
|
-
end
|
34
|
-
|
35
|
-
test 'StringField page 2 size 10' do
|
36
|
-
getter = ResourcesGetter.new(StringField, {
|
37
|
-
page: { size: 10, number: 2 },
|
38
|
-
sort: '-id',
|
39
|
-
timezone: 'America/Nome'
|
40
|
-
})
|
41
|
-
getter.perform
|
42
|
-
records = getter.records
|
43
|
-
count = getter.count
|
44
|
-
|
45
|
-
assert records.count == 10
|
46
|
-
assert count = 30
|
47
|
-
assert records.first.id == 20
|
48
|
-
assert records.last.id == 11
|
49
|
-
end
|
50
|
-
|
51
|
-
test 'StringField sort by field' do
|
52
|
-
getter = ResourcesGetter.new(StringField, {
|
53
|
-
page: { size: 10, number: 1 },
|
54
|
-
sort: '-field',
|
55
|
-
timezone: 'America/Nome'
|
56
|
-
})
|
57
|
-
getter.perform
|
58
|
-
records = getter.records
|
59
|
-
count = getter.count
|
60
|
-
|
61
|
-
assert records.count == 10
|
62
|
-
assert count = 30
|
63
|
-
assert records.map(&:field) == ['Test 9', 'Test 8', 'Test 7', 'Test 6',
|
64
|
-
'Test 5', 'Test 4', 'Test 30', 'Test 3',
|
65
|
-
'Test 29', 'Test 28']
|
66
|
-
end
|
67
|
-
|
68
|
-
test 'Sort by a belongs_to association' do
|
69
|
-
getter = ResourcesGetter.new(BelongsToField, {
|
70
|
-
page: { size: 10, number: 1 },
|
71
|
-
sort: 'has_one_field.id',
|
72
|
-
timezone: 'America/Nome'
|
73
|
-
})
|
74
|
-
getter.perform
|
75
|
-
records = getter.records
|
76
|
-
count = getter.count
|
77
|
-
|
78
|
-
assert records.count == 10
|
79
|
-
assert count = 30
|
80
|
-
assert records.first.has_one_field_id == 1
|
81
|
-
assert records.last.has_one_field_id == 10
|
82
|
-
end
|
83
|
-
|
84
|
-
test 'Sort by a has_one association' do
|
85
|
-
getter = ResourcesGetter.new(HasOneField, {
|
86
|
-
page: { size: 10, number: 1 },
|
87
|
-
sort: '-belongs_to_field.id',
|
88
|
-
timezone: 'America/Nome'
|
89
|
-
})
|
90
|
-
getter.perform
|
91
|
-
records = getter.records
|
92
|
-
count = getter.count
|
93
|
-
|
94
|
-
assert records.count == 10
|
95
|
-
assert count = 30
|
96
|
-
assert records.first.belongs_to_field.id == 30
|
97
|
-
assert records.last.belongs_to_field.id == 21
|
98
|
-
end
|
99
|
-
|
100
|
-
test 'Filter on ambiguous field' do
|
101
|
-
getter = ResourcesGetter.new(Tree, {
|
102
|
-
fields: { 'Tree' => 'id' },
|
103
|
-
page: { size: 10, number: 1 },
|
104
|
-
filters: {
|
105
|
-
aggregator: 'and',
|
106
|
-
conditions: [{
|
107
|
-
field: 'created_at',
|
108
|
-
operator: 'after',
|
109
|
-
value: "#{Time.now.year - 5}-06-18 08:00:00",
|
110
|
-
}, {
|
111
|
-
field: 'owner:name',
|
112
|
-
operator: 'equal',
|
113
|
-
value: 'Arnaud Besnier'
|
114
|
-
}]
|
115
|
-
}.to_json,
|
116
|
-
timezone: 'America/Nome'
|
117
|
-
})
|
118
|
-
getter.perform
|
119
|
-
records = getter.records
|
120
|
-
count = getter.count
|
121
|
-
|
122
|
-
assert records.count == 1
|
123
|
-
assert count = 1
|
124
|
-
assert records.first.id == 4
|
125
|
-
assert records.first.name == 'Oak'
|
126
|
-
assert records.first.owner.name == 'Arnaud Besnier'
|
127
|
-
end
|
128
|
-
|
129
|
-
test 'Filter before x hours' do
|
130
|
-
getter = ResourcesGetter.new(Tree, {
|
131
|
-
fields: { 'Tree' => 'id' },
|
132
|
-
page: { size: 10, number: 1 },
|
133
|
-
filters: {
|
134
|
-
field: 'created_at',
|
135
|
-
operator: 'before_x_hours_ago',
|
136
|
-
value: 3
|
137
|
-
}.to_json,
|
138
|
-
timezone: 'America/Nome'
|
139
|
-
})
|
140
|
-
getter.perform
|
141
|
-
records = getter.records
|
142
|
-
count = getter.count
|
143
|
-
|
144
|
-
assert records.count == 5
|
145
|
-
assert count = 5
|
146
|
-
assert records.first.id == 4
|
147
|
-
assert records.first.name == 'Oak'
|
148
|
-
assert records.first.owner.name == 'Arnaud Besnier'
|
149
|
-
end
|
150
|
-
|
151
|
-
test 'Filter after x hours' do
|
152
|
-
getter = ResourcesGetter.new(Tree, {
|
153
|
-
fields: { 'Tree' => 'id' },
|
154
|
-
page: { size: 10, number: 1 },
|
155
|
-
filters: {
|
156
|
-
field: 'created_at',
|
157
|
-
operator: 'after_x_hours_ago',
|
158
|
-
value: 3
|
159
|
-
}.to_json,
|
160
|
-
timezone: 'America/Nome'
|
161
|
-
})
|
162
|
-
getter.perform
|
163
|
-
records = getter.records
|
164
|
-
count = getter.count
|
165
|
-
|
166
|
-
assert records.count == 3
|
167
|
-
assert count = 3
|
168
|
-
end
|
169
|
-
|
170
|
-
test 'Sort on an ambiguous field name with a filter' do
|
171
|
-
getter = ResourcesGetter.new(Tree, {
|
172
|
-
fields: { 'Tree' => 'id' },
|
173
|
-
page: { size: 10, number: 1 },
|
174
|
-
sort: '-name',
|
175
|
-
filters: {
|
176
|
-
field: 'owner:name',
|
177
|
-
operator: 'equal',
|
178
|
-
value: 'Arnaud Besnier'
|
179
|
-
}.to_json,
|
180
|
-
timezone: 'America/Nome'
|
181
|
-
})
|
182
|
-
getter.perform
|
183
|
-
records = getter.records
|
184
|
-
count = getter.count
|
185
|
-
|
186
|
-
assert records.count == 3
|
187
|
-
assert count = 3
|
188
|
-
assert records.first.name == 'Oak'
|
189
|
-
assert records.last.name == 'Mapple'
|
190
|
-
end
|
191
|
-
|
192
|
-
test 'Filter on an updated_at field of the main collection' do
|
193
|
-
getter = ResourcesGetter.new(Owner, {
|
194
|
-
page: { size: 10, number: 1 },
|
195
|
-
filters: {
|
196
|
-
field: 'updated_at',
|
197
|
-
operator: 'previous_year'
|
198
|
-
}.to_json,
|
199
|
-
timezone: 'America/Nome'
|
200
|
-
})
|
201
|
-
getter.perform
|
202
|
-
records = getter.records
|
203
|
-
count = getter.count
|
204
|
-
|
205
|
-
assert records.count == 1
|
206
|
-
assert count = 1
|
207
|
-
assert records.first.id == 3
|
208
|
-
end
|
209
|
-
|
210
|
-
test 'Filter on an updated_at field of an associated collection' do
|
211
|
-
getter = ResourcesGetter.new(Tree, {
|
212
|
-
fields: { 'Tree' => 'id' },
|
213
|
-
page: { size: 10, number: 1 },
|
214
|
-
filters: {
|
215
|
-
field: 'owner:updated_at',
|
216
|
-
operator: 'previous_year'
|
217
|
-
}.to_json,
|
218
|
-
timezone: 'America/Nome'
|
219
|
-
})
|
220
|
-
getter.perform
|
221
|
-
records = getter.records
|
222
|
-
count = getter.count
|
223
|
-
|
224
|
-
assert records.count == 2
|
225
|
-
assert count = 2
|
226
|
-
assert records.first.id == 6
|
227
|
-
end
|
228
|
-
|
229
|
-
test 'Filter equal on an updated_at field of an associated collection' do
|
230
|
-
getter = ResourcesGetter.new(Tree, {
|
231
|
-
fields: { 'Tree' => 'id' },
|
232
|
-
page: { size: 10, number: 1 },
|
233
|
-
filters: {
|
234
|
-
field: 'owner:updated_at',
|
235
|
-
operator: 'equal',
|
236
|
-
value: 'Sat Jul 02 2016 11:52:00 GMT-0400 (EDT)',
|
237
|
-
}.to_json,
|
238
|
-
timezone: 'America/Nome'
|
239
|
-
})
|
240
|
-
getter.perform
|
241
|
-
records = getter.records
|
242
|
-
count = getter.count
|
243
|
-
|
244
|
-
assert records.count == 0
|
245
|
-
assert count = 0
|
246
|
-
end
|
247
|
-
|
248
|
-
test 'Filter on a field of an associated collection that does not exist' do
|
249
|
-
exception = assert_raises(ForestLiana::Errors::HTTP422Error) {
|
250
|
-
ForestLiana::ResourcesGetter.new(Tree, {
|
251
|
-
fields: { 'Tree' => 'id'},
|
252
|
-
searchExtended: '0',
|
253
|
-
timezone: 'Europe/Paris',
|
254
|
-
filters: {
|
255
|
-
field: 'leaf:id',
|
256
|
-
operator: 'equal',
|
257
|
-
value: 1
|
258
|
-
}.to_json,
|
259
|
-
collection: 'Tree'
|
260
|
-
})
|
261
|
-
}
|
262
|
-
assert_equal("Association 'leaf' not found", exception.message)
|
263
|
-
end
|
264
|
-
|
265
|
-
test 'Filter on a field that does not exists' do
|
266
|
-
exception = assert_raises(ForestLiana::Errors::HTTP422Error) {
|
267
|
-
ForestLiana::ResourcesGetter.new(Tree, {
|
268
|
-
fields: { 'Tree' => 'id'},
|
269
|
-
searchExtended: '0',
|
270
|
-
timezone: 'Europe/Paris',
|
271
|
-
filters: {
|
272
|
-
field: 'content',
|
273
|
-
operator: 'contains',
|
274
|
-
value: 'c'
|
275
|
-
}.to_json,
|
276
|
-
collection: 'Article'
|
277
|
-
})
|
278
|
-
}
|
279
|
-
|
280
|
-
assert_equal("Field 'content' not found", exception.message)
|
281
|
-
end
|
282
|
-
|
283
|
-
end
|
284
|
-
end
|