foobara 0.5.10 → 0.6.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 +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +22 -0
- data/lib/foobara/all.rb +4 -2
- data/projects/command/src/command_pattern_implementation/concerns/command_data.rb +3 -3
- data/projects/command/src/command_pattern_implementation/concerns/domain_mappers.rb +2 -2
- data/projects/command/src/command_pattern_implementation/concerns/errors.rb +27 -27
- data/projects/command/src/command_pattern_implementation/concerns/errors_type.rb +7 -11
- data/projects/command/src/command_pattern_implementation/concerns/inputs.rb +4 -24
- data/projects/command/src/command_pattern_implementation/concerns/inputs_type.rb +9 -14
- data/projects/command/src/command_pattern_implementation/concerns/reflection.rb +7 -20
- data/projects/command/src/command_pattern_implementation/concerns/runtime.rb +3 -48
- data/projects/command/src/command_pattern_implementation/concerns/subcommands.rb +5 -5
- data/projects/command/src/command_pattern_implementation.rb +0 -1
- data/projects/command_connectors/lib/foobara/command_connectors.rb +1 -1
- data/projects/command_connectors/src/command_connector/concerns/desugarizers.rb +5 -5
- data/projects/command_connectors/src/command_connector/concerns/reflection.rb +63 -17
- data/projects/command_connectors/src/command_connector/request.rb +26 -10
- data/projects/command_connectors/src/command_connector/response.rb +2 -0
- data/projects/command_connectors/src/command_connector.rb +62 -58
- data/projects/command_connectors/src/command_registry/exposed_command.rb +7 -2
- data/projects/command_connectors/src/command_registry.rb +24 -18
- data/projects/command_connectors/src/desugarizer.rb +2 -2
- data/projects/command_connectors/src/desugarizers/attributes.rb +8 -8
- data/projects/command_connectors/src/desugarizers/auth.rb +1 -1
- data/projects/command_connectors/src/desugarizers/set_inputs.rb +3 -3
- data/projects/command_connectors/src/desugarizers/symbols_to_true.rb +2 -2
- data/projects/command_connectors/src/request_mutator.rb +6 -6
- data/projects/command_connectors/src/response_mutator.rb +6 -6
- data/projects/command_connectors/src/transformed_command.rb +39 -36
- data/projects/command_connectors/src/transformers/auth_errors_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/entity_to_primary_key_inputs_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/load_delegated_attributes_entities_pre_commit_transformer.rb +1 -1
- data/projects/domain_mapper/src/domain_mapper.rb +4 -4
- data/projects/domain_mapper/src/domain_mapper_lookups.rb +3 -3
- data/projects/entities/projects/detached_entity/lib/foobara/detached_entity.rb +1 -1
- data/projects/entities/projects/detached_entity/src/concerns/associations.rb +18 -18
- data/projects/entities/projects/detached_entity/src/concerns/initialization.rb +2 -2
- data/projects/entities/projects/detached_entity/src/concerns/primary_key.rb +4 -4
- data/projects/entities/projects/detached_entity/src/concerns/types.rb +2 -2
- data/projects/entities/projects/detached_entity/src/detached_entity_type.rb +4 -4
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/primary_key.rb +1 -1
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/model_instance_is_valid.rb +2 -2
- data/projects/entities/projects/detached_entity/src/extensions/type_declarations/handlers/registered_type_declaration/validate_primary_key_present.rb +30 -0
- data/projects/entities/projects/detached_entity/src/remove_sensitive_values_transformer_extensions.rb +2 -2
- data/projects/entities/projects/entity/lib/foobara/entity.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/attributes.rb +6 -6
- data/projects/entities/projects/entity/src/concerns/callbacks.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/initialization.rb +8 -8
- data/projects/entities/projects/entity/src/concerns/mutations.rb +4 -4
- data/projects/entities/projects/entity/src/concerns/persistence.rb +3 -3
- data/projects/entities/projects/entity/src/concerns/queries.rb +7 -7
- data/projects/entities/projects/entity/src/extensions/domain/domain_module_extension.rb +4 -4
- data/projects/entities/projects/entity/src/new_prepend.rb +2 -2
- data/projects/entities/projects/entity/src/not_found_error.rb +8 -8
- data/projects/entities/projects/entity/src/sensitive_value_removers/entity.rb +8 -5
- data/projects/entities/projects/in_memory_crud_driver_minimal/src/in_memory_minimal.rb +4 -4
- data/projects/entities/projects/model_attribute_helpers/lib/foobara/model_attribute_helpers.rb +0 -2
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helper_aliases.rb +1 -1
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helpers.rb +2 -2
- data/projects/entities/projects/nested_transactionable/lib/foobara/nested_transactionable.rb +5 -5
- data/projects/entities/projects/persistence/lib/foobara/persistence.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_attributes_crud_driver.rb +35 -37
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/entity_callback_handling.rb +25 -25
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/state_transitions.rb +8 -8
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/transaction_tracking.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_base/transaction.rb +9 -9
- data/projects/entities/projects/persistence/src/entity_base/transaction_table/concerns/record_tracking.rb +4 -4
- data/projects/entities/projects/persistence/src/entity_base/transaction_table.rb +52 -52
- data/projects/entities/projects/persistence/src/entity_base.rb +7 -7
- data/projects/entities/projects/persistence/src/persistence.rb +23 -23
- data/projects/entities/projects/weak_object_set/src/weak_object_set.rb +16 -16
- data/projects/entities_plumbing/lib/foobara/entities_plumbing.rb +6 -2
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entities.rb +21 -5
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_errors_type.rb +23 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_inputs.rb +33 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_reflection.rb +39 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/runtime.rb +39 -0
- data/projects/manifest/src/base_manifest.rb +9 -9
- data/projects/manifest/src/model.rb +4 -4
- data/projects/manifest/src/type.rb +3 -3
- data/projects/manifest/src/type_declaration.rb +4 -4
- data/projects/model_plumbing/lib/foobara/model_plumbing.rb +2 -0
- data/projects/model_plumbing/src/extensions/command_pattern_implementation/concerns/model_inputs_type.rb +35 -0
- data/projects/typesystem/projects/builtin_types/lib/foobara/builtin_types.rb +2 -1
- data/projects/typesystem/projects/builtin_types/src/builtin_types.rb +8 -8
- data/projects/typesystem/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/module_desugarizer.rb +2 -2
- data/projects/typesystem/projects/builtin_types/src/email/validator_base.rb +4 -4
- data/projects/typesystem/projects/callback/src/block/concerns/block_parameter_required.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/keyword_argumentable_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/single_argument_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block.rb +4 -4
- data/projects/typesystem/projects/callback/src/registry/base.rb +10 -10
- data/projects/typesystem/projects/callback/src/registry/conditioned.rb +2 -2
- data/projects/typesystem/projects/callback/src/registry/multiple_action.rb +6 -6
- data/projects/typesystem/projects/callback/src/runner.rb +4 -4
- data/projects/typesystem/projects/callback/src/set.rb +4 -4
- data/projects/typesystem/projects/common/src/data_path.rb +14 -14
- data/projects/typesystem/projects/common/src/error.rb +11 -11
- data/projects/typesystem/projects/common/src/error_collection.rb +14 -14
- data/projects/typesystem/projects/common/src/error_key.rb +5 -3
- data/projects/typesystem/projects/common/src/outcome.rb +5 -5
- data/projects/typesystem/projects/common/src/possible_error.rb +2 -2
- data/projects/typesystem/projects/concerns/src/concern.rb +3 -3
- data/projects/typesystem/projects/delegate/src/extensions/module.rb +4 -4
- data/projects/typesystem/projects/domain/lib/foobara/domain.rb +2 -2
- data/projects/typesystem/projects/domain/src/domain.rb +5 -5
- data/projects/typesystem/projects/domain/src/domain_module_extension.rb +22 -22
- data/projects/typesystem/projects/domain/src/extensions/foobara.rb +14 -6
- data/projects/typesystem/projects/domain/src/module_extension.rb +4 -4
- data/projects/typesystem/projects/domain/src/organization.rb +6 -6
- data/projects/typesystem/projects/enumerated/src/accessors.rb +4 -4
- data/projects/typesystem/projects/enumerated/src/values.rb +14 -14
- data/projects/{entities → typesystem}/projects/model/lib/foobara/model.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/concerns/classes.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/concerns/types.rb +5 -5
- data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/casters/hash.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +6 -6
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb +6 -10
- data/projects/{entities → typesystem}/projects/model/src/model.rb +13 -13
- data/projects/{entities → typesystem}/projects/model/src/sensitive_value_removers/model.rb +1 -1
- data/projects/typesystem/projects/namespace/src/ambiguous_registry.rb +5 -5
- data/projects/typesystem/projects/namespace/src/base_registry.rb +8 -8
- data/projects/typesystem/projects/namespace/src/is_namespace.rb +19 -19
- data/projects/typesystem/projects/namespace/src/namespace/lookup_mode.rb +2 -2
- data/projects/typesystem/projects/namespace/src/namespace.rb +5 -5
- data/projects/typesystem/projects/namespace/src/namespace_helpers.rb +4 -4
- data/projects/typesystem/projects/namespace/src/prefixless_registry.rb +3 -3
- data/projects/typesystem/projects/namespace/src/scoped.rb +7 -7
- data/projects/typesystem/projects/project/src/foobara.rb +13 -7
- data/projects/typesystem/projects/project/src/project.rb +1 -1
- data/projects/typesystem/projects/state_machine/src/callbacks.rb +14 -14
- data/projects/typesystem/projects/state_machine/src/state_machine.rb +2 -2
- data/projects/typesystem/projects/state_machine/src/sugar.rb +3 -3
- data/projects/typesystem/projects/type_declarations/lib/foobara/type_declarations.rb +1 -1
- data/projects/typesystem/projects/type_declarations/src/attributes.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/from_yaml.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/reject.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/set.rb +4 -4
- data/projects/typesystem/projects/type_declarations/src/desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/dsl/attributes.rb +9 -9
- data/projects/typesystem/projects/type_declarations/src/error_extension.rb +6 -6
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/registered_type_declaration.rb +4 -3
- data/projects/typesystem/projects/type_declarations/src/remove_sensitive_values_transformer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/type_builder.rb +5 -5
- data/projects/typesystem/projects/type_declarations/src/type_declaration.rb +7 -1
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler.rb +13 -13
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler_registry.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declaration_validator.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declarations.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/with_registries.rb +2 -2
- data/projects/typesystem/projects/types/lib/foobara/types.rb +0 -2
- data/projects/typesystem/projects/types/src/extensions/error.rb +5 -5
- data/projects/typesystem/projects/types/src/type/concerns/reflection.rb +22 -22
- data/projects/typesystem/projects/types/src/type/concerns/supported_processor_registration.rb +4 -4
- data/projects/typesystem/projects/types/src/type.rb +25 -25
- data/projects/typesystem/projects/value/src/caster.rb +11 -11
- data/projects/typesystem/projects/value/src/data_error.rb +1 -1
- data/projects/typesystem/projects/value/src/mutator.rb +3 -3
- data/projects/typesystem/projects/value/src/processor/casting.rb +6 -6
- data/projects/typesystem/projects/value/src/processor/pipeline.rb +2 -2
- data/projects/typesystem/projects/value/src/processor/runner.rb +1 -1
- data/projects/typesystem/projects/value/src/processor/selection.rb +3 -3
- data/projects/typesystem/projects/value/src/processor.rb +23 -23
- data/projects/typesystem/projects/value/src/transformer.rb +5 -5
- data/projects/typesystem/projects/value/src/validator.rb +3 -3
- data/version.rb +2 -2
- metadata +44 -160
- data/projects/command_connectors/Guardfile +0 -6
- data/projects/command_connectors/spec/allowed_rules_spec.rb +0 -77
- data/projects/command_connectors/spec/ambiguous_lookups_spec.rb +0 -143
- data/projects/command_connectors/spec/auth_mappers_spec.rb +0 -201
- data/projects/command_connectors/spec/command_connector_spec.rb +0 -2460
- data/projects/command_connectors/spec/command_registry_spec.rb +0 -9
- data/projects/command_connectors/spec/commands/describe_spec.rb +0 -83
- data/projects/command_connectors/spec/commands/ping_spec.rb +0 -14
- data/projects/command_connectors/spec/commands/query_git_commit_info_spec.rb +0 -55
- data/projects/command_connectors/spec/fixtures/command_connectors/manifest_with_errors_with_missing_command_parents.yaml +0 -1662
- data/projects/command_connectors/spec/not_found_error_spec.rb +0 -17
- data/projects/command_connectors/spec/pre_commit_transformers/load_atoms_pre_commit_transformer_spec.rb +0 -108
- data/projects/command_connectors/spec/request_spec.rb +0 -118
- data/projects/command_connectors/spec/serializer_spec.rb +0 -9
- data/projects/command_connectors/spec/serializers/aggregate_serializer_spec.rb +0 -45
- data/projects/command_connectors/spec/serializers/atomic_serializer_spec.rb +0 -68
- data/projects/command_connectors/spec/serializers/entities_to_primary_keys_serializer_spec.rb +0 -36
- data/projects/command_connectors/spec/serializers/json_serializer_spec.rb +0 -22
- data/projects/command_connectors/spec/serializers/noop_serializer_spec.rb +0 -22
- data/projects/command_connectors/spec/serializers/yaml_serializer_spec.rb +0 -22
- data/projects/command_connectors/spec/spec_helper.rb +0 -56
- data/projects/command_connectors/spec/support/rubyprof.rb +0 -32
- data/projects/command_connectors/spec/support/term_trap.rb +0 -6
- data/projects/command_connectors/spec/transformers/entity_to_primary_key_inputs_transformer_spec.rb +0 -119
- data/projects/entities/Guardfile +0 -6
- data/projects/entities/spec/builtin_types/detached_entity_spec.rb +0 -300
- data/projects/entities/spec/builtin_types/entity_spec.rb +0 -501
- data/projects/entities/spec/builtin_types/model_spec.rb +0 -420
- data/projects/entities/spec/detached_entity/casting_spec.rb +0 -31
- data/projects/entities/spec/entity/concerns/associations_spec.rb +0 -73
- data/projects/entities/spec/entity/concerns/attribute_helpers_spec.rb +0 -220
- data/projects/entities/spec/entity/concerns/callbacks_spec.rb +0 -61
- data/projects/entities/spec/entity/concerns/initialization_spec.rb +0 -213
- data/projects/entities/spec/entity/concerns/mutations_spec.rb +0 -38
- data/projects/entities/spec/entity/concerns/queries_spec.rb +0 -184
- data/projects/entities/spec/entity/entity_spec.rb +0 -240
- data/projects/entities/spec/entity/extending_existing_spec.rb +0 -137
- data/projects/entities/spec/entity/extensions/domain_module_extension_spec.rb +0 -42
- data/projects/entities/spec/entity/from_type_declaration_spec.rb +0 -34
- data/projects/entities/spec/entity/that_owns_spec.rb +0 -243
- data/projects/entities/spec/entity/weak_object_set_spec.rb +0 -91
- data/projects/entities/spec/model/model_spec.rb +0 -135
- data/projects/entities/spec/model/types_spec.rb +0 -397
- data/projects/entities/spec/nested_transactionable/nested_transactionable_spec.rb +0 -67
- data/projects/entities/spec/persistence/entity_attributes_crud_drivers/in_memory_minimal_spec.rb +0 -13
- data/projects/entities/spec/persistence/entity_base/transaction_spec.rb +0 -509
- data/projects/entities/spec/persistence/entity_base/transaction_table_spec.rb +0 -58
- data/projects/entities/spec/persistence/persistence_spec.rb +0 -148
- data/projects/entities/spec/spec_helper.rb +0 -54
- data/projects/entities/spec/support/rubyprof.rb +0 -32
- data/projects/entities/spec/support/term_trap.rb +0 -6
- data/projects/entities/spec/type_declarations/sensitive_type_removers_spec.rb +0 -90
- data/projects/entities_plumbing/Guardfile +0 -6
- data/projects/entities_plumbing/spec/auth_mappers_spec.rb +0 -159
- data/projects/entities_plumbing/spec/spec_helper.rb +0 -55
- data/projects/entities_plumbing/spec/support/rubyprof.rb +0 -32
- data/projects/entities_plumbing/spec/support/term_trap.rb +0 -6
- data/projects/entities_plumbing/spec/transaction_spec.rb +0 -534
- data/projects/manifest/Guardfile +0 -6
- data/projects/manifest/spec/associations_spec.rb +0 -67
- data/projects/manifest/spec/manifest_spec.rb +0 -382
- data/projects/manifest/spec/model_spec.rb +0 -126
- data/projects/manifest/spec/spec_helper.rb +0 -54
- data/projects/manifest/spec/type_declaration_spec.rb +0 -39
- data/projects/manifest/spec/type_spec.rb +0 -30
- data/projects/typesystem/spec/builtin_types/allow_nil_spec.rb +0 -138
- data/projects/typesystem/spec/builtin_types/array_spec.rb +0 -140
- data/projects/typesystem/spec/builtin_types/associative_array_spec.rb +0 -228
- data/projects/typesystem/spec/builtin_types/attributes_spec.rb +0 -490
- data/projects/typesystem/spec/builtin_types/big_decimal_spec.rb +0 -42
- data/projects/typesystem/spec/builtin_types/boolean_spec.rb +0 -43
- data/projects/typesystem/spec/builtin_types/class_type_desugarizer_spec.rb +0 -17
- data/projects/typesystem/spec/builtin_types/custom_type_spec.rb +0 -430
- data/projects/typesystem/spec/builtin_types/date_spec.rb +0 -37
- data/projects/typesystem/spec/builtin_types/datetime_spec.rb +0 -49
- data/projects/typesystem/spec/builtin_types/email_spec.rb +0 -44
- data/projects/typesystem/spec/builtin_types/float_spec.rb +0 -59
- data/projects/typesystem/spec/builtin_types/instance_of_spec.rb +0 -75
- data/projects/typesystem/spec/builtin_types/one_of_spec.rb +0 -73
- data/projects/typesystem/spec/builtin_types/string_spec.rb +0 -117
- data/projects/typesystem/spec/builtin_types/symbol_spec.rb +0 -24
- data/projects/typesystem/spec/builtin_types/tuple_spec.rb +0 -125
- data/projects/typesystem/spec/callback/callback_spec.rb +0 -155
- data/projects/typesystem/spec/callback/registry/conditioned_spec.rb +0 -152
- data/projects/typesystem/spec/callback/registry/multiple_action_spec.rb +0 -144
- data/projects/typesystem/spec/callback/registry/single_action_spec.rb +0 -114
- data/projects/typesystem/spec/common/data_path_spec.rb +0 -268
- data/projects/typesystem/spec/common/error_collection_spec.rb +0 -77
- data/projects/typesystem/spec/common/error_key_spec.rb +0 -56
- data/projects/typesystem/spec/common/outcome_spec.rb +0 -65
- data/projects/typesystem/spec/common/possible_error_spec.rb +0 -17
- data/projects/typesystem/spec/concerns/concern_spec.rb +0 -122
- data/projects/typesystem/spec/enumerated/accessors_spec.rb +0 -182
- data/projects/typesystem/spec/enumerated/enumerated_spec.rb +0 -32
- data/projects/typesystem/spec/enumerated/values_spec.rb +0 -67
- data/projects/typesystem/spec/foobara/foobara_spec.rb +0 -45
- data/projects/typesystem/spec/namespace/ambiguous_registry_spec.rb +0 -70
- data/projects/typesystem/spec/namespace/foobara_simulation_spec.rb +0 -254
- data/projects/typesystem/spec/namespace/is_namespace_spec.rb +0 -103
- data/projects/typesystem/spec/namespace/namespace_helpers_spec.rb +0 -67
- data/projects/typesystem/spec/namespace/namespace_spec.rb +0 -335
- data/projects/typesystem/spec/namespace/prefixless_registry_spec.rb +0 -30
- data/projects/typesystem/spec/namespace/unambiguous_registry_spec.rb +0 -50
- data/projects/typesystem/spec/spec_helper.rb +0 -52
- data/projects/typesystem/spec/state_machine/callbacks_spec.rb +0 -144
- data/projects/typesystem/spec/state_machine/state_machine_spec.rb +0 -224
- data/projects/typesystem/spec/state_machine/target_attribute_spec.rb +0 -46
- data/projects/typesystem/spec/support/rubyprof.rb +0 -32
- data/projects/typesystem/spec/support/term_trap.rb +0 -6
- data/projects/typesystem/spec/type_declarations/attributes_spec.rb +0 -14
- data/projects/typesystem/spec/type_declarations/attributes_transformer_spec.rb +0 -95
- data/projects/typesystem/spec/type_declarations/dsl/attributes_spec.rb +0 -107
- data/projects/typesystem/spec/type_declarations/handlers/extend_registered_type_declaration_spec.rb +0 -13
- data/projects/typesystem/spec/type_declarations/sensitive_type_removers_spec.rb +0 -210
- data/projects/typesystem/spec/type_declarations/type_builder_spec.rb +0 -47
- data/projects/typesystem/spec/type_declarations/type_declaration_spec.rb +0 -252
- data/projects/typesystem/spec/type_declarations/type_declarations_spec.rb +0 -11
- data/projects/typesystem/spec/type_declarations/typed_transformer_spec.rb +0 -65
- data/projects/typesystem/spec/types/sensitive_spec.rb +0 -36
- data/projects/typesystem/spec/types/type_spec.rb +0 -102
- data/projects/typesystem/spec/value/caster_spec.rb +0 -23
- data/projects/typesystem/spec/value/processor/runner_spec.rb +0 -34
- data/projects/typesystem/spec/value/processor/selection_spec.rb +0 -71
- data/projects/typesystem/spec/value/processor_spec.rb +0 -76
- data/projects/typesystem/spec/value/transformer_spec.rb +0 -27
- /data/projects/{command/src → entities_plumbing/src/extensions}/command_pattern_implementation/concerns/transactions.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/aliases.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/reflection.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/validators/model_instance_is_valid.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/valid_attribute_names.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/extended_model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/model.rb +0 -0
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Entity do
|
|
2
|
-
after do
|
|
3
|
-
Foobara.reset_alls
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
let(:entity_class) do
|
|
7
|
-
stub_class = ->(klass) { stub_const(klass.name, klass) }
|
|
8
|
-
|
|
9
|
-
Class.new(described_class) do
|
|
10
|
-
class << self
|
|
11
|
-
def name
|
|
12
|
-
"SomeEntity"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
stub_class.call(self)
|
|
17
|
-
|
|
18
|
-
attributes pk: :integer,
|
|
19
|
-
foo: :integer,
|
|
20
|
-
bar: :symbol
|
|
21
|
-
|
|
22
|
-
primary_key :pk
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
let(:attributes) do
|
|
27
|
-
{
|
|
28
|
-
foo: 12,
|
|
29
|
-
bar: :baz
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "with transaction" do
|
|
34
|
-
around do |example|
|
|
35
|
-
Foobara::Persistence.default_crud_driver = Foobara::Persistence::CrudDrivers::InMemory.new
|
|
36
|
-
|
|
37
|
-
Foobara::Persistence.default_base.transaction do
|
|
38
|
-
example.run
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
before do
|
|
43
|
-
# TODO: move these checks to a persistence_spec
|
|
44
|
-
expect(Foobara::Persistence.object_to_base(entity_class)).to eq(Foobara::Persistence.default_base)
|
|
45
|
-
expect(Foobara::Persistence.object_to_base(:default_entity_base)).to eq(Foobara::Persistence.default_base)
|
|
46
|
-
expect(Foobara::Persistence.object_to_base("default_entity_base")).to eq(Foobara::Persistence.default_base)
|
|
47
|
-
|
|
48
|
-
Foobara::Persistence.transaction(entity_class, mode: :open_new) do
|
|
49
|
-
loaded_and_persisted_record
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# TODO: implement a no-transaction-required type of mode
|
|
53
|
-
unloaded_thunk_record
|
|
54
|
-
not_persisted_record
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
let(:loaded_and_persisted_record) do
|
|
58
|
-
entity_class.create(attributes)
|
|
59
|
-
end
|
|
60
|
-
let(:unloaded_thunk_record) do
|
|
61
|
-
entity_class.thunk(pk)
|
|
62
|
-
end
|
|
63
|
-
let(:not_persisted_record) do
|
|
64
|
-
# Just testing some un-tested code with this pointless transaction block...
|
|
65
|
-
transactions = [Foobara::Persistence.default_base.current_transaction]
|
|
66
|
-
Foobara::Persistence::EntityBase.using_transactions(transactions) do
|
|
67
|
-
entity_class.create(attributes)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
let(:pk) { loaded_and_persisted_record.pk }
|
|
72
|
-
|
|
73
|
-
describe "#loaded? and #persisted?" do
|
|
74
|
-
it "gives the right answer for various contexts" do
|
|
75
|
-
expect(loaded_and_persisted_record.pk).to be_an(Integer)
|
|
76
|
-
|
|
77
|
-
expect(loaded_and_persisted_record).to be_loaded
|
|
78
|
-
expect(unloaded_thunk_record).to_not be_loaded
|
|
79
|
-
expect(not_persisted_record).to_not be_loaded
|
|
80
|
-
|
|
81
|
-
expect(loaded_and_persisted_record).to be_persisted
|
|
82
|
-
expect(unloaded_thunk_record).to be_persisted
|
|
83
|
-
expect(not_persisted_record).to_not be_persisted
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
describe "setting primary key" do
|
|
88
|
-
it "is not allowed unless it's the same" do
|
|
89
|
-
not_persisted_record.pk = 6
|
|
90
|
-
expect(not_persisted_record.primary_key).to eq(6)
|
|
91
|
-
|
|
92
|
-
expect(loaded_and_persisted_record.primary_key).to eq(1)
|
|
93
|
-
entity_class.transaction(mode: :use_existing) do
|
|
94
|
-
record = entity_class.thunk(loaded_and_persisted_record.primary_key)
|
|
95
|
-
expect(record.primary_key).to eq(1)
|
|
96
|
-
record.pk = "1"
|
|
97
|
-
expect(record.primary_key).to eq(1)
|
|
98
|
-
expect {
|
|
99
|
-
record.pk = 13
|
|
100
|
-
}.to raise_error(Foobara::Entity::UnexpectedPrimaryKeyChangeError)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
describe "#write_attribute_without_callbacks!" do
|
|
106
|
-
it "blows up on invalid values" do
|
|
107
|
-
record = entity_class.create
|
|
108
|
-
|
|
109
|
-
record.write_attribute_without_callbacks!(:foo, 5)
|
|
110
|
-
expect(record.foo).to eq(5)
|
|
111
|
-
|
|
112
|
-
expect {
|
|
113
|
-
record.write_attribute_without_callbacks!(:foo, "asdf")
|
|
114
|
-
}.to raise_error(Foobara::Value::Processor::Casting::CannotCastError)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
describe ".model_type.process_value!" do
|
|
120
|
-
before do
|
|
121
|
-
Foobara::Persistence.default_crud_driver = Foobara::Persistence::CrudDrivers::InMemory.new
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
context "when record comes from a different closed transaction" do
|
|
125
|
-
let(:record_from_a_different_transaction) do
|
|
126
|
-
entity_class.transaction do
|
|
127
|
-
entity_class.create(attributes)
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it "casts it to a new thunk from the current transaction using its primary key" do
|
|
132
|
-
record_from_a_different_transaction
|
|
133
|
-
|
|
134
|
-
cast_value = entity_class.transaction do
|
|
135
|
-
entity_class.model_type.process_value!(record_from_a_different_transaction)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
expect(cast_value).to be_a(entity_class)
|
|
139
|
-
expect(cast_value.pk).to eq(record_from_a_different_transaction.pk)
|
|
140
|
-
expect(cast_value.object_id).to_not eq(record_from_a_different_transaction.object_id)
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
describe "equality methods" do
|
|
146
|
-
let(:loaded_and_persisted_record) do
|
|
147
|
-
entity_class.build(attributes.merge(pk:)).tap do |record|
|
|
148
|
-
record.is_persisted = true
|
|
149
|
-
record.is_loaded = true
|
|
150
|
-
|
|
151
|
-
expect(record).to be_persisted
|
|
152
|
-
expect(record).to be_loaded
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
let(:unloaded_thunk_record) do
|
|
156
|
-
entity_class.build(pk:)
|
|
157
|
-
end
|
|
158
|
-
let(:not_persisted_record) do
|
|
159
|
-
entity_class.build(attributes)
|
|
160
|
-
end
|
|
161
|
-
let(:not_persisted_record_with_pk) do
|
|
162
|
-
entity_class.build(attributes.merge(pk:))
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
let(:pk) { 10 }
|
|
166
|
-
|
|
167
|
-
describe "#== #hash and #eql?" do
|
|
168
|
-
it "gives the expected result for various scenarios" do
|
|
169
|
-
# rubocop:disable RSpec/IdenticalEqualityAssertion
|
|
170
|
-
# ==
|
|
171
|
-
expect(loaded_and_persisted_record).to eq(loaded_and_persisted_record)
|
|
172
|
-
expect(unloaded_thunk_record).to eq(unloaded_thunk_record)
|
|
173
|
-
expect(not_persisted_record).to eq(not_persisted_record)
|
|
174
|
-
expect(not_persisted_record_with_pk).to eq(not_persisted_record_with_pk)
|
|
175
|
-
|
|
176
|
-
expect(loaded_and_persisted_record).to eq(unloaded_thunk_record)
|
|
177
|
-
expect(loaded_and_persisted_record).to_not eq(not_persisted_record)
|
|
178
|
-
# Tricky to think of what this comparison should be.
|
|
179
|
-
# One thought would be that they are not equal and persisting the non-persisted one should result
|
|
180
|
-
# in an error. But will go with considering them equal for now and maybe revisit.
|
|
181
|
-
expect(loaded_and_persisted_record).to eq(not_persisted_record_with_pk)
|
|
182
|
-
|
|
183
|
-
expect(unloaded_thunk_record).to eq(loaded_and_persisted_record)
|
|
184
|
-
expect(unloaded_thunk_record).to_not eq(not_persisted_record)
|
|
185
|
-
expect(unloaded_thunk_record).to eq(not_persisted_record_with_pk)
|
|
186
|
-
|
|
187
|
-
expect(not_persisted_record).to_not eq(loaded_and_persisted_record)
|
|
188
|
-
expect(not_persisted_record).to_not eq(unloaded_thunk_record)
|
|
189
|
-
expect(not_persisted_record).to_not eq(not_persisted_record_with_pk)
|
|
190
|
-
|
|
191
|
-
expect(entity_class.build(attributes.dup)).to_not eq(entity_class.build(attributes.dup))
|
|
192
|
-
|
|
193
|
-
# hash
|
|
194
|
-
expect(loaded_and_persisted_record.hash).to eq(loaded_and_persisted_record.hash)
|
|
195
|
-
expect(unloaded_thunk_record.hash).to eq(unloaded_thunk_record.hash)
|
|
196
|
-
expect(not_persisted_record.hash).to eq(not_persisted_record.hash)
|
|
197
|
-
expect(not_persisted_record_with_pk.hash).to eq(not_persisted_record_with_pk.hash)
|
|
198
|
-
|
|
199
|
-
expect(loaded_and_persisted_record.hash).to eq(unloaded_thunk_record.hash)
|
|
200
|
-
expect(loaded_and_persisted_record.hash).to_not eq(not_persisted_record.hash)
|
|
201
|
-
expect(loaded_and_persisted_record.hash).to eq(not_persisted_record_with_pk.hash)
|
|
202
|
-
|
|
203
|
-
expect(unloaded_thunk_record.hash).to eq(loaded_and_persisted_record.hash)
|
|
204
|
-
expect(unloaded_thunk_record.hash).to_not eq(not_persisted_record.hash)
|
|
205
|
-
expect(unloaded_thunk_record.hash).to eq(not_persisted_record_with_pk.hash)
|
|
206
|
-
|
|
207
|
-
expect(not_persisted_record.hash).to_not eq(loaded_and_persisted_record.hash)
|
|
208
|
-
expect(not_persisted_record.hash).to_not eq(unloaded_thunk_record.hash)
|
|
209
|
-
expect(not_persisted_record.hash).to_not eq(not_persisted_record_with_pk.hash)
|
|
210
|
-
|
|
211
|
-
# eql?
|
|
212
|
-
expect(loaded_and_persisted_record).to eql(loaded_and_persisted_record)
|
|
213
|
-
expect(unloaded_thunk_record).to eql(unloaded_thunk_record)
|
|
214
|
-
expect(not_persisted_record).to eql(not_persisted_record)
|
|
215
|
-
expect(not_persisted_record_with_pk).to eql(not_persisted_record_with_pk)
|
|
216
|
-
|
|
217
|
-
expect(loaded_and_persisted_record).to eql(unloaded_thunk_record)
|
|
218
|
-
expect(loaded_and_persisted_record).to_not eql(not_persisted_record)
|
|
219
|
-
expect(loaded_and_persisted_record).to eql(not_persisted_record_with_pk)
|
|
220
|
-
|
|
221
|
-
expect(unloaded_thunk_record).to eql(loaded_and_persisted_record)
|
|
222
|
-
expect(unloaded_thunk_record).to_not eql(not_persisted_record)
|
|
223
|
-
expect(unloaded_thunk_record).to eql(not_persisted_record_with_pk)
|
|
224
|
-
|
|
225
|
-
expect(not_persisted_record).to_not eql(loaded_and_persisted_record)
|
|
226
|
-
expect(not_persisted_record).to_not eql(unloaded_thunk_record)
|
|
227
|
-
expect(not_persisted_record).to_not eql(not_persisted_record_with_pk)
|
|
228
|
-
|
|
229
|
-
expect(entity_class.build(attributes.dup)).to_not eql(entity_class.build(attributes.dup))
|
|
230
|
-
# rubocop:enable RSpec/IdenticalEqualityAssertion
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
describe "#inpsect" do
|
|
236
|
-
subject { entity_class.build(pk: 5).inspect }
|
|
237
|
-
|
|
238
|
-
it { is_expected.to eq("<SomeEntity:5>") }
|
|
239
|
-
end
|
|
240
|
-
end
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Model do
|
|
2
|
-
after do
|
|
3
|
-
Foobara.reset_alls
|
|
4
|
-
if Object.const_defined?(:User)
|
|
5
|
-
Object.send(:remove_const, :User)
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe "extending an entity with mutability" do
|
|
10
|
-
before do
|
|
11
|
-
Foobara::Persistence.default_crud_driver = Foobara::Persistence::CrudDrivers::InMemory.new
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:entity_declaration_data) do
|
|
15
|
-
{
|
|
16
|
-
type: :entity,
|
|
17
|
-
name: "User",
|
|
18
|
-
attributes_declaration: {
|
|
19
|
-
id: { type: :integer },
|
|
20
|
-
name: { type: :string },
|
|
21
|
-
age: { type: :integer }
|
|
22
|
-
},
|
|
23
|
-
primary_key: :id
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
let(:extended_entity_declaration_data) do
|
|
27
|
-
{ type: :User, mutable: [:age] }
|
|
28
|
-
end
|
|
29
|
-
let(:entity_type) do
|
|
30
|
-
Foobara::Domain.global.foobara_type_from_declaration(entity_declaration_data)
|
|
31
|
-
end
|
|
32
|
-
let(:extended_entity_type) do
|
|
33
|
-
Foobara::Domain.global.foobara_type_from_declaration(extended_entity_declaration_data)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "handles an extension properly" do
|
|
37
|
-
expect(entity_type).to be_a(Foobara::Types::Type)
|
|
38
|
-
|
|
39
|
-
described_class.deanonymize_class(entity_type.target_class)
|
|
40
|
-
|
|
41
|
-
User.transaction do
|
|
42
|
-
user = entity_type.process_value!(name: "Fumiko", age: 100)
|
|
43
|
-
expect(user).to be_a(User)
|
|
44
|
-
expect(user.mutable).to be true
|
|
45
|
-
|
|
46
|
-
extended_user = extended_entity_type.process_value!(name: "Barbara", age: 200)
|
|
47
|
-
expect(extended_user).to be_a(User)
|
|
48
|
-
expect(extended_user.mutable).to eq([:age])
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
context "when adding attributes to an existing entity" do
|
|
53
|
-
before do
|
|
54
|
-
entity_type.target_class.class_eval do
|
|
55
|
-
attributes do
|
|
56
|
-
email :string, :required
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "adds the attributes to the existing type" do
|
|
62
|
-
type = Foobara.foobara_lookup_type(:User)
|
|
63
|
-
attributes_type = type.element_types
|
|
64
|
-
expect(attributes_type.element_types.keys).to contain_exactly(:id, :name, :age, :email)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "when changing an entity's immutability" do
|
|
69
|
-
it "updates the type's mutable processor declaration data" do
|
|
70
|
-
entity_type
|
|
71
|
-
expect {
|
|
72
|
-
entity_type.target_class.mutable [:age]
|
|
73
|
-
}.to change { Foobara.foobara_lookup_type(:User).declaration_data[:mutable] }.from(nil).to([:age])
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe "extending a model with mutability" do
|
|
79
|
-
let(:model_declaration_data) do
|
|
80
|
-
{
|
|
81
|
-
type: :model,
|
|
82
|
-
name: "User",
|
|
83
|
-
attributes_declaration: {
|
|
84
|
-
name: { type: :string },
|
|
85
|
-
age: { type: :integer }
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
end
|
|
89
|
-
let(:extended_model_declaration_data) do
|
|
90
|
-
{ type: :User, mutable: [:age] }
|
|
91
|
-
end
|
|
92
|
-
let(:model_type) do
|
|
93
|
-
Foobara::Domain.global.foobara_type_from_declaration(model_declaration_data)
|
|
94
|
-
end
|
|
95
|
-
let(:extended_model_type) do
|
|
96
|
-
Foobara::Domain.global.foobara_type_from_declaration(extended_model_declaration_data)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it "handles an extension properly" do
|
|
100
|
-
expect(model_type).to be_a(Foobara::Types::Type)
|
|
101
|
-
described_class.deanonymize_class(model_type.target_class)
|
|
102
|
-
|
|
103
|
-
user = model_type.process_value!(name: "Fumiko", age: 100)
|
|
104
|
-
expect(user).to be_a(User)
|
|
105
|
-
expect(user.mutable).to be true
|
|
106
|
-
|
|
107
|
-
extended_user = extended_model_type.process_value!(name: "Barbara", age: 200)
|
|
108
|
-
expect(extended_user).to be_a(User)
|
|
109
|
-
expect(extended_user.mutable).to eq([:age])
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
context "when adding attributes to an existing model" do
|
|
113
|
-
before do
|
|
114
|
-
model_type.target_class.class_eval do
|
|
115
|
-
attributes do
|
|
116
|
-
email :string, :required
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "adds the attributes to the existing type" do
|
|
122
|
-
type = Foobara.foobara_lookup_type(:User)
|
|
123
|
-
attributes_type = type.element_types
|
|
124
|
-
expect(attributes_type.element_types.keys).to contain_exactly(:name, :age, :email)
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context "when changing a model's immutability" do
|
|
129
|
-
it "updates the type's mutable processor declaration data" do
|
|
130
|
-
model_type
|
|
131
|
-
expect {
|
|
132
|
-
model_type.target_class.mutable [:age]
|
|
133
|
-
}.to change { Foobara.foobara_lookup_type(:User).declaration_data[:mutable] }.from(nil).to([:age])
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Domain::DomainModuleExtension do
|
|
2
|
-
after do
|
|
3
|
-
Foobara.reset_alls
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
describe ".foobara_set_entity_base" do
|
|
7
|
-
context "when using a table prefix" do
|
|
8
|
-
let(:org) do
|
|
9
|
-
stub_module("SomeOrg") { foobara_organization! }
|
|
10
|
-
end
|
|
11
|
-
let(:domain) do
|
|
12
|
-
org
|
|
13
|
-
stub_module("SomeOrg::SomeDomain") { foobara_domain! }
|
|
14
|
-
end
|
|
15
|
-
let(:some_entity_class) do
|
|
16
|
-
domain
|
|
17
|
-
stub_class("SomeOrg::SomeDomain::SomeEntity", Foobara::Entity) do
|
|
18
|
-
attributes do
|
|
19
|
-
id :integer
|
|
20
|
-
foo :integer
|
|
21
|
-
bar :symbol
|
|
22
|
-
created_at :datetime, :allow_nil
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
primary_key :id
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
let(:driver_class) { Foobara::Persistence::CrudDrivers::InMemory }
|
|
29
|
-
|
|
30
|
-
it "creates a base using the table prefix and uses it for the entities in that domain" do
|
|
31
|
-
base = domain.foobara_set_entity_base(driver_class, table_prefix: "some_prefix")
|
|
32
|
-
expect(domain.foobara_default_entity_base).to be(base)
|
|
33
|
-
|
|
34
|
-
expect(some_entity_class.entity_base).to be(base)
|
|
35
|
-
|
|
36
|
-
expect(
|
|
37
|
-
base.entity_attributes_crud_driver.table_for(some_entity_class).table_name
|
|
38
|
-
).to eq("some_prefix_some_entity")
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Entity do
|
|
2
|
-
context "when creating an entity from declaration data" do
|
|
3
|
-
after do
|
|
4
|
-
Foobara.reset_alls
|
|
5
|
-
|
|
6
|
-
Object.send(:remove_const, :User) if Object.const_defined?(:User)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
let(:declaration_data) do
|
|
10
|
-
{
|
|
11
|
-
type: :entity,
|
|
12
|
-
name: "User",
|
|
13
|
-
model_class: "Foo::Bar::Baz::User",
|
|
14
|
-
model_base_class: "Foobara::Entity",
|
|
15
|
-
attributes_declaration: {
|
|
16
|
-
type: :attributes,
|
|
17
|
-
element_type_declarations: {
|
|
18
|
-
id: { type: :integer },
|
|
19
|
-
name: { type: :string }
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
primary_key: :id,
|
|
23
|
-
model_module: "Foo::Bar::Baz",
|
|
24
|
-
mutable: false
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "creates a model class" do
|
|
29
|
-
expect(Foobara::GlobalDomain).to_not be_foobara_type_registered("User")
|
|
30
|
-
Foobara::GlobalDomain.foobara_type_from_strict_stringified_declaration(declaration_data)
|
|
31
|
-
expect(Foobara::GlobalDomain.foobara_type_registered?("User")).to be true
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Entity do
|
|
2
|
-
# Entity types:
|
|
3
|
-
#
|
|
4
|
-
# one-to-one (default for foo: Bar attribute)
|
|
5
|
-
# one-to-many (default for foo: [Bar] attribute)
|
|
6
|
-
# many-to-one
|
|
7
|
-
# many-to-many
|
|
8
|
-
#
|
|
9
|
-
# .that_own is for many-to-*
|
|
10
|
-
# .that_owns is for one-to-*
|
|
11
|
-
#
|
|
12
|
-
# To specify many-to-* one must add:
|
|
13
|
-
#
|
|
14
|
-
# associations: {
|
|
15
|
-
# foo: {
|
|
16
|
-
# cardinality: "many-to-one"
|
|
17
|
-
# }
|
|
18
|
-
# }
|
|
19
|
-
#
|
|
20
|
-
# otherwise an exception will be thrown from .that_own
|
|
21
|
-
describe ".that_owns" do
|
|
22
|
-
after { Foobara.reset_alls }
|
|
23
|
-
|
|
24
|
-
before do
|
|
25
|
-
Foobara::Persistence.default_crud_driver = Foobara::Persistence::CrudDrivers::InMemory.new
|
|
26
|
-
|
|
27
|
-
stub_class = ->(klass) { stub_const(klass.name, klass) }
|
|
28
|
-
|
|
29
|
-
Class.new(Foobara::Entity) do
|
|
30
|
-
abstract
|
|
31
|
-
|
|
32
|
-
class << self
|
|
33
|
-
def name
|
|
34
|
-
"Base"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
stub_class.call(self)
|
|
39
|
-
|
|
40
|
-
attributes id: :integer
|
|
41
|
-
|
|
42
|
-
primary_key :id
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
Class.new(Base) do
|
|
46
|
-
class << self
|
|
47
|
-
def name
|
|
48
|
-
"User"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
stub_class.call(self)
|
|
53
|
-
|
|
54
|
-
attributes name: { type: :string, required: true }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
Class.new(Base) do
|
|
58
|
-
class << self
|
|
59
|
-
def name
|
|
60
|
-
"Person"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
abstract
|
|
65
|
-
|
|
66
|
-
stub_class.call(self)
|
|
67
|
-
|
|
68
|
-
attributes user: User
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
Class.new(Person) do
|
|
72
|
-
class << self
|
|
73
|
-
def name
|
|
74
|
-
"Applicant"
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
stub_class.call(self)
|
|
79
|
-
|
|
80
|
-
# TODO: make sure this isn't necessary outside of test suite where name is created later...
|
|
81
|
-
set_model_type
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
Class.new(Base) do
|
|
85
|
-
class << self
|
|
86
|
-
def name
|
|
87
|
-
"Package"
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
stub_class.call(self)
|
|
92
|
-
|
|
93
|
-
attributes applicants: [Applicant],
|
|
94
|
-
is_active: :boolean
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
Class.new(Base) do
|
|
98
|
-
class << self
|
|
99
|
-
def name
|
|
100
|
-
"Assignment"
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
stub_class.call(self)
|
|
105
|
-
|
|
106
|
-
attributes package: Package
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
Class.new(Person) do
|
|
110
|
-
class << self
|
|
111
|
-
def name
|
|
112
|
-
"Employee"
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
stub_class.call(self)
|
|
117
|
-
|
|
118
|
-
attributes assignments: { type: :array, element_type_declaration: Assignment, default: [] },
|
|
119
|
-
past_assignments: [Assignment],
|
|
120
|
-
priority_assignment: Assignment
|
|
121
|
-
|
|
122
|
-
association :past_users, "past_assignments.#.package.applicants.#.user"
|
|
123
|
-
association :priority_package, :"priority_assignment.package"
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "can find the appropriate records through various that_owns/that_own calls" do
|
|
128
|
-
expect(Employee.filtered_associations(:Assignment)).to eq(
|
|
129
|
-
["assignments.#", "past_assignments.#", "priority_assignment"]
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
User.transaction do
|
|
133
|
-
applicants = []
|
|
134
|
-
employees = []
|
|
135
|
-
packages = []
|
|
136
|
-
users = []
|
|
137
|
-
|
|
138
|
-
10.times do |i|
|
|
139
|
-
user = User.create(name: "applicant user#{i}")
|
|
140
|
-
users << user
|
|
141
|
-
applicants << Applicant.create(user:)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
10.times do |i|
|
|
145
|
-
user = User.create(name: "employee user#{i}")
|
|
146
|
-
employees << Employee.create(user:)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
20.times do |i|
|
|
150
|
-
packages << Package.create(is_active: i < 3, applicants: [applicants[i % 3]])
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
15.times do |i|
|
|
154
|
-
package = packages[i]
|
|
155
|
-
|
|
156
|
-
assignment = Assignment.create(package:)
|
|
157
|
-
|
|
158
|
-
if i < 10
|
|
159
|
-
employees[i % 4].assignments += [assignment]
|
|
160
|
-
|
|
161
|
-
if i.even?
|
|
162
|
-
employees[(i % 4) + 1].assignments += [assignment]
|
|
163
|
-
end
|
|
164
|
-
else
|
|
165
|
-
employees[0].past_assignments ||= []
|
|
166
|
-
employees[0].past_assignments += [assignment]
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
employee = Employee.all[0]
|
|
171
|
-
employee.priority_assignment = employee.assignments.first
|
|
172
|
-
|
|
173
|
-
expect(Employee.all[1].past_users).to eq([])
|
|
174
|
-
expect(Employee.all[0].past_users).to contain_exactly(users[0], users[1], users[2])
|
|
175
|
-
|
|
176
|
-
applicant = Applicant.all.first
|
|
177
|
-
user = applicant.user
|
|
178
|
-
|
|
179
|
-
expect(Applicant.that_owns(user)).to be(applicant)
|
|
180
|
-
expect(Employee.that_owns(users[0], "past_")).to eq(Employee.all.first)
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
employee_id = nil
|
|
184
|
-
assignment_id = nil
|
|
185
|
-
|
|
186
|
-
applicant_id, user_id = User.transaction do
|
|
187
|
-
a = Applicant.all.first
|
|
188
|
-
[a.id, a.user.id]
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
user = nil
|
|
192
|
-
|
|
193
|
-
User.transaction do
|
|
194
|
-
expect(Employee.all[1].past_users).to eq([])
|
|
195
|
-
# TODO: create .first query
|
|
196
|
-
employee = Employee.all.first
|
|
197
|
-
employee_id = employee.primary_key
|
|
198
|
-
|
|
199
|
-
expect(employee.past_users).to contain_exactly(User.thunk(1), User.thunk(2), User.thunk(3))
|
|
200
|
-
expect(employee.past_users).to eq(employee.values_at("past_assignments.#.package.applicants.#.user"))
|
|
201
|
-
assignment_id = employee.past_assignments.first
|
|
202
|
-
expect(
|
|
203
|
-
Employee.find_by_attribute_containing(:past_assignments, employee.past_assignments.first)
|
|
204
|
-
).to be(employee)
|
|
205
|
-
|
|
206
|
-
user = User.thunk(user_id)
|
|
207
|
-
applicant = Applicant.thunk(applicant_id)
|
|
208
|
-
expect(Applicant.that_owns(user)).to be(applicant)
|
|
209
|
-
expect(Applicant.find_all_by_attribute_any_of(:user, user).to_a).to eq([applicant])
|
|
210
|
-
expect(Employee.that_owns(User.thunk(1), "past_")).to eq(Employee.all.first)
|
|
211
|
-
|
|
212
|
-
expect(employee.priority_package).to be_a(Package)
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
# test when it's tracked but not loaded...
|
|
216
|
-
User.transaction do
|
|
217
|
-
employee = Employee.thunk(employee_id)
|
|
218
|
-
|
|
219
|
-
expect(
|
|
220
|
-
Employee.find_by_attribute_containing(:assignments, 1)
|
|
221
|
-
).to be(employee)
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
User.transaction do
|
|
225
|
-
# This tests the situation where the records have to be fetched from the database to answer the question
|
|
226
|
-
# which covers a few lines of code that might not be hit by the above transaction
|
|
227
|
-
expect(Applicant.find_all_by_attribute_any_of(:user, user).first.id).to eq(applicant_id)
|
|
228
|
-
end
|
|
229
|
-
User.transaction do
|
|
230
|
-
expect(Applicant.that_owns(User.thunk(user_id))).to eq(Applicant.thunk(applicant_id))
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
User.transaction do
|
|
234
|
-
expect(
|
|
235
|
-
Employee.find_by_attribute_containing(:past_assignments, assignment_id).primary_key
|
|
236
|
-
).to be(employee_id)
|
|
237
|
-
expect(User.find_by_attribute(:name, "applicant user5")).to be(User.thunk(6))
|
|
238
|
-
expect(User.find_by(name: "applicant user5")).to be(User.thunk(6))
|
|
239
|
-
expect(User.find_by(name: "does not exist")).to be_nil
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
end
|