has_helpers 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +38 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.tekton/Chart.yaml +14 -0
- data/.tekton/templates/pipelinerun.yaml +44 -0
- data/.tekton/values-main.yaml +53 -0
- data/.tekton/values-pr.yaml +40 -0
- data/.tekton/values.yaml +17 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +204 -0
- data/Gemfile +25 -0
- data/README.md +76 -0
- data/Rakefile +46 -0
- data/app/api/has_helpers/rack_api.rb +116 -0
- data/app/api/has_helpers/search_api.rb +173 -0
- data/app/assets/stylesheets/has_helpers/base.scss +5 -0
- data/app/assets/stylesheets/has_helpers/color_palette.scss +33 -0
- data/app/assets/stylesheets/has_helpers/color_palettes/default.scss +11 -0
- data/app/assets/stylesheets/has_helpers/components/dataset.scss +43 -0
- data/app/assets/stylesheets/has_helpers/mixins.scss +149 -0
- data/app/commands/has_helpers/cards/available_cards_command.rb +98 -0
- data/app/commands/has_helpers/cards/card_data_command.rb +1062 -0
- data/app/commands/reports/base_options.rb +79 -0
- data/app/commands/reports/belongs_to_options.rb +178 -0
- data/app/commands/reports/constant_options.rb +66 -0
- data/app/commands/reports/external_graphql_client.rb +116 -0
- data/app/commands/reports/fill_dates.rb +65 -0
- data/app/commands/reports/filter_option_generator.rb +186 -0
- data/app/commands/reports/generator.rb +310 -0
- data/app/commands/reports/has_many_options.rb +105 -0
- data/app/commands/reports/importer.rb +132 -0
- data/app/commands/reports/nested_attribute_options.rb +134 -0
- data/app/constants/color.rb +9 -0
- data/app/constants/file_format.rb +12 -0
- data/app/constants/has_helpers/cards/card_custom_field.rb +12 -0
- data/app/constants/has_helpers/cards/card_data_type.rb +11 -0
- data/app/constants/has_helpers/cards/card_identifier.rb +10 -0
- data/app/constants/has_helpers/cards/card_layout_type.rb +11 -0
- data/app/constants/has_helpers/cards/card_variant_type.rb +12 -0
- data/app/constants/has_helpers/link_type.rb +10 -0
- data/app/constants/has_helpers/notification_alert_status.rb +14 -0
- data/app/constants/has_helpers/notification_alert_type.rb +10 -0
- data/app/constants/has_helpers/operation.rb +11 -0
- data/app/constants/has_helpers/resource_type.rb +25 -0
- data/app/constants/icon.rb +22 -0
- data/app/constants/logical_operator.rb +7 -0
- data/app/constants/option.rb +10 -0
- data/app/constants/time_zone.rb +12 -0
- data/app/constructors/has_helpers/base_constructor.rb +62 -0
- data/app/controllers/concerns/has_helpers/service_trust/authenticated_as_service.rb +51 -0
- data/app/controllers/concerns/has_helpers/service_trust/graphql_authentication.rb +57 -0
- data/app/controllers/has_helpers/controller.rb +63 -0
- data/app/controllers/has_helpers/factory_controller.rb +261 -0
- data/app/controllers/has_helpers/graphql_extensions.rb +83 -0
- data/app/controllers/has_helpers/health_check_controller.rb +46 -0
- data/app/controllers/has_helpers/search_extensions.rb +92 -0
- data/app/controllers/has_helpers/service_trust/jwks_controller.rb +20 -0
- data/app/controllers/has_helpers/xlsx_export.rb +115 -0
- data/app/controllers/search_extensions.rb +5 -0
- data/app/graphql/has_helpers/base_type.rb +13 -0
- data/app/graphql/has_helpers/base_union.rb +9 -0
- data/app/graphql/has_helpers/enums/resource_enum.rb +24 -0
- data/app/graphql/has_helpers/middleware/application_access.rb +26 -0
- data/app/graphql/has_helpers/mutations/base.rb +27 -0
- data/app/graphql/has_helpers/mutations/external_data_sync.rb +72 -0
- data/app/graphql/has_helpers/mutations/mark_individual_alert_read.rb +31 -0
- data/app/graphql/has_helpers/mutations/mark_notifications_read.rb +50 -0
- data/app/graphql/has_helpers/mutations/toggle_favorite.rb +39 -0
- data/app/graphql/has_helpers/resolvers/app_nav.rb +107 -0
- data/app/graphql/has_helpers/resolvers/base.rb +27 -0
- data/app/graphql/has_helpers/resolvers/cards/available_cards.rb +31 -0
- data/app/graphql/has_helpers/resolvers/cards/card_data.rb +74 -0
- data/app/graphql/has_helpers/resolvers/cards/hover_card_data.rb +153 -0
- data/app/graphql/has_helpers/resolvers/favorite.rb +62 -0
- data/app/graphql/has_helpers/resolvers/internal/roles.rb +54 -0
- data/app/graphql/has_helpers/resolvers/is_favorite.rb +24 -0
- data/app/graphql/has_helpers/resolvers/list_notification_alerts.rb +47 -0
- data/app/graphql/has_helpers/resolvers/lookup.rb +36 -0
- data/app/graphql/has_helpers/resolvers/recently_viewed.rb +54 -0
- data/app/graphql/has_helpers/resolvers/resource_tab.rb +22 -0
- data/app/graphql/has_helpers/resolvers/search.rb +18 -0
- data/app/graphql/has_helpers/resolvers/search_query.rb +38 -0
- data/app/graphql/has_helpers/resolvers/user_application_order.rb +35 -0
- data/app/graphql/has_helpers/resources/organization_option_resource.rb +28 -0
- data/app/graphql/has_helpers/resources/organization_resource_resource.rb +18 -0
- data/app/graphql/has_helpers/resources/resource_group_resource.rb +10 -0
- data/app/graphql/has_helpers/resources/resource_resource.rb +21 -0
- data/app/graphql/has_helpers/resources/user_role_resource.rb +9 -0
- data/app/graphql/has_helpers/types/application_order_type.rb +18 -0
- data/app/graphql/has_helpers/types/cards/available_card_type.rb +20 -0
- data/app/graphql/has_helpers/types/cards/card_badge_type.rb +12 -0
- data/app/graphql/has_helpers/types/cards/card_config_type.rb +18 -0
- data/app/graphql/has_helpers/types/cards/card_data_type.rb +13 -0
- data/app/graphql/has_helpers/types/cards/card_entry_field_type.rb +21 -0
- data/app/graphql/has_helpers/types/cards/card_entry_type.rb +12 -0
- data/app/graphql/has_helpers/types/cards/card_field_config_type.rb +17 -0
- data/app/graphql/has_helpers/types/layouts/app_nav/link_section_type.rb +17 -0
- data/app/graphql/has_helpers/types/layouts/app_nav/link_type.rb +20 -0
- data/app/graphql/has_helpers/types/layouts/app_nav/sub_link_type.rb +17 -0
- data/app/graphql/has_helpers/types/layouts/app_nav/type.rb +16 -0
- data/app/graphql/has_helpers/types/lookup.rb +16 -0
- data/app/graphql/has_helpers/types/resource_tab/type.rb +15 -0
- data/app/graphql/has_helpers/types/role_type.rb +13 -0
- data/app/graphql/has_helpers/types/search/detail_badge_type.rb +15 -0
- data/app/graphql/has_helpers/types/search/detail_item_type.rb +14 -0
- data/app/graphql/has_helpers/types/search/detail_type.rb +16 -0
- data/app/graphql/has_helpers/types/search/filter_operation_enum.rb +19 -0
- data/app/graphql/has_helpers/types/search/input_type.rb +16 -0
- data/app/graphql/has_helpers/types/search/result_type.rb +72 -0
- data/app/graphql/has_helpers/types/search/search_filter_input_type.rb +17 -0
- data/app/graphql/has_helpers/types/search/type.rb +17 -0
- data/app/importers/has_helpers/cards/importer.rb +1223 -0
- data/app/lib/has_helpers/application_helper.rb +21 -0
- data/app/lib/has_helpers/dn/processor.rb +55 -0
- data/app/lib/has_helpers/dn/refresh.rb +13 -0
- data/app/lib/has_helpers/dn/utils/backfill_utils.rb +80 -0
- data/app/lib/has_helpers/dn/utils/query_utils.rb +216 -0
- data/app/lib/has_helpers/feature.rb +88 -0
- data/app/lib/has_helpers/hq_exception.rb +18 -0
- data/app/lib/has_helpers/index.rb +890 -0
- data/app/lib/has_helpers/organization_merge.rb +128 -0
- data/app/lib/has_helpers/query/elasticsearch.rb +20 -0
- data/app/lib/has_helpers/query/provider.rb +105 -0
- data/app/lib/has_helpers/query/sql.rb +133 -0
- data/app/lib/has_helpers/query.rb +14 -0
- data/app/lib/has_helpers/search/elasticsearch.rb +41 -0
- data/app/lib/has_helpers/search/elasticsearch_shared.rb +70 -0
- data/app/lib/has_helpers/search/provider.rb +149 -0
- data/app/lib/has_helpers/search/search_utils.rb +74 -0
- data/app/lib/has_helpers/search/sql_search.rb +219 -0
- data/app/lib/has_helpers/search.rb +46 -0
- data/app/models/ability.rb +233 -0
- data/app/models/has_helpers/application.rb +47 -0
- data/app/models/has_helpers/application_record.rb +7 -0
- data/app/models/has_helpers/cards/card_builder/base.rb +74 -0
- data/app/models/has_helpers/cards/card_builder/card_definition_builder.rb +486 -0
- data/app/models/has_helpers/cards/card_builder/definition_context.rb +82 -0
- data/app/models/has_helpers/cards/card_builder/field_builder.rb +142 -0
- data/app/models/has_helpers/cards/card_builder/resource_builder.rb +34 -0
- data/app/models/has_helpers/cards/card_definition.rb +41 -0
- data/app/models/has_helpers/cards/card_definition_resource.rb +19 -0
- data/app/models/has_helpers/cards/card_field.rb +39 -0
- data/app/models/has_helpers/cards/registry.rb +115 -0
- data/app/models/has_helpers/cards/role_card_field.rb +28 -0
- data/app/models/has_helpers/cards/role_resource_card.rb +41 -0
- data/app/models/has_helpers/dn_utils.rb +61 -0
- data/app/models/has_helpers/favorite.rb +20 -0
- data/app/models/has_helpers/master_record.rb +18 -0
- data/app/models/has_helpers/notification_alert.rb +52 -0
- data/app/models/has_helpers/organization.rb +16 -0
- data/app/models/has_helpers/organization_link.rb +92 -0
- data/app/models/has_helpers/organization_methods.rb +62 -0
- data/app/models/has_helpers/organization_option.rb +31 -0
- data/app/models/has_helpers/organization_resource.rb +45 -0
- data/app/models/has_helpers/pending_db_operation.rb +31 -0
- data/app/models/has_helpers/recently_viewed.rb +34 -0
- data/app/models/has_helpers/reindex_queue.rb +43 -0
- data/app/models/has_helpers/resource.rb +38 -0
- data/app/models/has_helpers/resource_group.rb +15 -0
- data/app/models/has_helpers/restriction.rb +15 -0
- data/app/models/has_helpers/restriction_operation.rb +13 -0
- data/app/models/has_helpers/role.rb +20 -0
- data/app/models/has_helpers/service_trust/audit_log.rb +20 -0
- data/app/models/has_helpers/service_trust/key.rb +56 -0
- data/app/models/has_helpers/stat.rb +13 -0
- data/app/models/has_helpers/user.rb +18 -0
- data/app/models/has_helpers/user_methods.rb +184 -0
- data/app/models/has_helpers/user_organization.rb +33 -0
- data/app/models/has_helpers/user_role.rb +27 -0
- data/app/models/has_helpers/user_session.rb +19 -0
- data/app/presenters/has_helpers/barcode_base_presenter.rb +113 -0
- data/app/presenters/has_helpers/base_presenter.rb +100 -0
- data/app/presenters/has_helpers/cacheable_item.rb +28 -0
- data/app/presenters/has_helpers/item_presenter.rb +52 -0
- data/app/presenters/has_helpers/items_presenter.rb +33 -0
- data/app/presenters/has_helpers/resource/action_presenter.rb +8 -0
- data/app/presenters/has_helpers/resource/cell_presenter.rb +52 -0
- data/app/presenters/has_helpers/resource/email_presenter.rb +34 -0
- data/app/presenters/has_helpers/resource/form_presenter.rb +76 -0
- data/app/presenters/has_helpers/resource/info_collection_presenter.rb +33 -0
- data/app/presenters/has_helpers/resource/info_presenter.rb +34 -0
- data/app/presenters/has_helpers/resource/list_presenter.rb +120 -0
- data/app/presenters/has_helpers/resource/note_presenter.rb +14 -0
- data/app/presenters/has_helpers/resource/row_presenter.rb +25 -0
- data/app/presenters/has_helpers/resource/tag_presenter.rb +31 -0
- data/app/presenters/has_helpers/search_presenter.rb +230 -0
- data/app/triggers/has_helpers/erase_denormalized_belongs_to_column_trigger.rb +85 -0
- data/app/triggers/has_helpers/limit_favorites.rb +97 -0
- data/app/utils/has_helpers/redis_configurable.rb +79 -0
- data/app/utils/has_helpers/sync_utils.rb +234 -0
- data/app/views/has_helpers/actions/_action.html.erb +31 -0
- data/app/views/has_helpers/alerts/_alert.html.erb +3 -0
- data/app/views/has_helpers/barcodes.html.erb +36 -0
- data/app/views/has_helpers/containers/_container.html.erb +3 -0
- data/app/views/has_helpers/email_notifier/system.html.erb +8 -0
- data/app/views/has_helpers/email_notifier/system.text.erb +7 -0
- data/app/views/has_helpers/enumerables/_enumerable.html.erb +1 -0
- data/app/views/has_helpers/icons/_icon.html.erb +1 -0
- data/app/views/has_helpers/render_objects/_render_object.html.erb +1 -0
- data/app/views/has_helpers/services/_service.html.erb +1 -0
- data/app/views/has_helpers/text_nodes/_text_node.html.erb +4 -0
- data/app/views/has_helpers/ui_attributes/_html_attrs.html.erb +1 -0
- data/app/workers/elasticsearch_process_queue.rb +11 -0
- data/app/workers/elasticsearch_reindex.rb +11 -0
- data/app/workers/elasticsearch_reindex_scheduler.rb +35 -0
- data/app/workers/good_job/configurable_backfill.rb +64 -0
- data/app/workers/good_job/cron_denormalization_stats_manager.rb +39 -0
- data/app/workers/good_job/denormalization_stats_worker.rb +57 -0
- data/app/workers/good_job/dn_update_worker.rb +30 -0
- data/app/workers/good_job/dn_worker.rb +47 -0
- data/app/workers/good_job/elasticsearch_old_index_cleaner_worker.rb +113 -0
- data/app/workers/good_job/elasticsearch_on_finish_reindex.rb +26 -0
- data/app/workers/good_job/elasticsearch_process_batch.rb +78 -0
- data/app/workers/good_job/elasticsearch_process_change_logs_master_worker.rb +27 -0
- data/app/workers/good_job/elasticsearch_process_change_logs_worker.rb +155 -0
- data/app/workers/good_job/elasticsearch_process_queue.rb +50 -0
- data/app/workers/good_job/elasticsearch_reindex.rb +31 -0
- data/app/workers/has_helpers/cards/orphan_card_sweeper.rb +28 -0
- data/app/workers/has_helpers/db_operations/clean_stats_worker.rb +42 -0
- data/app/workers/has_helpers/db_operations/helper_worker.rb +131 -0
- data/app/workers/has_helpers/db_operations/main_worker.rb +164 -0
- data/app/workers/has_helpers/db_operations/operations.rb +134 -0
- data/app/workers/has_helpers/db_operations/update_operations_stats_resume_worker.rb +35 -0
- data/app/workers/has_helpers/default_worker.rb +17 -0
- data/app/workers/has_helpers/good_job/notification_alert_cleanup_worker.rb +43 -0
- data/app/workers/has_helpers/service_trust/audit_log_cleanup_worker.rb +19 -0
- data/app/workers/sidekiq/elasticsearch_old_index_cleaner_worker.rb +112 -0
- data/app/workers/sidekiq/elasticsearch_process_batch.rb +87 -0
- data/app/workers/sidekiq/elasticsearch_process_queue.rb +40 -0
- data/app/workers/sidekiq/elasticsearch_reindex.rb +53 -0
- data/config/initializers/action_view.rb +7 -0
- data/config/initializers/inflections.rb +24 -0
- data/config/initializers/marginalia.rb +8 -0
- data/config/initializers/mime_types.rb +6 -0
- data/config/initializers/opentelemetry.rb +12 -0
- data/config/initializers/redis_conf.rb +40 -0
- data/config/initializers/searchkick.rb +9 -0
- data/config/initializers/will_paginate.rb +39 -0
- data/config/redis.yml +12 -0
- data/config/routes.rb +27 -0
- data/config/service_trust_routes.rb +5 -0
- data/config.ru +9 -0
- data/db/migrate/20230127194725_create_organization_table.rb +25 -0
- data/db/migrate/20230127194726_validate_organization_foreign_keys.rb +7 -0
- data/db/migrate/20230206141413_create_security_models.rb +42 -0
- data/db/migrate/20230206141513_create_restriction_model.rb +20 -0
- data/db/migrate/20230206142613_add_security_indexes.rb +14 -0
- data/db/migrate/20230206143513_security_model_constants_seed.rb +8 -0
- data/db/migrate/20230206161513_add_organization_to_security_models.rb +13 -0
- data/db/migrate/20230209121019_create_search_group_models.rb +36 -0
- data/db/migrate/20230209122919_add_search_group_indexes.rb +21 -0
- data/db/migrate/20230209181832_add_search_group_resources_type_constraint_trigger.rb +61 -0
- data/db/migrate/20230313220337_create_table_user_sessions.rb +31 -0
- data/db/migrate/20230517141106_update_resource_types.rb +12 -0
- data/db/migrate/20230518194611_add_resources_contraints.rb +17 -0
- data/db/migrate/20230518194642_create_nested_resource_model.rb +21 -0
- data/db/migrate/20230518194645_validate_security_models_constraints.rb +23 -0
- data/db/migrate/20230608125037_add_inactive_field_to_user_sessions.rb +7 -0
- data/db/migrate/20230919191525_add_parent_id_to_resources.rb +8 -0
- data/db/migrate/20230919191535_validate_parent_id_fk_resources.rb +7 -0
- data/db/migrate/20230919210456_drop_nested_resources.rb +7 -0
- data/db/migrate/20231222135620_add_user_role.rb +19 -0
- data/db/migrate/20240108172021_create_favorites_table.rb +20 -0
- data/db/migrate/20240108190209_create_organization_link_table_if_doesnt_exists.rb +31 -0
- data/db/migrate/20240109211445_validate_fks_org_links.rb +9 -0
- data/db/migrate/20240110135440_create_recently_vieweds.rb +20 -0
- data/db/migrate/20240112185312_link_type_options_seed.rb +7 -0
- data/db/migrate/20240116173201_organization_link_resource_tab_constraints.rb +19 -0
- data/db/migrate/20240131160949_add_user_organizations_table.rb +32 -0
- data/db/migrate/20240212132519_add_organization_in_user_sessions.rb +13 -0
- data/db/migrate/20240227135052_add_user_organization_composite_fks.rb +32 -0
- data/db/migrate/20240312193501_update_organization_links.rb +11 -0
- data/db/migrate/20240426185902_add_user_organizations_current_organization_column.rb +12 -0
- data/db/migrate/20240429214601_add_primary_trigger.rb +10 -0
- data/db/migrate/20241112131819_add_json_file_format_seed.rb +7 -0
- data/db/migrate/20250520133417_create_restriction_operations.rb +18 -0
- data/db/migrate/20250520133420_validate_create_restriction_operations.rb +8 -0
- data/db/migrate/20250520140642_add_indexes_to_restrictions.rb +9 -0
- data/db/migrate/20250529130741_create_notification_alerts_table.rb +28 -0
- data/db/migrate/20250530223332_create_data_migrations_table.rb +19 -0
- data/db/migrate/20250605121622_seed_notification_alert_status.rb +7 -0
- data/db/migrate/20250605131439_seed_notification_alert_types.rb +7 -0
- data/db/migrate/20250606173128_update_notification_alert_length_constraint.rb +18 -0
- data/db/migrate/20250606174043_validate_notification_alert_length_constraints.rb +8 -0
- data/db/migrate/20250624183000_add_data_import_alert_type.rb +11 -0
- data/db/migrate/20250722183935_create_organization_options_table.rb +38 -0
- data/db/migrate/20250722192724_validate_organization_options_fks_and_constraints.rb +32 -0
- data/db/migrate/20250722192936_add_indexes_to_organization_options_table.rb +15 -0
- data/db/migrate/20250915132448_add_column_restrictions_hash.rb +7 -0
- data/db/migrate/20250917143211_add_column_permissions_hash.rb +7 -0
- data/db/migrate/20251001145950_add_trust_this_device.rb +7 -0
- data/db/migrate/20251021130835_add_backend_urls_to_applications_table.rb +13 -0
- data/db/migrate/20251021172715_validate_backend_urls_constraints_in_applications.rb +9 -0
- data/db/migrate/20251030200020_create_card_definitions.rb +23 -0
- data/db/migrate/20251030201012_create_card_definition_resources.rb +24 -0
- data/db/migrate/20251030201236_create_card_fields.rb +34 -0
- data/db/migrate/20251103194317_create_role_resource_cards.rb +37 -0
- data/db/migrate/20251103194426_create_role_card_fields.rb +34 -0
- data/db/migrate/20251107173218_validate_columns_from_cards.rb +17 -0
- data/db/migrate/20251111173212_add_column_application_array.rb +7 -0
- data/db/migrate/20251112203326_add_card_types.rb +10 -0
- data/db/migrate/20251115120000_add_virtual_cards_support.rb +28 -0
- data/db/migrate/20251202231256_add_org_scoped_fk_role_resource_cards_to_roles.rb +14 -0
- data/db/migrate/20260105134504_add_accessor_field_resource_type.rb +7 -0
- data/db/migrate/20260115123000_add_default_visibility_to_card_definitions.rb +9 -0
- data/db/migrate/20260120175037_is_new_admin.rb +9 -0
- data/db/migrate/20260122392008_add_stats_table.rb +17 -0
- data/db/migrate/20260414204718_add_index_to_stats_table.rb +10 -0
- data/db/migrate/20260509120000_create_service_trust_keys.rb +25 -0
- data/db/migrate/20260509120001_create_service_trust_audit_logs.rb +26 -0
- data/db/migrate/20260511120000_add_direction_to_service_trust_audit_logs.rb +17 -0
- data/db/migrate/20260511121000_remove_role_fk_from_role_resource_cards.rb +19 -0
- data/db/migrate/20260511121001_add_disabled_at_to_role_resource_cards.rb +10 -0
- data/db/migrate/20260605120100_seed_hover_card_options.rb +8 -0
- data/db/migrate/20260608120000_seed_badge_list_card_data_type.rb +7 -0
- data/db/migrate/20260727000000_add_two_factor_trust_id_to_user_sessions.rb +11 -0
- data/db/seeds.rb +14 -0
- data/docs/Elasticsearch.md +23 -0
- data/docs/Search_API.md +126 -0
- data/docs/cards_role_proxy.md +107 -0
- data/docs/factory_api.md +135 -0
- data/has-helpers-pr-289-pipeline.yaml +16 -0
- data/has-helpers-pr-298-pipeline.yaml +15 -0
- data/has_helpers.gemspec +68 -0
- data/lib/active_record/migration/active_migration_patch.rb +123 -0
- data/lib/generators/has_helpers/install/USAGE +8 -0
- data/lib/generators/has_helpers/install/install_generator.rb +22 -0
- data/lib/generators/has_helpers/install/templates/migrate/has_helpers_initial_setup.rb +26 -0
- data/lib/has_helpers/active_record/base.rb +50 -0
- data/lib/has_helpers/active_record/date_range.rb +228 -0
- data/lib/has_helpers/active_record/nested_resource.rb +58 -0
- data/lib/has_helpers/active_record/validation.rb +63 -0
- data/lib/has_helpers/active_record.rb +520 -0
- data/lib/has_helpers/app/command.rb +107 -0
- data/lib/has_helpers/app.rb +10 -0
- data/lib/has_helpers/assets_precompile_helper.rb +20 -0
- data/lib/has_helpers/attributes.rb +196 -0
- data/lib/has_helpers/aws.rb +67 -0
- data/lib/has_helpers/cards/cache.rb +49 -0
- data/lib/has_helpers/cards/config.rb +42 -0
- data/lib/has_helpers/cards/remote_role.rb +27 -0
- data/lib/has_helpers/cards/remote_roles.rb +75 -0
- data/lib/has_helpers/cards/roles.rb +55 -0
- data/lib/has_helpers/cards.rb +34 -0
- data/lib/has_helpers/concerns/hydrate_concern.rb +76 -0
- data/lib/has_helpers/concerns/importable_accessors.rb +25 -0
- data/lib/has_helpers/concerns/restrictions_parseable.rb +51 -0
- data/lib/has_helpers/config.rb +11 -0
- data/lib/has_helpers/constant.rb +578 -0
- data/lib/has_helpers/constraints.rb +10 -0
- data/lib/has_helpers/core_ext/array.rb +28 -0
- data/lib/has_helpers/core_ext/date/infinity.rb +25 -0
- data/lib/has_helpers/core_ext/date.rb +39 -0
- data/lib/has_helpers/core_ext/enumerable.rb +20 -0
- data/lib/has_helpers/core_ext/false_class.rb +14 -0
- data/lib/has_helpers/core_ext/float.rb +18 -0
- data/lib/has_helpers/core_ext/hash.rb +71 -0
- data/lib/has_helpers/core_ext/integer.rb +18 -0
- data/lib/has_helpers/core_ext/nil_class.rb +30 -0
- data/lib/has_helpers/core_ext/object.rb +60 -0
- data/lib/has_helpers/core_ext/proc.rb +16 -0
- data/lib/has_helpers/core_ext/string.rb +81 -0
- data/lib/has_helpers/core_ext/symbol.rb +17 -0
- data/lib/has_helpers/core_ext/true_class.rb +14 -0
- data/lib/has_helpers/cursor.rb +46 -0
- data/lib/has_helpers/data_migration/base.rb +293 -0
- data/lib/has_helpers/data_migration/large_worker.rb +20 -0
- data/lib/has_helpers/data_migration/master_worker.rb +33 -0
- data/lib/has_helpers/data_migration/migrator.rb +83 -0
- data/lib/has_helpers/data_migration/model.rb +18 -0
- data/lib/has_helpers/data_migration/small_worker.rb +20 -0
- data/lib/has_helpers/data_migration.rb +8 -0
- data/lib/has_helpers/engine.rb +47 -0
- data/lib/has_helpers/extensions.rb +17 -0
- data/lib/has_helpers/factory_api.rb +47 -0
- data/lib/has_helpers/factory_scenario/definition.rb +33 -0
- data/lib/has_helpers/factory_scenario/dsl.rb +80 -0
- data/lib/has_helpers/factory_scenario/factory_bot_override.rb +53 -0
- data/lib/has_helpers/factory_scenario/registry.rb +31 -0
- data/lib/has_helpers/factory_scenario/runner.rb +285 -0
- data/lib/has_helpers/factory_scenario.rb +27 -0
- data/lib/has_helpers/fixed_expiration_time_cache_session_store.rb +20 -0
- data/lib/has_helpers/flattener/association.rb +140 -0
- data/lib/has_helpers/flattener/attribute.rb +42 -0
- data/lib/has_helpers/flattener/base.rb +428 -0
- data/lib/has_helpers/flattener/column/types.rb +71 -0
- data/lib/has_helpers/flattener/column.rb +97 -0
- data/lib/has_helpers/flattener/pivot.rb +49 -0
- data/lib/has_helpers/flattener/reset.rb +33 -0
- data/lib/has_helpers/flattener/resource.rb +114 -0
- data/lib/has_helpers/flattener/resource_generator.rb +21 -0
- data/lib/has_helpers/flattener/utils.rb +14 -0
- data/lib/has_helpers/flattener.rb +53 -0
- data/lib/has_helpers/hash_accessors.rb +62 -0
- data/lib/has_helpers/helpers/application.rb +291 -0
- data/lib/has_helpers/index/config.rb +15 -0
- data/lib/has_helpers/lazy_config.rb +61 -0
- data/lib/has_helpers/resource_importer.rb +260 -0
- data/lib/has_helpers/resources.rb +127 -0
- data/lib/has_helpers/rspec/constants.rb +61 -0
- data/lib/has_helpers/rspec/factories.rb +11 -0
- data/lib/has_helpers/rspec.rb +22 -0
- data/lib/has_helpers/sentry/graphql_trace.rb +37 -0
- data/lib/has_helpers/serializer.rb +41 -0
- data/lib/has_helpers/service_trust/audit.rb +45 -0
- data/lib/has_helpers/service_trust/authorization.rb +34 -0
- data/lib/has_helpers/service_trust/bearer_token.rb +23 -0
- data/lib/has_helpers/service_trust/capability.rb +32 -0
- data/lib/has_helpers/service_trust/client/response.rb +13 -0
- data/lib/has_helpers/service_trust/client/retry.rb +35 -0
- data/lib/has_helpers/service_trust/client.rb +128 -0
- data/lib/has_helpers/service_trust/configuration.rb +76 -0
- data/lib/has_helpers/service_trust/engine.rb +10 -0
- data/lib/has_helpers/service_trust/errors.rb +32 -0
- data/lib/has_helpers/service_trust/graphql/authorizable.rb +72 -0
- data/lib/has_helpers/service_trust/graphql_client.rb +54 -0
- data/lib/has_helpers/service_trust/jwks_client.rb +133 -0
- data/lib/has_helpers/service_trust/jwt_codec.rb +45 -0
- data/lib/has_helpers/service_trust/key_manager.rb +160 -0
- data/lib/has_helpers/service_trust/rate_limiter.rb +27 -0
- data/lib/has_helpers/service_trust/replay_cache.rb +26 -0
- data/lib/has_helpers/service_trust/signer.rb +47 -0
- data/lib/has_helpers/service_trust/test.rb +60 -0
- data/lib/has_helpers/service_trust/verifier.rb +85 -0
- data/lib/has_helpers/service_trust/verify_middleware.rb +55 -0
- data/lib/has_helpers/service_trust.rb +51 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_addresses.rb +42 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_advisors.rb +272 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_emails.rb +37 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_organizations.rb +48 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_people.rb +34 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_phones.rb +41 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_states.rb +26 -0
- data/lib/has_helpers/test_helpers/factory_data/unit_webs.rb +31 -0
- data/lib/has_helpers/test_helpers/shoulda_helpers.rb +249 -0
- data/lib/has_helpers/ui_attributes.rb +39 -0
- data/lib/has_helpers/utils/action.rb +87 -0
- data/lib/has_helpers/utils/active_record_utils.rb +40 -0
- data/lib/has_helpers/utils/alert.rb +42 -0
- data/lib/has_helpers/utils/container.rb +46 -0
- data/lib/has_helpers/utils/dataset.rb +34 -0
- data/lib/has_helpers/utils/email_notifier.rb +15 -0
- data/lib/has_helpers/utils/icon.rb +66 -0
- data/lib/has_helpers/utils/input.rb +45 -0
- data/lib/has_helpers/utils/log_notifier.rb +79 -0
- data/lib/has_helpers/utils/render_object.rb +32 -0
- data/lib/has_helpers/utils/s3_utils.rb +37 -0
- data/lib/has_helpers/utils/service.rb +87 -0
- data/lib/has_helpers/utils/slack_conf.rb +31 -0
- data/lib/has_helpers/utils/slack_notifier.rb +42 -0
- data/lib/has_helpers/utils/text_node.rb +34 -0
- data/lib/has_helpers/utils/user_restrictions.rb +266 -0
- data/lib/has_helpers/utils.rb +19 -0
- data/lib/has_helpers/version.rb +6 -0
- data/lib/has_helpers/web_socket_publisher.rb +20 -0
- data/lib/has_helpers/webhook.rb +17 -0
- data/lib/has_helpers.rb +63 -0
- data/lib/hq/resource.rb +55 -0
- data/lib/hq/structure/inserts.rb +176 -0
- data/lib/hq/structure.rb +115 -0
- data/lib/tasks/has_helpers/service_trust.rake +39 -0
- data/script/rails +10 -0
- data/sorbet/config +5 -0
- data/sorbet/rbi/gems/actionpack.rbi +1361 -0
- data/sorbet/rbi/gems/activemodel.rbi +755 -0
- data/sorbet/rbi/gems/activerecord.rbi +4713 -0
- data/sorbet/rbi/gems/activesupport.rbi +1970 -0
- data/sorbet/rbi/gems/barby.rbi +129 -0
- data/sorbet/rbi/gems/better_errors.rbi +155 -0
- data/sorbet/rbi/gems/binding_of_caller.rbi +22 -0
- data/sorbet/rbi/gems/byebug.rbi +19 -0
- data/sorbet/rbi/gems/chronic.rbi +480 -0
- data/sorbet/rbi/gems/chunky_png.rbi +510 -0
- data/sorbet/rbi/gems/climate_control.rbi +45 -0
- data/sorbet/rbi/gems/coderay.rbi +91 -0
- data/sorbet/rbi/gems/concurrent-ruby.rbi +1587 -0
- data/sorbet/rbi/gems/debug_inspector.rbi +18 -0
- data/sorbet/rbi/gems/erubi.rbi +26 -0
- data/sorbet/rbi/gems/holidays.rbi +362 -0
- data/sorbet/rbi/gems/i18n.rbi +132 -0
- data/sorbet/rbi/gems/method_source.rbi +63 -0
- data/sorbet/rbi/gems/mime-types-data.rbi +16 -0
- data/sorbet/rbi/gems/mime-types.rbi +217 -0
- data/sorbet/rbi/gems/mimemagic.rbi +36 -0
- data/sorbet/rbi/gems/minitest.rbi +282 -0
- data/sorbet/rbi/gems/mustache.rbi +151 -0
- data/sorbet/rbi/gems/paperclip.rbi +644 -0
- data/sorbet/rbi/gems/parallel.rbi +81 -0
- data/sorbet/rbi/gems/parallel_tests.rbi +27 -0
- data/sorbet/rbi/gems/pry-rails.rbi +71 -0
- data/sorbet/rbi/gems/pry.rbi +1964 -0
- data/sorbet/rbi/gems/rack.rbi +228 -0
- data/sorbet/rbi/gems/railties.rbi +364 -0
- data/sorbet/rbi/gems/rspec-core.rbi +1704 -0
- data/sorbet/rbi/gems/rspec-expectations.rbi +389 -0
- data/sorbet/rbi/gems/rspec-support.rbi +206 -0
- data/sorbet/rbi/gems/rspec.rbi +14 -0
- data/sorbet/rbi/gems/spreadsheet_architect.rbi +10 -0
- data/sorbet/rbi/gems/sprockets.rbi +659 -0
- data/sorbet/rbi/gems/terrapin.rbi +115 -0
- data/sorbet/rbi/gems/testhq.rbi +14 -0
- data/sorbet/rbi/gems/thor.rbi +482 -0
- data/sorbet/rbi/gems/thread_safe.rbi +81 -0
- data/sorbet/rbi/gems/tzinfo.rbi +407 -0
- data/sorbet/rbi/gems/zeitwerk.rbi +131 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +35111 -0
- data/sorbet/rbi/hidden-definitions/hidden.rbi +59974 -0
- data/sorbet/rbi/sorbet-typed/lib/actionmailer/all/actionmailer.rbi +13 -0
- data/sorbet/rbi/sorbet-typed/lib/actionpack/all/actionpack.rbi +855 -0
- data/sorbet/rbi/sorbet-typed/lib/actionview/all/actionview.rbi +314 -0
- data/sorbet/rbi/sorbet-typed/lib/activemodel/all/activemodel.rbi +423 -0
- data/sorbet/rbi/sorbet-typed/lib/activerecord/>=5.2/activerecord.rbi +17 -0
- data/sorbet/rbi/sorbet-typed/lib/activerecord/all/activerecord.rbi +1415 -0
- data/sorbet/rbi/sorbet-typed/lib/activerecord/~>6.0.0/activerecord.rbi +475 -0
- data/sorbet/rbi/sorbet-typed/lib/activestorage/>=6.0.0/activestorage.rbi +19 -0
- data/sorbet/rbi/sorbet-typed/lib/activestorage/all/activestorage.rbi +173 -0
- data/sorbet/rbi/sorbet-typed/lib/activesupport/>=6.0.0.rc1/activesupport.rbi +23 -0
- data/sorbet/rbi/sorbet-typed/lib/activesupport/all/activesupport.rbi +625 -0
- data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +8684 -0
- data/sorbet/rbi/sorbet-typed/lib/minitest/all/minitest.rbi +99 -0
- data/sorbet/rbi/sorbet-typed/lib/railties/all/railties.rbi +25 -0
- data/sorbet/rbi/sorbet-typed/lib/rainbow/all/rainbow.rbi +254 -0
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +4222 -0
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +111 -0
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +543 -0
- data/sorbet/rbi/todo.rbi +244 -0
- data/spec/commands/cards/available_cards_command_spec.rb +90 -0
- data/spec/commands/cards/card_data_command_spec.rb +1048 -0
- data/spec/constructors/has_helpers/base_constructor_spec.rb +49 -0
- data/spec/controllers/has_helpers/controller_spec.rb +71 -0
- data/spec/controllers/has_helpers/xlsx_export_spec.rb +96 -0
- data/spec/factories/advisors.rb +20 -0
- data/spec/factories/anonymous_cowards.rb +5 -0
- data/spec/factories/applications.rb +5 -0
- data/spec/factories/appointments.rb +6 -0
- data/spec/factories/attachment.rb +15 -0
- data/spec/factories/audits.rb +5 -0
- data/spec/factories/basic_schedules.rb +12 -0
- data/spec/factories/cards/card_definition_resources.rb +7 -0
- data/spec/factories/cards/card_definitions.rb +11 -0
- data/spec/factories/cards/card_fields.rb +22 -0
- data/spec/factories/cards/role_card_fields.rb +17 -0
- data/spec/factories/cards/role_resource_cards.rb +12 -0
- data/spec/factories/constant_definition.rb +7 -0
- data/spec/factories/contracts.rb +10 -0
- data/spec/factories/data_migration_models.rb +9 -0
- data/spec/factories/demographics.rb +22 -0
- data/spec/factories/events.rb +21 -0
- data/spec/factories/firms.rb +21 -0
- data/spec/factories/imports.rb +9 -0
- data/spec/factories/meetups.rb +13 -0
- data/spec/factories/organizations.rb +13 -0
- data/spec/factories/policies.rb +7 -0
- data/spec/factories/policy_notes.rb +9 -0
- data/spec/factories/read_only_values.rb +7 -0
- data/spec/factories/resources.rb +7 -0
- data/spec/factories/roles.rb +11 -0
- data/spec/factories/schedules.rb +13 -0
- data/spec/factories/shared/flattener/attributes.rb +10 -0
- data/spec/factories/shared/flattener/columns.rb +6 -0
- data/spec/factories/shared/flattener/resources.rb +5 -0
- data/spec/factories/templates.rb +12 -0
- data/spec/factories/user_organizations.rb +23 -0
- data/spec/factories/user_session.rb +11 -0
- data/spec/factories/users.rb +55 -0
- data/spec/fixtures/sample_config.yml +3 -0
- data/spec/graphql/has_helpers/mutations/external_data_sync_spec.rb +101 -0
- data/spec/graphql/has_helpers/resolvers/cards/available_cards_spec.rb +36 -0
- data/spec/graphql/has_helpers/resolvers/cards/card_data_spec.rb +42 -0
- data/spec/graphql/has_helpers/resolvers/cards/hover_card_data_spec.rb +59 -0
- data/spec/has_helpers/cards/cache_spec.rb +58 -0
- data/spec/has_helpers/cards/config_spec.rb +68 -0
- data/spec/has_helpers/cards/orphan_card_sweeper_spec.rb +97 -0
- data/spec/has_helpers/cards/remote_role_spec.rb +17 -0
- data/spec/has_helpers/cards/remote_roles_spec.rb +97 -0
- data/spec/has_helpers/cards/roles_spec.rb +52 -0
- data/spec/has_helpers/cards/smoke_spec.rb +168 -0
- data/spec/has_helpers/cards/support.rb +52 -0
- data/spec/has_helpers/resolvers/internal/roles_spec.rb +73 -0
- data/spec/has_helpers/service_trust/audit_log_cleanup_worker_spec.rb +33 -0
- data/spec/has_helpers/service_trust/audit_spec.rb +70 -0
- data/spec/has_helpers/service_trust/authenticated_as_service_spec.rb +65 -0
- data/spec/has_helpers/service_trust/authorization_spec.rb +37 -0
- data/spec/has_helpers/service_trust/capability_spec.rb +35 -0
- data/spec/has_helpers/service_trust/client_spec.rb +129 -0
- data/spec/has_helpers/service_trust/configuration_spec.rb +35 -0
- data/spec/has_helpers/service_trust/engine_spec.rb +13 -0
- data/spec/has_helpers/service_trust/errors_spec.rb +23 -0
- data/spec/has_helpers/service_trust/graphql_authentication_spec.rb +59 -0
- data/spec/has_helpers/service_trust/graphql_authorizable_spec.rb +91 -0
- data/spec/has_helpers/service_trust/graphql_client_spec.rb +47 -0
- data/spec/has_helpers/service_trust/jwks_client_spec.rb +85 -0
- data/spec/has_helpers/service_trust/jwks_controller_spec.rb +47 -0
- data/spec/has_helpers/service_trust/jwt_codec_spec.rb +30 -0
- data/spec/has_helpers/service_trust/key_manager_spec.rb +80 -0
- data/spec/has_helpers/service_trust/key_spec.rb +52 -0
- data/spec/has_helpers/service_trust/rake_tasks_spec.rb +58 -0
- data/spec/has_helpers/service_trust/rate_limiter_spec.rb +31 -0
- data/spec/has_helpers/service_trust/replay_cache_spec.rb +29 -0
- data/spec/has_helpers/service_trust/signer_verifier_spec.rb +159 -0
- data/spec/has_helpers/service_trust/smoke_spec.rb +216 -0
- data/spec/has_helpers/service_trust/support.rb +121 -0
- data/spec/has_helpers/service_trust/test_module_spec.rb +39 -0
- data/spec/has_helpers/service_trust/verify_middleware_spec.rb +82 -0
- data/spec/helpers/application_spec.rb +155 -0
- data/spec/importers/cards/importer_spec.rb +861 -0
- data/spec/internal/app/assets/config/manifest.js +0 -0
- data/spec/internal/app/constants/cat_egory.rb +33 -0
- data/spec/internal/app/constants/color.rb +19 -0
- data/spec/internal/app/constants/exclude_group_nil_constant.rb +5 -0
- data/spec/internal/app/constants/foo.rb +6 -0
- data/spec/internal/app/constants/fruit.rb +3 -0
- data/spec/internal/app/constants/generic_group_example.rb +12 -0
- data/spec/internal/app/constants/my_constant.rb +4 -0
- data/spec/internal/app/constants/product.rb +3 -0
- data/spec/internal/app/constants/shirt_size.rb +18 -0
- data/spec/internal/app/constants/simple_option.rb +14 -0
- data/spec/internal/app/constants/status.rb +5 -0
- data/spec/internal/app/constructors/organization_constructor.rb +4 -0
- data/spec/internal/app/controllers/application_controller.rb +27 -0
- data/spec/internal/app/controllers/search_extensions.rb +3 -0
- data/spec/internal/app/indices/advisor_index.rb +35 -0
- data/spec/internal/app/indices/contract_index.rb +52 -0
- data/spec/internal/app/indices/firm_index.rb +16 -0
- data/spec/internal/app/indices/policy_index.rb +20 -0
- data/spec/internal/app/models/advisor.rb +24 -0
- data/spec/internal/app/models/agency.rb +3 -0
- data/spec/internal/app/models/anonymous_coward.rb +5 -0
- data/spec/internal/app/models/another_event.rb +2 -0
- data/spec/internal/app/models/appointment.rb +3 -0
- data/spec/internal/app/models/attachment.rb +10 -0
- data/spec/internal/app/models/basic_schedule.rb +6 -0
- data/spec/internal/app/models/beneficiary.rb +6 -0
- data/spec/internal/app/models/client.rb +5 -0
- data/spec/internal/app/models/contract.rb +9 -0
- data/spec/internal/app/models/demographic.rb +4 -0
- data/spec/internal/app/models/division.rb +3 -0
- data/spec/internal/app/models/event.rb +10 -0
- data/spec/internal/app/models/event_template.rb +1 -0
- data/spec/internal/app/models/firm.rb +18 -0
- data/spec/internal/app/models/has_audits/audit.rb +15 -0
- data/spec/internal/app/models/import.rb +7 -0
- data/spec/internal/app/models/meetup.rb +8 -0
- data/spec/internal/app/models/organization.rb +17 -0
- data/spec/internal/app/models/organization_event.rb +5 -0
- data/spec/internal/app/models/policy.rb +16 -0
- data/spec/internal/app/models/policy_holder.rb +7 -0
- data/spec/internal/app/models/policy_note.rb +8 -0
- data/spec/internal/app/models/project.rb +3 -0
- data/spec/internal/app/models/read_only_value.rb +8 -0
- data/spec/internal/app/models/schedule.rb +12 -0
- data/spec/internal/app/models/template.rb +9 -0
- data/spec/internal/app/models/user.rb +31 -0
- data/spec/internal/app/models/user_organization.rb +17 -0
- data/spec/internal/app/views/has_lists/lists/_table.html.erb +1 -0
- data/spec/internal/config/database-standard.yml +24 -0
- data/spec/internal/config/initializers/resources.rb +19 -0
- data/spec/internal/config/routes.rb +19 -0
- data/spec/internal/config/storage.yml +3 -0
- data/spec/internal/db/good_job_schema.rb +141 -0
- data/spec/internal/db/schema.rb +334 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/lib/flattener/base_spec.rb +93 -0
- data/spec/lib/flattener/column/types_spec.rb +65 -0
- data/spec/lib/has_helpers/active_record/base_spec.rb +53 -0
- data/spec/lib/has_helpers/active_record/date_range_spec.rb +498 -0
- data/spec/lib/has_helpers/active_record/lookup_model_spec.rb +408 -0
- data/spec/lib/has_helpers/active_record/nested_resource_spec.rb +43 -0
- data/spec/lib/has_helpers/app/command/reports/generator_specs.rb +887 -0
- data/spec/lib/has_helpers/app/command_spec.rb +117 -0
- data/spec/lib/has_helpers/app/support/mocks/graphql_reports_helpers.rb +96 -0
- data/spec/lib/has_helpers/app/support/mocks/reports_api_mock.rb +47 -0
- data/spec/lib/has_helpers/attributes_spec.rb +220 -0
- data/spec/lib/has_helpers/aws_spec.rb +126 -0
- data/spec/lib/has_helpers/concerns/hydrate_concern_spec.rb +473 -0
- data/spec/lib/has_helpers/constant/definition_spec.rb +128 -0
- data/spec/lib/has_helpers/constant_spec.rb +432 -0
- data/spec/lib/has_helpers/core_ext/array_spec.rb +22 -0
- data/spec/lib/has_helpers/core_ext/date/infinity_spec.rb +67 -0
- data/spec/lib/has_helpers/core_ext/date_spec.rb +27 -0
- data/spec/lib/has_helpers/core_ext/false_class_spec.rb +7 -0
- data/spec/lib/has_helpers/core_ext/float_spec.rb +9 -0
- data/spec/lib/has_helpers/core_ext/hash_spec.rb +48 -0
- data/spec/lib/has_helpers/core_ext/integer_spec.rb +9 -0
- data/spec/lib/has_helpers/core_ext/nil_class_spec.rb +17 -0
- data/spec/lib/has_helpers/core_ext/object_spec.rb +54 -0
- data/spec/lib/has_helpers/core_ext/proc_spec.rb +24 -0
- data/spec/lib/has_helpers/core_ext/string_spec.rb +154 -0
- data/spec/lib/has_helpers/core_ext/true_class_spec.rb +7 -0
- data/spec/lib/has_helpers/data_migration/base_spec.rb +470 -0
- data/spec/lib/has_helpers/data_migration/large_worker_spec.rb +34 -0
- data/spec/lib/has_helpers/data_migration/master_worker_spec.rb +51 -0
- data/spec/lib/has_helpers/data_migration/migrator_spec.rb +113 -0
- data/spec/lib/has_helpers/data_migration/model_spec.rb +52 -0
- data/spec/lib/has_helpers/data_migration/small_worker_spec.rb +34 -0
- data/spec/lib/has_helpers/good_job/notification_alert_cleanup_worker_spec.rb +89 -0
- data/spec/lib/has_helpers/hash_accessors_spec.rb +66 -0
- data/spec/lib/has_helpers/index_spec.rb +442 -0
- data/spec/lib/has_helpers/lazy_config_spec.rb +31 -0
- data/spec/lib/has_helpers/organization_merge_spec.rb +88 -0
- data/spec/lib/has_helpers/resource_importer_spec.rb +119 -0
- data/spec/lib/has_helpers/rspec_spec.rb +16 -0
- data/spec/lib/has_helpers/search/provider_spec.rb +26 -0
- data/spec/lib/has_helpers/search/search_utils_spec.rb +134 -0
- data/spec/lib/has_helpers/sentry/graphql_trace_spec.rb +140 -0
- data/spec/lib/has_helpers/ui_attributes_spec.rb +42 -0
- data/spec/lib/has_helpers/utils/action_spec.rb +49 -0
- data/spec/lib/has_helpers/utils/alert_spec.rb +33 -0
- data/spec/lib/has_helpers/utils/dataset_spec.rb +10 -0
- data/spec/lib/has_helpers/utils/icon_spec.rb +23 -0
- data/spec/lib/has_helpers/utils/input_spec.rb +40 -0
- data/spec/lib/has_helpers/utils/log_notifier_spec.rb +25 -0
- data/spec/lib/has_helpers/utils/render_object_spec.rb +17 -0
- data/spec/lib/has_helpers/utils/s3_utils_spec.rb +78 -0
- data/spec/lib/has_helpers/utils/service_spec.rb +79 -0
- data/spec/lib/has_helpers/utils/slack_notifier_spec.rb +70 -0
- data/spec/lib/has_helpers/utils/user_restrictions_spec.rb +343 -0
- data/spec/lib/hq/structure/inserts_spec.rb +152 -0
- data/spec/lib/hq/structure_spec.rb +12 -0
- data/spec/models/cards/base_spec.rb +149 -0
- data/spec/models/cards/card_definition_resource_spec.rb +103 -0
- data/spec/models/cards/card_definition_spec.rb +50 -0
- data/spec/models/cards/card_field_spec.rb +46 -0
- data/spec/models/cards/field_builder_spec.rb +318 -0
- data/spec/models/cards/registry_spec.rb +147 -0
- data/spec/models/cards/role_card_field_spec.rb +111 -0
- data/spec/models/cards/role_resource_card_spec.rb +112 -0
- data/spec/models/has_helpers/master_record_spec.rb +20 -0
- data/spec/models/has_helpers/user_organization_spec.rb +28 -0
- data/spec/models/has_helpers/user_session_spec.rb +16 -0
- data/spec/presenters/base_presenter_spec.rb +166 -0
- data/spec/rails_helper.rb +119 -0
- data/spec/requests/has_helpers/factory_controller_spec.rb +159 -0
- data/spec/requests/has_helpers/health_check_controller_spec.rb +37 -0
- data/spec/scenarios/empty_setup.rb +6 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/has_helpers/database_helpers.rb +12 -0
- data/spec/utils/sync_utils_spec.rb +233 -0
- data/spec/workers/goodjob/elasticsearch_process_batch_spec.rb +94 -0
- data/spec/workers/goodjob/elasticsearch_process_change_logs_master_worker_spec.rb +40 -0
- data/spec/workers/goodjob/elasticsearch_process_change_logs_worker_spec.rb +82 -0
- data/spec/workers/goodjob/elasticsearch_process_queue_spec.rb +89 -0
- data/spec/workers/goodjob/elasticsearch_reindex_spec.rb +49 -0
- metadata +1593 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
describe ::HasHelpers::Constant do
|
|
4
|
+
describe ".define_constants" do
|
|
5
|
+
let(:constants) { ["Joe", "Bob", "Mary", "Boys".to_constant {}] }
|
|
6
|
+
subject { __constants__ = constants; Class.new { include ::HasHelpers::Constant; define_constants *__constants__ } }
|
|
7
|
+
|
|
8
|
+
it { expect(subject.send(:__constants__).values.all? { |d| d.class == ::HasHelpers::Constant::Definition }).to be_truthy }
|
|
9
|
+
it { expect(subject.constant_names).to contain_exactly(*%w[Joe Bob Mary]) } # Excludes lazy (group) constants, in this case "Boys"
|
|
10
|
+
it { expect(CatEgory.send(:__constants__)[:SIAMESE].attrs(force_eval: true).except("cat_type")).to eq({:name => "Siamese", :likelihood_that_it_eats_me => CatEgory::MODERATE_LIKELIHOOD}) }
|
|
11
|
+
|
|
12
|
+
context "with prefix" do
|
|
13
|
+
subject {
|
|
14
|
+
__constants__ = constants
|
|
15
|
+
Class.new do
|
|
16
|
+
include ::HasHelpers::Constant
|
|
17
|
+
define_constants *__constants__, key_prefix: "PERSON"
|
|
18
|
+
end
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
it { expect(subject.constant_names).to contain_exactly(*%w[Joe Bob Mary]) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "include group_id null constants" do
|
|
25
|
+
subject {
|
|
26
|
+
__constants__ = constants
|
|
27
|
+
Class.new do
|
|
28
|
+
include ::HasHelpers::Constant
|
|
29
|
+
define_constants *__constants__
|
|
30
|
+
end
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
it { expect(subject.constant_names).to contain_exactly(*%w[Joe Bob Mary]) }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "exclude group_id null constants" do
|
|
37
|
+
it { expect(ExcludeGroupNilConstant.all).to contain_exactly(*%w[]) }
|
|
38
|
+
it { expect(ExcludeGroupNilConstant.constant_names).to contain_exactly(*%w[One Two Three]) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context do
|
|
42
|
+
let!(:both) { Color.where(:name => "Cyan").first_or_create! }
|
|
43
|
+
|
|
44
|
+
before do
|
|
45
|
+
Object.const_set(:CYAN, "shouldn't access me")
|
|
46
|
+
Color.define_constant "Cyan"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
after do
|
|
50
|
+
Color.send(:__constants__).delete(:CYAN) # Clean up, so this does not affect other specs
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "avoids constant lookup in ancestors" do
|
|
54
|
+
# Initial lookup
|
|
55
|
+
subject = Color::CYAN
|
|
56
|
+
expect(subject.is_a?(Color)).to be true
|
|
57
|
+
expect(subject.class).to eq(Color)
|
|
58
|
+
expect(subject).to eq(both)
|
|
59
|
+
|
|
60
|
+
# Subsequent lookups
|
|
61
|
+
expect(subject).to eq(Color::CYAN)
|
|
62
|
+
expect(subject.object_id).to eq(Color::CYAN.object_id)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context do
|
|
68
|
+
before do
|
|
69
|
+
::Color.seed!
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Set up constant database records
|
|
73
|
+
let!(:blue) { ::Color.where(name: 'Blue').first_or_create! }
|
|
74
|
+
let!(:goldenrod) { ::Color.where(name: 'Goldenrod').first_or_create! }
|
|
75
|
+
let!(:indigo) { ::Color.where(name: 'Indigo').first_or_create! }
|
|
76
|
+
let!(:lemon) { ::Color.where(name: 'Lemon').first_or_create! }
|
|
77
|
+
let!(:purple) { ::Color.where(name: 'Red Blue').first_or_create! }
|
|
78
|
+
let!(:red) { ::Color.where(name: 'Red').first_or_create! }
|
|
79
|
+
let!(:teal) { ::Color.where(name: 'Teal').first_or_create! }
|
|
80
|
+
let!(:yellow) { ::Color.where(name: 'Yellow').first_or_create!}
|
|
81
|
+
let!(:green) { ::Color.where(name: 'Green').first_or_create!}
|
|
82
|
+
let!(:grey) { ::Color.where(name: 'Grey').first_or_create!}
|
|
83
|
+
|
|
84
|
+
it "looks up constant records" do
|
|
85
|
+
expect(::Color::BLUE).to eq(blue)
|
|
86
|
+
expect(::Color::GOLDENROD).to eq(goldenrod)
|
|
87
|
+
expect(::Color::INDIGO).to eq(indigo)
|
|
88
|
+
expect(::Color::LEMON).to eq(lemon)
|
|
89
|
+
expect(::Color::RED).to eq(red)
|
|
90
|
+
expect(::Color::PURPLE).to eq(purple)
|
|
91
|
+
expect(::Color::TEAL).to eq(teal)
|
|
92
|
+
expect(::Color::YELLOW).to eq(yellow)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "set the constant" do
|
|
96
|
+
Color.send(:remove_const, :RED) if Color.const_defined?(:RED) # Ensure that ::RED is not set
|
|
97
|
+
expect(Color.const_defined?(:RED)).to be_falsey
|
|
98
|
+
Color::RED # Should load the constant
|
|
99
|
+
expect(Color.const_defined?(:RED)).to be_truthy
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
context "errors" do # Wrap errors in their own context to prevent them from messing up other specs.
|
|
103
|
+
it "uses the key attribute when present" do
|
|
104
|
+
expect(Color::PURPLE).to eq(purple)
|
|
105
|
+
expect { Color::RED_BLUE }.to raise_error(NameError, /uninitialized constant/)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "raises an error when the constant record is not defined" do
|
|
109
|
+
expect{ Color::FUSCHIA }.to raise_error(NameError, /uninitialized constant/)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
context "all" do
|
|
114
|
+
it "returns all non-group constants" do
|
|
115
|
+
expect(Color::ALL).to contain_exactly(blue, goldenrod, indigo, lemon, purple, red, teal, yellow, green, grey)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "set the ::ALL constant" do
|
|
119
|
+
Color.send(:remove_const, :ALL) if Color.const_defined?(:ALL) # Ensure that ::ALL is not set
|
|
120
|
+
expect(Color.const_defined?(:ALL)).to be_falsey
|
|
121
|
+
Color::ALL # Should load the constant
|
|
122
|
+
expect(Color.const_defined?(:ALL)).to be_truthy
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should raise if it is an abstract constant class" do
|
|
126
|
+
expect{Option::ALL}.to raise_error(NameError)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "uses the same objects individually as it" do
|
|
130
|
+
Color.send(:remove_const, :ALL) if Color.const_defined?(:ALL) # Ensure that ::ALL is not set
|
|
131
|
+
Color.send(:remove_const, :RED) if Color.const_defined?(:RED) # Ensure that ::RED is not set
|
|
132
|
+
red_from_all = Color::ALL.detect { |g| g.name == "Red" }
|
|
133
|
+
red_individual = Color::RED
|
|
134
|
+
expect(red_from_all.object_id).to eq(red_individual.object_id)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
context "scoped constants" do
|
|
140
|
+
before(:each) do
|
|
141
|
+
CatEgory.seed!
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Set up constant database records
|
|
145
|
+
let(:persian) { CatEgory.find_by(:name => "Persian", :likelihood_that_it_eats_me => CatEgory::LOW_LIKELIHOOD) }
|
|
146
|
+
let(:siamese) { CatEgory.find_by(:name => "Siamese", :likelihood_that_it_eats_me => CatEgory::MODERATE_LIKELIHOOD) }
|
|
147
|
+
let(:cougar) { CatEgory.find_by(:name => "Cougar", :likelihood_that_it_eats_me => CatEgory::MODERATE_LIKELIHOOD) }
|
|
148
|
+
let(:puma) { CatEgory.find_by(:name => "Puma", :likelihood_that_it_eats_me => CatEgory::HIGH_LIKELIHOOD) }
|
|
149
|
+
let(:tiger) { CatEgory.find_by(:name => "Tiger", :likelihood_that_it_eats_me => CatEgory::HIGH_LIKELIHOOD) }
|
|
150
|
+
let(:bengal) { CatEgory.find_by(:name => "Bengal", :likelihood_that_it_eats_me => CatEgory::HIGH_LIKELIHOOD) }
|
|
151
|
+
let(:big_cat) { CatEgory.find_by(name: "Big Cat") }
|
|
152
|
+
let(:small_cat) { CatEgory.find_by(name: "Small Cat") }
|
|
153
|
+
|
|
154
|
+
it "looks up constant records" do
|
|
155
|
+
expect(CatEgory::PERSIAN).to eq(persian)
|
|
156
|
+
expect(CatEgory::PERSIAN.likelihood_that_it_eats_me).to eq(CatEgory::LOW_LIKELIHOOD)
|
|
157
|
+
expect(CatEgory::SIAMESE).to eq(siamese)
|
|
158
|
+
expect(CatEgory::SIAMESE.likelihood_that_it_eats_me).to eq(CatEgory::MODERATE_LIKELIHOOD)
|
|
159
|
+
expect(CatEgory::COUGAR).to eq(cougar)
|
|
160
|
+
expect(CatEgory::COUGAR.likelihood_that_it_eats_me).to eq(CatEgory::MODERATE_LIKELIHOOD)
|
|
161
|
+
expect(CatEgory::POOOOOMA).to eq(puma)
|
|
162
|
+
expect(CatEgory::POOOOOMA.likelihood_that_it_eats_me).to eq(CatEgory::HIGH_LIKELIHOOD)
|
|
163
|
+
expect(CatEgory::TIGER).to eq(tiger)
|
|
164
|
+
expect(CatEgory::TIGER.likelihood_that_it_eats_me).to eq(CatEgory::HIGH_LIKELIHOOD)
|
|
165
|
+
expect(CatEgory::BIG_CAT).to eq(big_cat)
|
|
166
|
+
expect(CatEgory::BIG_CAT.likelihood_that_it_eats_me).to eq(CatEgory::HIGH_LIKELIHOOD)
|
|
167
|
+
expect(CatEgory::SMALL_CAT).to eq(small_cat)
|
|
168
|
+
expect(CatEgory::SMALL_CAT.likelihood_that_it_eats_me).to eq(CatEgory::MODERATE_LIKELIHOOD)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it { expect { CatEgory::PUMA }.to raise_error(NameError, /uninitialized constant/) }
|
|
172
|
+
|
|
173
|
+
context "all" do
|
|
174
|
+
it "returns all non-group constants" do
|
|
175
|
+
expect(CatEgory::ALL).to contain_exactly(persian, siamese, cougar, puma, tiger, big_cat, small_cat, bengal)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it "raises an error when the scope does not match the name" do
|
|
180
|
+
# Update Tiger record so that it does _not_ match the constant definition (mismatched values for likelihood)
|
|
181
|
+
bengal.reload.update_attribute :likelihood_that_it_eats_me, CatEgory::LOW_LIKELIHOOD
|
|
182
|
+
CatEgory.send :remove_const, :BENGAL if CatEgory.const_defined?(:BENGAL) # Clear out any previous definition from other specs.
|
|
183
|
+
expect { CatEgory::BENGAL }.to raise_error(NameError, /the constant CatEgory::BENGAL does not exist/)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it "raises an error when the constant record is not defined" do
|
|
187
|
+
expect { CatEgory::LION }.to raise_error(NameError, /uninitialized constant/)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
context "simple constants" do
|
|
192
|
+
before(:each) do
|
|
193
|
+
SimpleOption.seed!
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it do
|
|
197
|
+
aggregate_failures do
|
|
198
|
+
expect(SimpleOption::SIMPLE_TWO.is_parent?).to be true
|
|
199
|
+
expect(SimpleOption::SIMPLE_THREE.is_parent?).to be false
|
|
200
|
+
expect(SimpleOption::SIMPLE_FOUR.is_parent?).to be true
|
|
201
|
+
expect(SimpleOption::SIMPLE_FIVE.is_parent?).to be false
|
|
202
|
+
|
|
203
|
+
expect(SimpleOption::SIMPLE_TWO.group_children).to contain_exactly(::SimpleOption::SIMPLE_TWO, ::SimpleOption::SIMPLE_THREE)
|
|
204
|
+
expect(SimpleOption::SIMPLE_THREE.group_parent).to eq SimpleOption::SIMPLE_TWO
|
|
205
|
+
expect(SimpleOption::SIMPLE_FOUR.group_children).to contain_exactly(::SimpleOption::SIMPLE_FIVE)
|
|
206
|
+
expect(SimpleOption::SIMPLE_FOUR.group_parent).to eq SimpleOption::SIMPLE_FOUR
|
|
207
|
+
expect(SimpleOption::SIMPLE_FIVE.group_parent).to eq SimpleOption::SIMPLE_FOUR
|
|
208
|
+
|
|
209
|
+
expect(SimpleOption.is_parent?(SimpleOption::SIMPLE_TWO)).to be true
|
|
210
|
+
expect(SimpleOption.is_parent?(SimpleOption::SIMPLE_THREE)).to be false
|
|
211
|
+
expect(SimpleOption.is_parent?(SimpleOption::SIMPLE_FOUR)).to be true
|
|
212
|
+
expect(SimpleOption.is_parent?(SimpleOption::SIMPLE_FIVE)).to be false
|
|
213
|
+
|
|
214
|
+
simple_two = SimpleOption.find_by(name: "Simple Two")
|
|
215
|
+
simple_three = SimpleOption.find_by(name: "Simple Three")
|
|
216
|
+
simple_four = SimpleOption.find_by(name: "Simple Four")
|
|
217
|
+
simple_five = SimpleOption.find_by(name: "Simple Five")
|
|
218
|
+
|
|
219
|
+
expect(simple_two.is_parent?).to be true
|
|
220
|
+
expect(simple_three.is_parent?).to be false
|
|
221
|
+
expect(simple_four.is_parent?).to be true
|
|
222
|
+
expect(simple_five.is_parent?).to be false
|
|
223
|
+
|
|
224
|
+
expect(simple_two.group_children).to contain_exactly(simple_two, simple_three)
|
|
225
|
+
expect(simple_three.group_parent).to eq simple_two
|
|
226
|
+
expect(simple_four.group_children).to contain_exactly(simple_five)
|
|
227
|
+
expect(simple_five.group_parent).to eq simple_four
|
|
228
|
+
|
|
229
|
+
expect(simple_two.group_id).to eq simple_two.id
|
|
230
|
+
expect(simple_four.group_id).to_not eq simple_four.id
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
before(:each) do
|
|
236
|
+
Product.all.delete_all
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
describe ".seed!" do
|
|
240
|
+
before :all do
|
|
241
|
+
Product.define_constant "Hair Gel".to_constant(:code => "EW12")
|
|
242
|
+
Product.define_constant "Hair Spray".to_constant(:code => "HS01")
|
|
243
|
+
Product.define_constant "Pomade".to_constant(:code => "DD99")
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it "seeds each constant" do
|
|
247
|
+
expect(Product.where(:name => "Hair Gel", :code => "EW12").exists?).to be_falsey
|
|
248
|
+
expect(Product.where(:name => "Hair Spray", :code => "HS01").exists?).to be_falsey
|
|
249
|
+
expect(Product.where(:name => "Pomade", :code => "DD99").exists?).to be_falsey
|
|
250
|
+
|
|
251
|
+
Product.seed!
|
|
252
|
+
|
|
253
|
+
expect(Product.where(:name => "Hair Gel", :code => "EW12").first).to be_a(Product)
|
|
254
|
+
expect(Product.where(:name => "Hair Spray", :code => "HS01").first).to be_a(Product)
|
|
255
|
+
expect(Product.where(:name => "Pomade", :code => "DD99").first).to be_a(Product)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it "Returns nil" do
|
|
259
|
+
expect(Product.seed!).to be_nil
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
describe ".define_constant_group" do
|
|
264
|
+
before do
|
|
265
|
+
::CatEgory.seed!
|
|
266
|
+
::Color.seed!
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
let(:big_cat) { ::CatEgory.find_by(name: "Big Cat") }
|
|
270
|
+
let(:cougar) { ::CatEgory.find_by(name: 'Cougar') }
|
|
271
|
+
let(:persian) { ::CatEgory.find_by(name: 'Persian') }
|
|
272
|
+
let(:puma) { ::CatEgory.find_by(name: 'Puma') }
|
|
273
|
+
let(:siamese) { ::CatEgory.find_by(name: 'Siamese') }
|
|
274
|
+
let(:small_cat) { ::CatEgory.find_by(name: "Small Cat") }
|
|
275
|
+
let(:tiger) { ::CatEgory.find_by(name: 'Tiger') }
|
|
276
|
+
|
|
277
|
+
it { expect(::Foo.supports_grouping?).to be false }
|
|
278
|
+
it { expect(::CatEgory.supports_grouping?).to be true }
|
|
279
|
+
it { expect(::CatEgory::SNUGGLEABLE).to contain_exactly(::CatEgory::PERSIAN, ::CatEgory::SIAMESE) }
|
|
280
|
+
|
|
281
|
+
context 'without the parent being persisted' do
|
|
282
|
+
it "returns grouped records when evaluating the parent constant" do
|
|
283
|
+
expect(CatEgory::UNLIKELY_TO_EAT_ME).to contain_exactly(persian)
|
|
284
|
+
expect(CatEgory::MODERATELY_LIKELY_TO_EAT_ME).to contain_exactly(siamese, cougar)
|
|
285
|
+
expect(CatEgory::LIKELY_TO_EAT_ME).to contain_exactly(puma, tiger)
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
context 'with the parent being persisted' do
|
|
290
|
+
it 'should not include the parent twice in the group' do
|
|
291
|
+
expect(::Color::BLUE_COLORS).to contain_exactly(::Color::BLUE, ::Color::INDIGO, ::Color::TEAL)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it 'should return the parent record rather than the group when evaluating the parent constant' do
|
|
295
|
+
expect(::CatEgory::BIG_CAT).to eq(big_cat)
|
|
296
|
+
expect(::CatEgory::SMALL_CAT).to eq(small_cat)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
it 'should return groups when evaluating the group name constant' do
|
|
300
|
+
expect(::CatEgory::BIG_CAT_GROUP).to contain_exactly(cougar, puma, tiger, big_cat)
|
|
301
|
+
[big_cat, cougar, puma, tiger].each do |cat|
|
|
302
|
+
expect(cat.cat_type).to eq(big_cat.id), "cat_type != big_cat.id! (#{cat.cat_type || "nil"} != #{big_cat.id}) Failing constant: #{cat.name}"
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
it 'should handle assigning a custom group name' do
|
|
307
|
+
expect { ::CatEgory::SMALL_CAT_GROUP }.to raise_error(NameError, /uninitialized constant/)
|
|
308
|
+
expect(::CatEgory::SMOL_KITTERS).to contain_exactly(persian, siamese, small_cat)
|
|
309
|
+
[persian, siamese, small_cat].each do |cat|
|
|
310
|
+
expect(cat.cat_type).to eq(small_cat.id), "cat_type != small_cat.id! (#{cat.cat_type || "nil"} != #{small_cat.id}) Failing constant: #{cat.name}"
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
it 'should set a has_many/belongs to association on the model' do
|
|
315
|
+
expect(::CatEgory.reflect_on_association(:group_parent)).to be_truthy
|
|
316
|
+
expect(::CatEgory.reflect_on_association(:group_children)).to be_truthy
|
|
317
|
+
expect(::CatEgory::SMALL_CAT.group_children).to contain_exactly(persian, siamese, small_cat)
|
|
318
|
+
[persian, siamese, small_cat].each do |cat|
|
|
319
|
+
expect(cat.group_parent).to eq(small_cat)
|
|
320
|
+
end
|
|
321
|
+
expect(::CatEgory::BIG_CAT.group_children).to contain_exactly(cougar, puma, tiger, big_cat)
|
|
322
|
+
[cougar, puma, tiger, big_cat].each do |cat|
|
|
323
|
+
expect(cat.group_parent).to eq(big_cat)
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
describe ".lookup" do
|
|
331
|
+
context do
|
|
332
|
+
before { CatEgory.seed! }
|
|
333
|
+
it "returns the record matching the specified query" do
|
|
334
|
+
expect(CatEgory.lookup("Siamese")).to eq(CatEgory::SIAMESE)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
it "returns nil if no matching record is found" do
|
|
338
|
+
expect(CatEgory.lookup("Liger")).to be_nil
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
it "returns nil if given name is nil" do
|
|
342
|
+
expect(CatEgory.lookup(nil)).to be_nil
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
describe "options" do
|
|
346
|
+
describe "case_sensitive" do
|
|
347
|
+
it "is disabled by default" do
|
|
348
|
+
expect(CatEgory.lookup("siamese")).to eq(CatEgory::SIAMESE)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
it "matches with case-sensitivity" do
|
|
352
|
+
aggregate_failures do
|
|
353
|
+
expect(CatEgory.lookup("siamese", case_sensitive: true)).to be_nil
|
|
354
|
+
expect(CatEgory.lookup("Siamese", case_sensitive: true)).to eq(CatEgory::SIAMESE)
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
it "matches without case-sensitivity" do
|
|
359
|
+
aggregate_failures do
|
|
360
|
+
expect(CatEgory.lookup("siamese", case_sensitive: false)).to eq(CatEgory::SIAMESE)
|
|
361
|
+
expect(CatEgory.lookup("Siamese", case_sensitive: false)).to eq(CatEgory::SIAMESE)
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
describe "attributes" do
|
|
368
|
+
before :all do
|
|
369
|
+
Color.seed!
|
|
370
|
+
ShirtSize.seed!
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
it "matches with attributes before constant is loaded in memory" do
|
|
374
|
+
# There is a need to test ShirtSize _before_ constants are loaded into memory,
|
|
375
|
+
# so we need to "reset" the constant, done by reloading the source file.
|
|
376
|
+
# There was a bug which caused attributes to not be match correctly until
|
|
377
|
+
# the matching constant record was loaded. More specifically, lazy attributes
|
|
378
|
+
# were not being evaluated when compared in the lookup method.
|
|
379
|
+
load Rails.root.join("app/constants/shirt_size.rb")
|
|
380
|
+
|
|
381
|
+
shirt_size = ShirtSize.lookup("M", color_id: Color::RED.id)
|
|
382
|
+
expect(shirt_size.is_a?(ShirtSize)).to be true # Check for a failed lookup, which will return nil
|
|
383
|
+
|
|
384
|
+
aggregate_failures do
|
|
385
|
+
expect(shirt_size.name).to eq("M")
|
|
386
|
+
expect(shirt_size.color_id).to eq(Color::RED.id)
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
describe "id" do
|
|
392
|
+
it "returns the record with the matching id" do
|
|
393
|
+
expect(CatEgory.lookup(id: CatEgory::SMALL_CAT.id)).to eq(CatEgory::SMALL_CAT)
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
it "supports matching by string" do
|
|
397
|
+
expect(CatEgory.lookup(id: CatEgory::SMALL_CAT.id.to_s)).to eq(CatEgory::SMALL_CAT)
|
|
398
|
+
end
|
|
399
|
+
end
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
context do
|
|
403
|
+
before do
|
|
404
|
+
Foo.seed!
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
it "raises an exception if the query matches more than one record" do
|
|
408
|
+
expect { Foo.lookup("Derp") }.to raise_error.with_message(/Lookup matched more than one record/)
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
context "returns the record matching the specified query, key and/or attributes" do
|
|
412
|
+
it { expect(Foo.lookup("Derp", key: "DERP")).to eq(Foo::DERP) }
|
|
413
|
+
it { expect(Foo.lookup("Derp", key: "NERP")).to eq(Foo::NERP) }
|
|
414
|
+
it { expect(Foo.lookup(key: :NERP)).to eq(Foo::NERP) }
|
|
415
|
+
it { expect(Foo.lookup(key: :BERP)).to be_nil }
|
|
416
|
+
it { expect(Foo.lookup(scope: "perry")).to eq(Foo::NERP) }
|
|
417
|
+
it { expect(Foo.lookup("Derp", scope: "perry")).to eq(Foo::NERP) }
|
|
418
|
+
it { expect(Foo.lookup("Nerp", scope: "perry")).to be_nil }
|
|
419
|
+
end
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
describe "#definition" do
|
|
424
|
+
before { Color.seed! }
|
|
425
|
+
it { expect(Color::PURPLE.definition).to be_a(described_class::Definition) }
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
describe "#meta" do
|
|
429
|
+
before { Color.seed! }
|
|
430
|
+
it { expect(Color::PURPLE.meta.secondary_color).to be_truthy }
|
|
431
|
+
end
|
|
432
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
describe ::HasHelpers::CoreExt::Array do
|
|
4
|
+
describe "#to_constant" do
|
|
5
|
+
let(:name1) { "Test1" }
|
|
6
|
+
let(:name2) { "Test2" }
|
|
7
|
+
let(:names) { [name1, name2] }
|
|
8
|
+
subject { names.to_constant }
|
|
9
|
+
|
|
10
|
+
it { expect(subject.all? { |element| element.class == ::HasHelpers::Constant::Definition }).to be_truthy }
|
|
11
|
+
it { expect(subject.map(&:name)).to eq(names) }
|
|
12
|
+
|
|
13
|
+
context "with options" do
|
|
14
|
+
let(:type) { "Tupe" }
|
|
15
|
+
subject { [*names, :type => type].to_constant }
|
|
16
|
+
|
|
17
|
+
it { expect(subject.all? { |element| element.class == ::HasHelpers::Constant::Definition }).to be_truthy }
|
|
18
|
+
it { expect(subject.map(&:name)).to eq(names) }
|
|
19
|
+
it { expect(subject.all? { |element| element.attrs[:type] == type }).to be_truthy }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
describe ::HasHelpers::CoreExt::Date::Infinity do
|
|
4
|
+
context "comparisons with Date instance" do
|
|
5
|
+
context "on left side" do
|
|
6
|
+
context "with positive Infinity" do
|
|
7
|
+
it { expect(Date.current < Date::Infinity.new).to be_truthy }
|
|
8
|
+
it { expect(Date.current > Date::Infinity.new).to be_falsey }
|
|
9
|
+
it { expect(Date.current == Date::Infinity.new).to be_falsey }
|
|
10
|
+
it { expect(Date.current <=> Date::Infinity.new).to eq(-1) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "with negative Infinity" do
|
|
14
|
+
it { expect(Date.current < -Date::Infinity.new).to be_falsey }
|
|
15
|
+
it { expect(Date.current > -Date::Infinity.new).to be_truthy }
|
|
16
|
+
it { expect(Date.current == -Date::Infinity.new).to be_falsey }
|
|
17
|
+
it { expect(Date.current <=> -Date::Infinity.new).to eq(1) }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "on right side" do
|
|
22
|
+
context "with positive Infinity" do
|
|
23
|
+
it { expect(Date::Infinity.new < Date.current).to be_falsey }
|
|
24
|
+
it { expect(Date::Infinity.new > Date.current).to be_truthy }
|
|
25
|
+
it { expect(Date::Infinity.new == Date.current).to be_falsey }
|
|
26
|
+
it { expect(Date::Infinity.new <=> Date.current).to eq(1) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "with negative Infinity" do
|
|
30
|
+
it { expect(-Date::Infinity.new < Date.current).to be_truthy }
|
|
31
|
+
it { expect(-Date::Infinity.new > Date.current).to be_falsey }
|
|
32
|
+
it { expect(-Date::Infinity.new == Date.current).to be_falsey }
|
|
33
|
+
it { expect(-Date::Infinity.new <=> Date.current).to eq(-1) }
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "comparisons with Date::Infinity instance" do
|
|
39
|
+
context "<" do
|
|
40
|
+
it { expect(Date::Infinity.new < Date::Infinity.new).to be_falsey }
|
|
41
|
+
it { expect(-Date::Infinity.new < Date::Infinity.new).to be_truthy }
|
|
42
|
+
it { expect(-Date::Infinity.new < -Date::Infinity.new).to be_falsey }
|
|
43
|
+
it { expect(Date::Infinity.new < -Date::Infinity.new).to be_falsey }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context ">" do
|
|
47
|
+
it { expect(Date::Infinity.new > Date::Infinity.new).to be_falsey }
|
|
48
|
+
it { expect(-Date::Infinity.new > Date::Infinity.new).to be_falsey }
|
|
49
|
+
it { expect(-Date::Infinity.new > -Date::Infinity.new).to be_falsey }
|
|
50
|
+
it { expect(Date::Infinity.new > -Date::Infinity.new).to be_truthy }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "==" do
|
|
54
|
+
it { expect(Date::Infinity.new == Date::Infinity.new).to be_truthy }
|
|
55
|
+
it { expect(-Date::Infinity.new == Date::Infinity.new).to be_falsey }
|
|
56
|
+
it { expect(-Date::Infinity.new == -Date::Infinity.new).to be_truthy }
|
|
57
|
+
it { expect(Date::Infinity.new == -Date::Infinity.new).to be_falsey }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context "<=>" do
|
|
61
|
+
it { expect(Date::Infinity.new <=> Date::Infinity.new).to eq(0) }
|
|
62
|
+
it { expect(-Date::Infinity.new <=> Date::Infinity.new).to eq(-1) }
|
|
63
|
+
it { expect(-Date::Infinity.new <=> -Date::Infinity.new).to eq(0) }
|
|
64
|
+
it { expect(Date::Infinity.new <=> -Date::Infinity.new).to eq(1) }
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe ::HasHelpers::CoreExt::Date do
|
|
4
|
+
describe ".next_business_day" do
|
|
5
|
+
it "should not include weekends" do
|
|
6
|
+
# Friday, January 1st, 2016
|
|
7
|
+
starting_date = Date.civil(2016, 1, 1)
|
|
8
|
+
|
|
9
|
+
# Monday, January 4, 2016
|
|
10
|
+
expect(starting_date.next_business_day).to eq(Date.civil(2016, 1, 4))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should not include christmas" do
|
|
14
|
+
# Monday, December 25th, 2017
|
|
15
|
+
starting_date = Date.civil(2017, 12, 25)
|
|
16
|
+
|
|
17
|
+
# Tuesday, December 26th, 2016
|
|
18
|
+
expect(starting_date.next_business_day).to eq(Date.civil(2017, 12, 26))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should allow argument for multiple days" do
|
|
22
|
+
starting_date = Date.civil(2016, 1, 1)
|
|
23
|
+
|
|
24
|
+
expect(starting_date.next_business_day(3)).to eq(Date.civil(2016, 1, 6))
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe ::HasHelpers::CoreExt::Integer do
|
|
4
|
+
describe "#to_renderable" do
|
|
5
|
+
subject { 3.141592 }
|
|
6
|
+
it { expect(subject.to_renderable).to be_a(::HasHelpers::TextNode) }
|
|
7
|
+
it { expect(subject.to_renderable.str).to eq(subject.to_s) }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe ::HasHelpers::CoreExt::Hash do
|
|
4
|
+
describe "#with_nested_access" do
|
|
5
|
+
it { expect({}.with_nested_access[:a][:b][:c]).to eq({}) }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "#camelize_keys!" do
|
|
9
|
+
it { expect({ first_name: "Brendan"}.camelize_keys!).to eq({firstName: "Brendan"})}
|
|
10
|
+
it "doesn't change strings to symbols" do
|
|
11
|
+
expect({ "last_name" => "Carney"}.camelize_keys!).to eq({"lastName" => "Carney"})
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#to_icon" do
|
|
16
|
+
it "returns an icon instance using the current hash as parameters" do
|
|
17
|
+
hash = { name: :clock, orientation: :upside_down }
|
|
18
|
+
icon = hash.to_icon
|
|
19
|
+
aggregate_failures do
|
|
20
|
+
expect(icon).to be_an(::HasHelpers::Icon)
|
|
21
|
+
expect(icon.instance_variable_get(:@name)).to eq(:clock)
|
|
22
|
+
expect(icon.orientation).to eq(:upside_down)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "#to_input" do
|
|
28
|
+
it "returns an input instance using the current hash as parameters" do
|
|
29
|
+
expect({ name: :submit, value: :save }.to_input).to be_an(Input)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "#to_action" do
|
|
34
|
+
it "returns an action instance using the current hash as parameters" do
|
|
35
|
+
expect({ label: "Look here" }.to_action).to be_an(Action)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "#to_html_attrs" do
|
|
40
|
+
it "returns an html_attrs instance using the current hash as parameters" do
|
|
41
|
+
expect({ class: "btn btn-default" }.to_html_attrs).to be_an(::HasHelpers::UIAttributes::HTMLAttributes::HTMLAttrs)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "#to_renderable" do
|
|
46
|
+
it { expect({}.to_renderable).to be_a(::RenderObject) }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe ::HasHelpers::CoreExt::Integer do
|
|
4
|
+
describe "#to_renderable" do
|
|
5
|
+
subject { 15 }
|
|
6
|
+
it { expect(subject.to_renderable).to be_a(::HasHelpers::TextNode) }
|
|
7
|
+
it { expect(subject.to_renderable.str).to eq(subject.to_s) }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe ::HasHelpers::CoreExt::NilClass do
|
|
4
|
+
describe "#to_bool" do
|
|
5
|
+
it { expect(nil.to_bool).to be(false) }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "#to_d" do
|
|
9
|
+
it { expect(nil.to_d).to eq(BigDecimal(0)) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "#to_renderable" do
|
|
13
|
+
subject { nil }
|
|
14
|
+
it { expect(subject.to_renderable).to be_a(::HasHelpers::TextNode) }
|
|
15
|
+
it { expect(subject.to_renderable.str).to eq("NIL") }
|
|
16
|
+
end
|
|
17
|
+
end
|