ibm_db 5.6.1-arm64-darwin-24
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/CHANGES +299 -0
 - data/LICENSE +55 -0
 - data/MANIFEST +14 -0
 - data/ParameterizedQueries README +39 -0
 - data/README +210 -0
 - data/ext/Makefile +270 -0
 - data/ext/Makefile.nt32 +181 -0
 - data/ext/Makefile.nt32.191 +212 -0
 - data/ext/extconf.rb +320 -0
 - data/ext/gil_release_version.h +3 -0
 - data/ext/ibm_db.bundle +0 -0
 - data/ext/ibm_db.c +11865 -0
 - data/ext/ibm_db.o +0 -0
 - data/ext/mkmf.log +98 -0
 - data/ext/ruby_ibm_db.h +241 -0
 - data/ext/ruby_ibm_db_cli.c +867 -0
 - data/ext/ruby_ibm_db_cli.h +508 -0
 - data/ext/ruby_ibm_db_cli.o +0 -0
 - data/ext/unicode_support_version.h +3 -0
 - data/init.rb +42 -0
 - data/lib/IBM_DB.rb +27 -0
 - data/lib/active_record/connection_adapters/ibm_db_adapter.rb +4407 -0
 - data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1965 -0
 - data/lib/active_record/connection_adapters/ibmdb_adapter.rb +5 -0
 - data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -0
 - data/lib/ibm_db.bundle +0 -0
 - data/test/active_record/connection_adapters/fake_adapter.rb +52 -0
 - data/test/activejob/destroy_association_async_test.rb +305 -0
 - data/test/activejob/destroy_async_job_not_present_test.rb +31 -0
 - data/test/activejob/helper.rb +15 -0
 - data/test/assets/example.log +1 -0
 - data/test/assets/flowers.jpg +0 -0
 - data/test/assets/schema_dump_5_1.yml +345 -0
 - data/test/assets/test.txt +1 -0
 - data/test/cases/adapter_prevent_writes_test.rb +334 -0
 - data/test/cases/adapter_test.rb +565 -0
 - data/test/cases/adapters/mysql2/active_schema_test.rb +203 -0
 - data/test/cases/adapters/mysql2/auto_increment_test.rb +34 -0
 - data/test/cases/adapters/mysql2/bind_parameter_test.rb +52 -0
 - data/test/cases/adapters/mysql2/boolean_test.rb +102 -0
 - data/test/cases/adapters/mysql2/case_sensitivity_test.rb +65 -0
 - data/test/cases/adapters/mysql2/charset_collation_test.rb +57 -0
 - data/test/cases/adapters/mysql2/connection_test.rb +208 -0
 - data/test/cases/adapters/mysql2/count_deleted_rows_with_lock_test.rb +28 -0
 - data/test/cases/adapters/mysql2/datetime_precision_quoting_test.rb +49 -0
 - data/test/cases/adapters/mysql2/enum_test.rb +47 -0
 - data/test/cases/adapters/mysql2/explain_test.rb +23 -0
 - data/test/cases/adapters/mysql2/json_test.rb +24 -0
 - data/test/cases/adapters/mysql2/mysql2_adapter_prevent_writes_test.rb +208 -0
 - data/test/cases/adapters/mysql2/mysql2_adapter_test.rb +238 -0
 - data/test/cases/adapters/mysql2/nested_deadlock_test.rb +75 -0
 - data/test/cases/adapters/mysql2/optimizer_hints_test.rb +69 -0
 - data/test/cases/adapters/mysql2/reserved_word_test.rb +152 -0
 - data/test/cases/adapters/mysql2/schema_migrations_test.rb +64 -0
 - data/test/cases/adapters/mysql2/schema_test.rb +128 -0
 - data/test/cases/adapters/mysql2/set_test.rb +32 -0
 - data/test/cases/adapters/mysql2/sp_test.rb +38 -0
 - data/test/cases/adapters/mysql2/sql_types_test.rb +16 -0
 - data/test/cases/adapters/mysql2/table_options_test.rb +125 -0
 - data/test/cases/adapters/mysql2/transaction_test.rb +151 -0
 - data/test/cases/adapters/mysql2/unsigned_type_test.rb +68 -0
 - data/test/cases/adapters/mysql2/virtual_column_test.rb +66 -0
 - data/test/cases/adapters/postgresql/active_schema_test.rb +113 -0
 - data/test/cases/adapters/postgresql/array_test.rb +394 -0
 - data/test/cases/adapters/postgresql/bit_string_test.rb +84 -0
 - data/test/cases/adapters/postgresql/bytea_test.rb +135 -0
 - data/test/cases/adapters/postgresql/case_insensitive_test.rb +27 -0
 - data/test/cases/adapters/postgresql/change_schema_test.rb +40 -0
 - data/test/cases/adapters/postgresql/cidr_test.rb +27 -0
 - data/test/cases/adapters/postgresql/citext_test.rb +78 -0
 - data/test/cases/adapters/postgresql/collation_test.rb +55 -0
 - data/test/cases/adapters/postgresql/composite_test.rb +134 -0
 - data/test/cases/adapters/postgresql/connection_test.rb +245 -0
 - data/test/cases/adapters/postgresql/create_unlogged_tables_test.rb +74 -0
 - data/test/cases/adapters/postgresql/datatype_test.rb +89 -0
 - data/test/cases/adapters/postgresql/date_test.rb +42 -0
 - data/test/cases/adapters/postgresql/domain_test.rb +49 -0
 - data/test/cases/adapters/postgresql/enum_test.rb +93 -0
 - data/test/cases/adapters/postgresql/explain_test.rb +22 -0
 - data/test/cases/adapters/postgresql/extension_migration_test.rb +64 -0
 - data/test/cases/adapters/postgresql/foreign_table_test.rb +109 -0
 - data/test/cases/adapters/postgresql/full_text_test.rb +46 -0
 - data/test/cases/adapters/postgresql/geometric_test.rb +372 -0
 - data/test/cases/adapters/postgresql/hstore_test.rb +390 -0
 - data/test/cases/adapters/postgresql/infinity_test.rb +108 -0
 - data/test/cases/adapters/postgresql/integer_test.rb +27 -0
 - data/test/cases/adapters/postgresql/interval_test.rb +99 -0
 - data/test/cases/adapters/postgresql/json_test.rb +52 -0
 - data/test/cases/adapters/postgresql/ltree_test.rb +51 -0
 - data/test/cases/adapters/postgresql/money_test.rb +127 -0
 - data/test/cases/adapters/postgresql/network_test.rb +102 -0
 - data/test/cases/adapters/postgresql/numbers_test.rb +51 -0
 - data/test/cases/adapters/postgresql/optimizer_hints_test.rb +71 -0
 - data/test/cases/adapters/postgresql/partitions_test.rb +22 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_prevent_writes_test.rb +205 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_test.rb +447 -0
 - data/test/cases/adapters/postgresql/prepared_statements_disabled_test.rb +27 -0
 - data/test/cases/adapters/postgresql/prepared_statements_test.rb +22 -0
 - data/test/cases/adapters/postgresql/quoting_test.rb +50 -0
 - data/test/cases/adapters/postgresql/range_test.rb +457 -0
 - data/test/cases/adapters/postgresql/referential_integrity_test.rb +112 -0
 - data/test/cases/adapters/postgresql/rename_table_test.rb +35 -0
 - data/test/cases/adapters/postgresql/schema_authorization_test.rb +110 -0
 - data/test/cases/adapters/postgresql/schema_test.rb +713 -0
 - data/test/cases/adapters/postgresql/serial_test.rb +156 -0
 - data/test/cases/adapters/postgresql/statement_pool_test.rb +61 -0
 - data/test/cases/adapters/postgresql/timestamp_test.rb +92 -0
 - data/test/cases/adapters/postgresql/transaction_nested_test.rb +114 -0
 - data/test/cases/adapters/postgresql/transaction_test.rb +189 -0
 - data/test/cases/adapters/postgresql/type_lookup_test.rb +35 -0
 - data/test/cases/adapters/postgresql/utils_test.rb +64 -0
 - data/test/cases/adapters/postgresql/uuid_test.rb +411 -0
 - data/test/cases/adapters/postgresql/xml_test.rb +50 -0
 - data/test/cases/adapters/sqlite3/collation_test.rb +64 -0
 - data/test/cases/adapters/sqlite3/copy_table_test.rb +101 -0
 - data/test/cases/adapters/sqlite3/explain_test.rb +23 -0
 - data/test/cases/adapters/sqlite3/json_test.rb +29 -0
 - data/test/cases/adapters/sqlite3/quoting_test.rb +79 -0
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_prevent_writes_test.rb +186 -0
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +628 -0
 - data/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb +24 -0
 - data/test/cases/adapters/sqlite3/statement_pool_test.rb +21 -0
 - data/test/cases/adapters/sqlite3/transaction_test.rb +123 -0
 - data/test/cases/aggregations_test.rb +170 -0
 - data/test/cases/annotate_test.rb +46 -0
 - data/test/cases/ar_schema_test.rb +213 -0
 - data/test/cases/arel/attributes/attribute_test.rb +1145 -0
 - data/test/cases/arel/attributes/math_test.rb +83 -0
 - data/test/cases/arel/attributes_test.rb +27 -0
 - data/test/cases/arel/collectors/bind_test.rb +40 -0
 - data/test/cases/arel/collectors/composite_test.rb +47 -0
 - data/test/cases/arel/collectors/sql_string_test.rb +41 -0
 - data/test/cases/arel/collectors/substitute_bind_collector_test.rb +48 -0
 - data/test/cases/arel/crud_test.rb +65 -0
 - data/test/cases/arel/delete_manager_test.rb +53 -0
 - data/test/cases/arel/factory_methods_test.rb +46 -0
 - data/test/cases/arel/helper.rb +45 -0
 - data/test/cases/arel/insert_manager_test.rb +241 -0
 - data/test/cases/arel/nodes/and_test.rb +30 -0
 - data/test/cases/arel/nodes/as_test.rb +36 -0
 - data/test/cases/arel/nodes/ascending_test.rb +46 -0
 - data/test/cases/arel/nodes/bin_test.rb +35 -0
 - data/test/cases/arel/nodes/binary_test.rb +29 -0
 - data/test/cases/arel/nodes/bind_param_test.rb +22 -0
 - data/test/cases/arel/nodes/case_test.rb +96 -0
 - data/test/cases/arel/nodes/casted_test.rb +18 -0
 - data/test/cases/arel/nodes/comment_test.rb +22 -0
 - data/test/cases/arel/nodes/count_test.rb +35 -0
 - data/test/cases/arel/nodes/delete_statement_test.rb +36 -0
 - data/test/cases/arel/nodes/descending_test.rb +46 -0
 - data/test/cases/arel/nodes/distinct_test.rb +21 -0
 - data/test/cases/arel/nodes/equality_test.rb +62 -0
 - data/test/cases/arel/nodes/extract_test.rb +43 -0
 - data/test/cases/arel/nodes/false_test.rb +21 -0
 - data/test/cases/arel/nodes/grouping_test.rb +26 -0
 - data/test/cases/arel/nodes/infix_operation_test.rb +42 -0
 - data/test/cases/arel/nodes/insert_statement_test.rb +44 -0
 - data/test/cases/arel/nodes/named_function_test.rb +48 -0
 - data/test/cases/arel/nodes/node_test.rb +22 -0
 - data/test/cases/arel/nodes/not_test.rb +31 -0
 - data/test/cases/arel/nodes/or_test.rb +36 -0
 - data/test/cases/arel/nodes/over_test.rb +69 -0
 - data/test/cases/arel/nodes/select_core_test.rb +79 -0
 - data/test/cases/arel/nodes/select_statement_test.rb +51 -0
 - data/test/cases/arel/nodes/sql_literal_test.rb +75 -0
 - data/test/cases/arel/nodes/sum_test.rb +35 -0
 - data/test/cases/arel/nodes/table_alias_test.rb +29 -0
 - data/test/cases/arel/nodes/true_test.rb +21 -0
 - data/test/cases/arel/nodes/unary_operation_test.rb +41 -0
 - data/test/cases/arel/nodes/update_statement_test.rb +60 -0
 - data/test/cases/arel/nodes/window_test.rb +81 -0
 - data/test/cases/arel/nodes_test.rb +34 -0
 - data/test/cases/arel/select_manager_test.rb +1238 -0
 - data/test/cases/arel/support/fake_record.rb +135 -0
 - data/test/cases/arel/table_test.rb +216 -0
 - data/test/cases/arel/update_manager_test.rb +126 -0
 - data/test/cases/arel/visitors/dispatch_contamination_test.rb +78 -0
 - data/test/cases/arel/visitors/dot_test.rb +90 -0
 - data/test/cases/arel/visitors/mysql_test.rb +157 -0
 - data/test/cases/arel/visitors/postgres_test.rb +366 -0
 - data/test/cases/arel/visitors/sqlite_test.rb +75 -0
 - data/test/cases/arel/visitors/to_sql_test.rb +750 -0
 - data/test/cases/associations/association_scope_test.rb +16 -0
 - data/test/cases/associations/belongs_to_associations_test.rb +1493 -0
 - data/test/cases/associations/bidirectional_destroy_dependencies_test.rb +43 -0
 - data/test/cases/associations/callbacks_test.rb +208 -0
 - data/test/cases/associations/cascaded_eager_loading_test.rb +245 -0
 - data/test/cases/associations/eager_load_includes_full_sti_class_test.rb +156 -0
 - data/test/cases/associations/eager_load_nested_include_test.rb +127 -0
 - data/test/cases/associations/eager_singularization_test.rb +148 -0
 - data/test/cases/associations/eager_test.rb +1658 -0
 - data/test/cases/associations/extension_test.rb +93 -0
 - data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +1025 -0
 - data/test/cases/associations/has_many_associations_test.rb +3074 -0
 - data/test/cases/associations/has_many_through_associations_test.rb +1580 -0
 - data/test/cases/associations/has_one_associations_test.rb +872 -0
 - data/test/cases/associations/has_one_through_associations_test.rb +429 -0
 - data/test/cases/associations/inner_join_association_test.rb +215 -0
 - data/test/cases/associations/inverse_associations_test.rb +941 -0
 - data/test/cases/associations/join_model_test.rb +787 -0
 - data/test/cases/associations/left_outer_join_association_test.rb +123 -0
 - data/test/cases/associations/nested_through_associations_test.rb +636 -0
 - data/test/cases/associations/required_test.rb +127 -0
 - data/test/cases/associations_test.rb +516 -0
 - data/test/cases/attribute_decorators_test.rb +126 -0
 - data/test/cases/attribute_methods/read_test.rb +60 -0
 - data/test/cases/attribute_methods_test.rb +1124 -0
 - data/test/cases/attribute_set_test.rb +270 -0
 - data/test/cases/attribute_test.rb +246 -0
 - data/test/cases/attributes_test.rb +371 -0
 - data/test/cases/autosave_association_test.rb +1953 -0
 - data/test/cases/base_prevent_writes_test.rb +229 -0
 - data/test/cases/base_test.rb +1770 -0
 - data/test/cases/batches_test.rb +695 -0
 - data/test/cases/binary_test.rb +39 -0
 - data/test/cases/bind_parameter_test.rb +283 -0
 - data/test/cases/boolean_test.rb +52 -0
 - data/test/cases/cache_key_test.rb +131 -0
 - data/test/cases/calculations_test.rb +1361 -0
 - data/test/cases/callbacks_test.rb +503 -0
 - data/test/cases/clone_test.rb +45 -0
 - data/test/cases/coders/json_test.rb +17 -0
 - data/test/cases/coders/yaml_column_test.rb +66 -0
 - data/test/cases/collection_cache_key_test.rb +272 -0
 - data/test/cases/column_alias_test.rb +19 -0
 - data/test/cases/column_definition_test.rb +34 -0
 - data/test/cases/comment_test.rb +204 -0
 - data/test/cases/connection_adapters/adapter_leasing_test.rb +60 -0
 - data/test/cases/connection_adapters/connection_handler_test.rb +467 -0
 - data/test/cases/connection_adapters/connection_handlers_multi_db_test.rb +400 -0
 - data/test/cases/connection_adapters/connection_handlers_multi_pool_config_test.rb +103 -0
 - data/test/cases/connection_adapters/connection_handlers_sharding_db_test.rb +499 -0
 - data/test/cases/connection_adapters/connection_specification_test.rb +12 -0
 - data/test/cases/connection_adapters/connection_swapping_nested_test.rb +457 -0
 - data/test/cases/connection_adapters/legacy_connection_handlers_multi_db_test.rb +486 -0
 - data/test/cases/connection_adapters/legacy_connection_handlers_sharding_db_test.rb +586 -0
 - data/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +436 -0
 - data/test/cases/connection_adapters/mysql_type_lookup_test.rb +81 -0
 - data/test/cases/connection_adapters/quoting_test.rb +13 -0
 - data/test/cases/connection_adapters/schema_cache_test.rb +294 -0
 - data/test/cases/connection_adapters/type_lookup_test.rb +119 -0
 - data/test/cases/connection_management_test.rb +114 -0
 - data/test/cases/connection_pool_test.rb +754 -0
 - data/test/cases/connection_specification/resolver_test.rb +131 -0
 - data/test/cases/core_test.rb +136 -0
 - data/test/cases/counter_cache_test.rb +368 -0
 - data/test/cases/custom_locking_test.rb +19 -0
 - data/test/cases/database_configurations/hash_config_test.rb +74 -0
 - data/test/cases/database_configurations/resolver_test.rb +150 -0
 - data/test/cases/database_configurations_test.rb +145 -0
 - data/test/cases/database_selector_test.rb +296 -0
 - data/test/cases/database_statements_test.rb +36 -0
 - data/test/cases/date_test.rb +36 -0
 - data/test/cases/date_time_precision_test.rb +129 -0
 - data/test/cases/date_time_test.rb +76 -0
 - data/test/cases/defaults_test.rb +254 -0
 - data/test/cases/delegated_type_test.rb +57 -0
 - data/test/cases/dirty_test.rb +959 -0
 - data/test/cases/disconnected_test.rb +30 -0
 - data/test/cases/dup_test.rb +184 -0
 - data/test/cases/enum_test.rb +823 -0
 - data/test/cases/errors_test.rb +16 -0
 - data/test/cases/explain_subscriber_test.rb +66 -0
 - data/test/cases/explain_test.rb +79 -0
 - data/test/cases/filter_attributes_test.rb +153 -0
 - data/test/cases/finder_respond_to_test.rb +60 -0
 - data/test/cases/finder_test.rb +1676 -0
 - data/test/cases/fixture_set/file_test.rb +152 -0
 - data/test/cases/fixtures_test.rb +1645 -0
 - data/test/cases/forbidden_attributes_protection_test.rb +130 -0
 - data/test/cases/habtm_destroy_order_test.rb +61 -0
 - data/test/cases/helper.rb +233 -0
 - data/test/cases/hot_compatibility_test.rb +143 -0
 - data/test/cases/i18n_test.rb +46 -0
 - data/test/cases/inheritance_test.rb +671 -0
 - data/test/cases/insert_all_test.rb +489 -0
 - data/test/cases/instrumentation_test.rb +101 -0
 - data/test/cases/integration_test.rb +243 -0
 - data/test/cases/invalid_connection_test.rb +26 -0
 - data/test/cases/invertible_migration_test.rb +527 -0
 - data/test/cases/json_attribute_test.rb +35 -0
 - data/test/cases/json_serialization_test.rb +310 -0
 - data/test/cases/json_shared_test_cases.rb +290 -0
 - data/test/cases/locking_test.rb +787 -0
 - data/test/cases/log_subscriber_test.rb +267 -0
 - data/test/cases/marshal_serialization_test.rb +39 -0
 - data/test/cases/migration/change_schema_test.rb +504 -0
 - data/test/cases/migration/change_table_test.rb +364 -0
 - data/test/cases/migration/check_constraint_test.rb +162 -0
 - data/test/cases/migration/column_attributes_test.rb +186 -0
 - data/test/cases/migration/column_positioning_test.rb +68 -0
 - data/test/cases/migration/columns_test.rb +326 -0
 - data/test/cases/migration/command_recorder_test.rb +437 -0
 - data/test/cases/migration/compatibility_test.rb +673 -0
 - data/test/cases/migration/create_join_table_test.rb +167 -0
 - data/test/cases/migration/foreign_key_test.rb +581 -0
 - data/test/cases/migration/helper.rb +40 -0
 - data/test/cases/migration/index_test.rb +267 -0
 - data/test/cases/migration/logger_test.rb +39 -0
 - data/test/cases/migration/pending_migrations_test.rb +106 -0
 - data/test/cases/migration/references_foreign_key_test.rb +235 -0
 - data/test/cases/migration/references_index_test.rb +120 -0
 - data/test/cases/migration/references_statements_test.rb +137 -0
 - data/test/cases/migration/rename_table_test.rb +116 -0
 - data/test/cases/migration_test.rb +1525 -0
 - data/test/cases/migrator_test.rb +527 -0
 - data/test/cases/mixin_test.rb +64 -0
 - data/test/cases/modules_test.rb +174 -0
 - data/test/cases/multi_db_migrator_test.rb +223 -0
 - data/test/cases/multiparameter_attributes_test.rb +399 -0
 - data/test/cases/multiple_db_test.rb +116 -0
 - data/test/cases/nested_attributes_test.rb +1119 -0
 - data/test/cases/nested_attributes_with_callbacks_test.rb +146 -0
 - data/test/cases/null_relation_test.rb +84 -0
 - data/test/cases/numeric_data_test.rb +93 -0
 - data/test/cases/persistence_test.rb +1093 -0
 - data/test/cases/pooled_connections_test.rb +73 -0
 - data/test/cases/prepared_statement_status_test.rb +48 -0
 - data/test/cases/primary_keys_test.rb +482 -0
 - data/test/cases/query_cache_test.rb +915 -0
 - data/test/cases/quoting_test.rb +303 -0
 - data/test/cases/readonly_test.rb +120 -0
 - data/test/cases/reaper_test.rb +199 -0
 - data/test/cases/reflection_test.rb +520 -0
 - data/test/cases/relation/delegation_test.rb +76 -0
 - data/test/cases/relation/delete_all_test.rb +117 -0
 - data/test/cases/relation/merging_test.rb +434 -0
 - data/test/cases/relation/mutation_test.rb +145 -0
 - data/test/cases/relation/or_test.rb +192 -0
 - data/test/cases/relation/predicate_builder_test.rb +31 -0
 - data/test/cases/relation/record_fetch_warning_test.rb +42 -0
 - data/test/cases/relation/select_test.rb +67 -0
 - data/test/cases/relation/update_all_test.rb +317 -0
 - data/test/cases/relation/where_chain_test.rb +141 -0
 - data/test/cases/relation/where_clause_test.rb +257 -0
 - data/test/cases/relation/where_test.rb +429 -0
 - data/test/cases/relation_test.rb +482 -0
 - data/test/cases/relations_test.rb +2251 -0
 - data/test/cases/reload_models_test.rb +26 -0
 - data/test/cases/reserved_word_test.rb +141 -0
 - data/test/cases/result_test.rb +141 -0
 - data/test/cases/sanitize_test.rb +192 -0
 - data/test/cases/schema_dumper_test.rb +550 -0
 - data/test/cases/schema_loading_test.rb +53 -0
 - data/test/cases/scoping/default_scoping_test.rb +569 -0
 - data/test/cases/scoping/named_scoping_test.rb +649 -0
 - data/test/cases/scoping/relation_scoping_test.rb +522 -0
 - data/test/cases/secure_token_test.rb +47 -0
 - data/test/cases/serialization_test.rb +106 -0
 - data/test/cases/serialized_attribute_test.rb +455 -0
 - data/test/cases/signed_id_test.rb +168 -0
 - data/test/cases/statement_cache_test.rb +153 -0
 - data/test/cases/statement_invalid_test.rb +42 -0
 - data/test/cases/store_test.rb +320 -0
 - data/test/cases/strict_loading_test.rb +473 -0
 - data/test/cases/suppressor_test.rb +77 -0
 - data/test/cases/tasks/database_tasks_test.rb +1526 -0
 - data/test/cases/tasks/mysql_rake_test.rb +417 -0
 - data/test/cases/tasks/postgresql_rake_test.rb +534 -0
 - data/test/cases/tasks/sqlite_rake_test.rb +267 -0
 - data/test/cases/test_case.rb +142 -0
 - data/test/cases/test_databases_test.rb +79 -0
 - data/test/cases/test_fixtures_test.rb +96 -0
 - data/test/cases/time_precision_test.rb +125 -0
 - data/test/cases/timestamp_test.rb +504 -0
 - data/test/cases/touch_later_test.rb +123 -0
 - data/test/cases/transaction_callbacks_test.rb +772 -0
 - data/test/cases/transaction_isolation_test.rb +106 -0
 - data/test/cases/transactions_test.rb +1285 -0
 - data/test/cases/type/adapter_specific_registry_test.rb +145 -0
 - data/test/cases/type/date_time_test.rb +16 -0
 - data/test/cases/type/integer_test.rb +29 -0
 - data/test/cases/type/string_test.rb +24 -0
 - data/test/cases/type/time_test.rb +28 -0
 - data/test/cases/type/type_map_test.rb +178 -0
 - data/test/cases/type/unsigned_integer_test.rb +19 -0
 - data/test/cases/type_test.rb +41 -0
 - data/test/cases/types_test.rb +26 -0
 - data/test/cases/unconnected_test.rb +46 -0
 - data/test/cases/unsafe_raw_sql_test.rb +274 -0
 - data/test/cases/validations/absence_validation_test.rb +75 -0
 - data/test/cases/validations/association_validation_test.rb +99 -0
 - data/test/cases/validations/i18n_generate_message_validation_test.rb +102 -0
 - data/test/cases/validations/i18n_validation_test.rb +87 -0
 - data/test/cases/validations/length_validation_test.rb +80 -0
 - data/test/cases/validations/numericality_validation_test.rb +181 -0
 - data/test/cases/validations/presence_validation_test.rb +105 -0
 - data/test/cases/validations/uniqueness_validation_test.rb +618 -0
 - data/test/cases/validations_repair_helper.rb +21 -0
 - data/test/cases/validations_test.rb +229 -0
 - data/test/cases/view_test.rb +222 -0
 - data/test/cases/yaml_serialization_test.rb +166 -0
 - data/test/config.example.yml +97 -0
 - data/test/config.rb +7 -0
 - data/test/config.yml +220 -0
 - data/test/connections/native_ibm_db/connection.rb +44 -0
 - data/test/fixtures/accounts.yml +29 -0
 - data/test/fixtures/admin/accounts.yml +2 -0
 - data/test/fixtures/admin/randomly_named_a9.yml +7 -0
 - data/test/fixtures/admin/randomly_named_b0.yml +7 -0
 - data/test/fixtures/admin/users.yml +10 -0
 - data/test/fixtures/all/admin +1 -0
 - data/test/fixtures/all/developers.yml +0 -0
 - data/test/fixtures/all/namespaced/accounts.yml +2 -0
 - data/test/fixtures/all/people.yml +0 -0
 - data/test/fixtures/all/tasks.yml +0 -0
 - data/test/fixtures/author_addresses.yml +11 -0
 - data/test/fixtures/author_favorites.yml +4 -0
 - data/test/fixtures/authors.yml +17 -0
 - data/test/fixtures/bad_posts.yml +9 -0
 - data/test/fixtures/binaries.yml +137 -0
 - data/test/fixtures/books.yml +38 -0
 - data/test/fixtures/bulbs.yml +5 -0
 - data/test/fixtures/cars.yml +9 -0
 - data/test/fixtures/categories/special_categories.yml +9 -0
 - data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
 - data/test/fixtures/categories.yml +19 -0
 - data/test/fixtures/categories_ordered.yml +7 -0
 - data/test/fixtures/categories_posts.yml +34 -0
 - data/test/fixtures/categorizations.yml +23 -0
 - data/test/fixtures/citations.yml +5 -0
 - data/test/fixtures/clubs.yml +8 -0
 - data/test/fixtures/collections.yml +3 -0
 - data/test/fixtures/colleges.yml +3 -0
 - data/test/fixtures/comments.yml +72 -0
 - data/test/fixtures/companies.yml +72 -0
 - data/test/fixtures/computers.yml +12 -0
 - data/test/fixtures/content.yml +3 -0
 - data/test/fixtures/content_positions.yml +3 -0
 - data/test/fixtures/courses.yml +8 -0
 - data/test/fixtures/customers.yml +35 -0
 - data/test/fixtures/dashboards.yml +6 -0
 - data/test/fixtures/dead_parrots.yml +5 -0
 - data/test/fixtures/developers.yml +22 -0
 - data/test/fixtures/developers_projects.yml +17 -0
 - data/test/fixtures/dog_lovers.yml +7 -0
 - data/test/fixtures/dogs.yml +4 -0
 - data/test/fixtures/doubloons.yml +3 -0
 - data/test/fixtures/edges.yml +5 -0
 - data/test/fixtures/entrants.yml +14 -0
 - data/test/fixtures/essays.yml +16 -0
 - data/test/fixtures/faces.yml +11 -0
 - data/test/fixtures/fk_test_has_fk.yml +3 -0
 - data/test/fixtures/fk_test_has_pk.yml +2 -0
 - data/test/fixtures/friendships.yml +4 -0
 - data/test/fixtures/funny_jokes.yml +10 -0
 - data/test/fixtures/humans.yml +5 -0
 - data/test/fixtures/interests.yml +33 -0
 - data/test/fixtures/items.yml +3 -0
 - data/test/fixtures/jobs.yml +7 -0
 - data/test/fixtures/legacy_things.yml +3 -0
 - data/test/fixtures/live_parrots.yml +4 -0
 - data/test/fixtures/mateys.yml +4 -0
 - data/test/fixtures/member_details.yml +8 -0
 - data/test/fixtures/member_types.yml +6 -0
 - data/test/fixtures/members.yml +11 -0
 - data/test/fixtures/memberships.yml +41 -0
 - data/test/fixtures/men.yml +5 -0
 - data/test/fixtures/minimalistics.yml +5 -0
 - data/test/fixtures/minivans.yml +5 -0
 - data/test/fixtures/mixed_case_monkeys.yml +6 -0
 - data/test/fixtures/mixins.yml +29 -0
 - data/test/fixtures/movies.yml +7 -0
 - data/test/fixtures/naked/yml/accounts.yml +1 -0
 - data/test/fixtures/naked/yml/companies.yml +1 -0
 - data/test/fixtures/naked/yml/courses.yml +1 -0
 - data/test/fixtures/naked/yml/courses_with_invalid_key.yml +3 -0
 - data/test/fixtures/naked/yml/parrots.yml +3 -0
 - data/test/fixtures/naked/yml/trees.yml +3 -0
 - data/test/fixtures/nodes.yml +29 -0
 - data/test/fixtures/organizations.yml +5 -0
 - data/test/fixtures/other_books.yml +26 -0
 - data/test/fixtures/other_comments.yml +6 -0
 - data/test/fixtures/other_dogs.yml +2 -0
 - data/test/fixtures/other_posts.yml +8 -0
 - data/test/fixtures/other_topics.yml +42 -0
 - data/test/fixtures/owners.yml +9 -0
 - data/test/fixtures/parrots.yml +33 -0
 - data/test/fixtures/parrots_pirates.yml +7 -0
 - data/test/fixtures/people.yml +24 -0
 - data/test/fixtures/peoples_treasures.yml +3 -0
 - data/test/fixtures/pets.yml +19 -0
 - data/test/fixtures/pirates.yml +15 -0
 - data/test/fixtures/posts.yml +88 -0
 - data/test/fixtures/price_estimates.yml +16 -0
 - data/test/fixtures/products.yml +4 -0
 - data/test/fixtures/projects.yml +7 -0
 - data/test/fixtures/randomly_named_a9.yml +7 -0
 - data/test/fixtures/ratings.yml +14 -0
 - data/test/fixtures/readers.yml +17 -0
 - data/test/fixtures/references.yml +17 -0
 - data/test/fixtures/reserved_words/distinct.yml +5 -0
 - data/test/fixtures/reserved_words/distinct_select.yml +11 -0
 - data/test/fixtures/reserved_words/group.yml +14 -0
 - data/test/fixtures/reserved_words/select.yml +8 -0
 - data/test/fixtures/reserved_words/values.yml +7 -0
 - data/test/fixtures/ships.yml +6 -0
 - data/test/fixtures/speedometers.yml +8 -0
 - data/test/fixtures/sponsors.yml +15 -0
 - data/test/fixtures/strict_zines.yml +2 -0
 - data/test/fixtures/string_key_objects.yml +7 -0
 - data/test/fixtures/subscribers.yml +11 -0
 - data/test/fixtures/subscriptions.yml +12 -0
 - data/test/fixtures/taggings.yml +78 -0
 - data/test/fixtures/tags.yml +11 -0
 - data/test/fixtures/tasks.yml +7 -0
 - data/test/fixtures/teapots.yml +3 -0
 - data/test/fixtures/to_be_linked/accounts.yml +2 -0
 - data/test/fixtures/to_be_linked/users.yml +10 -0
 - data/test/fixtures/topics.yml +49 -0
 - data/test/fixtures/toys.yml +14 -0
 - data/test/fixtures/traffic_lights.yml +10 -0
 - data/test/fixtures/treasures.yml +10 -0
 - data/test/fixtures/trees.yml +3 -0
 - data/test/fixtures/uuid_children.yml +3 -0
 - data/test/fixtures/uuid_parents.yml +2 -0
 - data/test/fixtures/variants.yml +4 -0
 - data/test/fixtures/vegetables.yml +20 -0
 - data/test/fixtures/vertices.yml +4 -0
 - data/test/fixtures/warehouse-things.yml +3 -0
 - data/test/fixtures/warehouse_things.yml +3 -0
 - data/test/fixtures/zines.yml +5 -0
 - data/test/ibm_db_test.rb +25 -0
 - data/test/migrations/10_urban/9_add_expressions.rb +13 -0
 - data/test/migrations/decimal/1_give_me_big_numbers.rb +17 -0
 - data/test/migrations/magic/1_currencies_have_symbols.rb +13 -0
 - data/test/migrations/missing/1000_people_have_middle_names.rb +11 -0
 - data/test/migrations/missing/1_people_have_last_names.rb +11 -0
 - data/test/migrations/missing/3_we_need_reminders.rb +14 -0
 - data/test/migrations/missing/4_innocent_jointable.rb +14 -0
 - data/test/migrations/rename/1_we_need_things.rb +13 -0
 - data/test/migrations/rename/2_rename_things.rb +11 -0
 - data/test/migrations/to_copy/1_people_have_hobbies.rb +11 -0
 - data/test/migrations/to_copy/2_people_have_descriptions.rb +11 -0
 - data/test/migrations/to_copy2/1_create_articles.rb +9 -0
 - data/test/migrations/to_copy2/2_create_comments.rb +9 -0
 - data/test/migrations/to_copy_with_name_collision/1_people_have_hobbies.rb +11 -0
 - data/test/migrations/to_copy_with_timestamps/20090101010101_people_have_hobbies.rb +11 -0
 - data/test/migrations/to_copy_with_timestamps/20090101010202_people_have_descriptions.rb +11 -0
 - data/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb +9 -0
 - data/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb +9 -0
 - data/test/migrations/valid/1_valid_people_have_last_names.rb +11 -0
 - data/test/migrations/valid/2_we_need_reminders.rb +14 -0
 - data/test/migrations/valid/3_innocent_jointable.rb +14 -0
 - data/test/migrations/valid_with_subdirectories/1_valid_people_have_last_names.rb +11 -0
 - data/test/migrations/valid_with_subdirectories/sub/2_we_need_reminders.rb +14 -0
 - data/test/migrations/valid_with_subdirectories/sub1/3_innocent_jointable.rb +14 -0
 - data/test/migrations/valid_with_timestamps/20100101010101_valid_with_timestamps_people_have_last_names.rb +11 -0
 - data/test/migrations/valid_with_timestamps/20100201010101_valid_with_timestamps_we_need_reminders.rb +14 -0
 - data/test/migrations/valid_with_timestamps/20100301010101_valid_with_timestamps_innocent_jointable.rb +14 -0
 - data/test/migrations/version_check/20131219224947_migration_version_check.rb +10 -0
 - data/test/models/account.rb +46 -0
 - data/test/models/admin/account.rb +5 -0
 - data/test/models/admin/randomly_named_c1.rb +9 -0
 - data/test/models/admin/user.rb +48 -0
 - data/test/models/admin.rb +7 -0
 - data/test/models/aircraft.rb +7 -0
 - data/test/models/arunit2_model.rb +5 -0
 - data/test/models/author.rb +260 -0
 - data/test/models/auto_id.rb +6 -0
 - data/test/models/autoloadable/extra_firm.rb +4 -0
 - data/test/models/binary.rb +4 -0
 - data/test/models/binary_field.rb +6 -0
 - data/test/models/bird.rb +24 -0
 - data/test/models/book.rb +33 -0
 - data/test/models/book_destroy_async.rb +24 -0
 - data/test/models/boolean.rb +7 -0
 - data/test/models/bulb.rb +61 -0
 - data/test/models/cake_designer.rb +5 -0
 - data/test/models/car.rb +36 -0
 - data/test/models/carrier.rb +4 -0
 - data/test/models/cart.rb +5 -0
 - data/test/models/cat.rb +12 -0
 - data/test/models/categorization.rb +21 -0
 - data/test/models/category.rb +47 -0
 - data/test/models/chef.rb +10 -0
 - data/test/models/citation.rb +7 -0
 - data/test/models/club.rb +28 -0
 - data/test/models/college.rb +12 -0
 - data/test/models/column.rb +5 -0
 - data/test/models/column_name.rb +5 -0
 - data/test/models/comment.rb +98 -0
 - data/test/models/company.rb +226 -0
 - data/test/models/company_in_module.rb +99 -0
 - data/test/models/computer.rb +5 -0
 - data/test/models/contact.rb +43 -0
 - data/test/models/content.rb +42 -0
 - data/test/models/contract.rb +38 -0
 - data/test/models/country.rb +5 -0
 - data/test/models/course.rb +8 -0
 - data/test/models/customer.rb +85 -0
 - data/test/models/customer_carrier.rb +16 -0
 - data/test/models/dashboard.rb +5 -0
 - data/test/models/default.rb +4 -0
 - data/test/models/department.rb +6 -0
 - data/test/models/destroy_async_parent.rb +15 -0
 - data/test/models/destroy_async_parent_soft_delete.rb +20 -0
 - data/test/models/developer.rb +341 -0
 - data/test/models/dl_keyed_belongs_to.rb +13 -0
 - data/test/models/dl_keyed_belongs_to_soft_delete.rb +19 -0
 - data/test/models/dl_keyed_has_many.rb +5 -0
 - data/test/models/dl_keyed_has_many_through.rb +5 -0
 - data/test/models/dl_keyed_has_one.rb +5 -0
 - data/test/models/dl_keyed_join.rb +10 -0
 - data/test/models/dog.rb +7 -0
 - data/test/models/dog_lover.rb +7 -0
 - data/test/models/doubloon.rb +14 -0
 - data/test/models/drink_designer.rb +20 -0
 - data/test/models/edge.rb +7 -0
 - data/test/models/electron.rb +7 -0
 - data/test/models/engine.rb +5 -0
 - data/test/models/entrant.rb +5 -0
 - data/test/models/entry.rb +5 -0
 - data/test/models/essay.rb +8 -0
 - data/test/models/essay_destroy_async.rb +12 -0
 - data/test/models/event.rb +5 -0
 - data/test/models/eye.rb +39 -0
 - data/test/models/face.rb +17 -0
 - data/test/models/family.rb +6 -0
 - data/test/models/family_tree.rb +6 -0
 - data/test/models/friendship.rb +8 -0
 - data/test/models/frog.rb +8 -0
 - data/test/models/guid.rb +4 -0
 - data/test/models/guitar.rb +6 -0
 - data/test/models/hotel.rb +13 -0
 - data/test/models/human.rb +39 -0
 - data/test/models/image.rb +5 -0
 - data/test/models/interest.rb +16 -0
 - data/test/models/invoice.rb +6 -0
 - data/test/models/item.rb +9 -0
 - data/test/models/job.rb +9 -0
 - data/test/models/joke.rb +9 -0
 - data/test/models/keyboard.rb +5 -0
 - data/test/models/legacy_thing.rb +5 -0
 - data/test/models/lesson.rb +13 -0
 - data/test/models/line_item.rb +5 -0
 - data/test/models/liquid.rb +6 -0
 - data/test/models/man.rb +11 -0
 - data/test/models/matey.rb +6 -0
 - data/test/models/measurement.rb +4 -0
 - data/test/models/member.rb +45 -0
 - data/test/models/member_detail.rb +11 -0
 - data/test/models/member_type.rb +5 -0
 - data/test/models/membership.rb +38 -0
 - data/test/models/mentor.rb +5 -0
 - data/test/models/message.rb +5 -0
 - data/test/models/minimalistic.rb +4 -0
 - data/test/models/minivan.rb +10 -0
 - data/test/models/mixed_case_monkey.rb +5 -0
 - data/test/models/mocktail_designer.rb +2 -0
 - data/test/models/molecule.rb +8 -0
 - data/test/models/mouse.rb +6 -0
 - data/test/models/movie.rb +7 -0
 - data/test/models/node.rb +7 -0
 - data/test/models/non_primary_key.rb +4 -0
 - data/test/models/notification.rb +5 -0
 - data/test/models/numeric_data.rb +12 -0
 - data/test/models/order.rb +6 -0
 - data/test/models/organization.rb +16 -0
 - data/test/models/other_dog.rb +7 -0
 - data/test/models/owner.rb +39 -0
 - data/test/models/parrot.rb +36 -0
 - data/test/models/person.rb +147 -0
 - data/test/models/personal_legacy_thing.rb +6 -0
 - data/test/models/pet.rb +20 -0
 - data/test/models/pet_treasure.rb +8 -0
 - data/test/models/pirate.rb +116 -0
 - data/test/models/possession.rb +5 -0
 - data/test/models/post.rb +371 -0
 - data/test/models/price_estimate.rb +14 -0
 - data/test/models/professor.rb +7 -0
 - data/test/models/project.rb +42 -0
 - data/test/models/publisher/article.rb +6 -0
 - data/test/models/publisher/magazine.rb +5 -0
 - data/test/models/publisher.rb +4 -0
 - data/test/models/randomly_named_c1.rb +5 -0
 - data/test/models/rating.rb +8 -0
 - data/test/models/reader.rb +25 -0
 - data/test/models/recipe.rb +5 -0
 - data/test/models/record.rb +4 -0
 - data/test/models/reference.rb +25 -0
 - data/test/models/reply.rb +79 -0
 - data/test/models/room.rb +6 -0
 - data/test/models/section.rb +6 -0
 - data/test/models/seminar.rb +6 -0
 - data/test/models/session.rb +6 -0
 - data/test/models/ship.rb +42 -0
 - data/test/models/ship_part.rb +10 -0
 - data/test/models/shop.rb +19 -0
 - data/test/models/shop_account.rb +8 -0
 - data/test/models/speedometer.rb +8 -0
 - data/test/models/sponsor.rb +10 -0
 - data/test/models/squeak.rb +6 -0
 - data/test/models/strict_zine.rb +7 -0
 - data/test/models/string_key_object.rb +5 -0
 - data/test/models/student.rb +6 -0
 - data/test/models/subject.rb +16 -0
 - data/test/models/subscriber.rb +10 -0
 - data/test/models/subscription.rb +8 -0
 - data/test/models/tag.rb +16 -0
 - data/test/models/tagging.rb +20 -0
 - data/test/models/task.rb +7 -0
 - data/test/models/topic.rb +153 -0
 - data/test/models/toy.rb +10 -0
 - data/test/models/traffic_light.rb +6 -0
 - data/test/models/treasure.rb +16 -0
 - data/test/models/treaty.rb +5 -0
 - data/test/models/tree.rb +5 -0
 - data/test/models/tuning_peg.rb +6 -0
 - data/test/models/tyre.rb +13 -0
 - data/test/models/user.rb +22 -0
 - data/test/models/uuid_child.rb +5 -0
 - data/test/models/uuid_item.rb +8 -0
 - data/test/models/uuid_parent.rb +5 -0
 - data/test/models/vegetables.rb +33 -0
 - data/test/models/vehicle.rb +7 -0
 - data/test/models/vertex.rb +11 -0
 - data/test/models/warehouse_thing.rb +7 -0
 - data/test/models/wheel.rb +5 -0
 - data/test/models/without_table.rb +5 -0
 - data/test/models/zine.rb +5 -0
 - data/test/schema/i5/ibm_db_specific_schema.rb +137 -0
 - data/test/schema/ids/ibm_db_specific_schema.rb +140 -0
 - data/test/schema/luw/ibm_db_specific_schema.rb +137 -0
 - data/test/schema/mysql2_specific_schema.rb +82 -0
 - data/test/schema/oracle_specific_schema.rb +38 -0
 - data/test/schema/postgresql_specific_schema.rb +125 -0
 - data/test/schema/schema.rb +1237 -0
 - data/test/schema/schema.rb.original +1057 -0
 - data/test/schema/sqlite_specific_schema.rb +11 -0
 - data/test/schema/zOS/ibm_db_specific_schema.rb +208 -0
 - data/test/support/config.rb +43 -0
 - data/test/support/connection.rb +29 -0
 - data/test/support/connection_helper.rb +16 -0
 - data/test/support/ddl_helper.rb +10 -0
 - data/test/support/marshal_compatibility_fixtures/IBM_DB/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/IBM_DB/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/Mysql2/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/Mysql2/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/PostgreSQL/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/PostgreSQL/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/SQLite/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/SQLite/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/legacy_6_0_record_mysql.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/legacy_relation.dump +0 -0
 - data/test/support/schema_dumping_helper.rb +22 -0
 - data/test/support/stubs/strong_parameters.rb +40 -0
 - data/test/support/yaml_compatibility_fixtures/rails_4_1.yml +22 -0
 - data/test/support/yaml_compatibility_fixtures/rails_4_2_0.yml +182 -0
 - data/test/support/yaml_compatibility_fixtures/rails_v1_mysql.yml +206 -0
 - data/test/support/yaml_compatibility_fixtures/rails_v2.yml +55 -0
 - metadata +876 -0
 
| 
         @@ -0,0 +1,1645 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "cases/helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "support/connection_helper"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "models/admin"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "models/admin/account"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "models/admin/randomly_named_c1"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "models/admin/user"
         
     | 
| 
      
 9 
     | 
    
         
            +
            require "models/binary"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require "models/book"
         
     | 
| 
      
 11 
     | 
    
         
            +
            require "models/bulb"
         
     | 
| 
      
 12 
     | 
    
         
            +
            require "models/category"
         
     | 
| 
      
 13 
     | 
    
         
            +
            require "models/post"
         
     | 
| 
      
 14 
     | 
    
         
            +
            require "models/comment"
         
     | 
| 
      
 15 
     | 
    
         
            +
            require "models/company"
         
     | 
| 
      
 16 
     | 
    
         
            +
            require "models/computer"
         
     | 
| 
      
 17 
     | 
    
         
            +
            require "models/course"
         
     | 
| 
      
 18 
     | 
    
         
            +
            require "models/developer"
         
     | 
| 
      
 19 
     | 
    
         
            +
            require "models/dog"
         
     | 
| 
      
 20 
     | 
    
         
            +
            require "models/doubloon"
         
     | 
| 
      
 21 
     | 
    
         
            +
            require "models/joke"
         
     | 
| 
      
 22 
     | 
    
         
            +
            require "models/matey"
         
     | 
| 
      
 23 
     | 
    
         
            +
            require "models/other_dog"
         
     | 
| 
      
 24 
     | 
    
         
            +
            require "models/parrot"
         
     | 
| 
      
 25 
     | 
    
         
            +
            require "models/pirate"
         
     | 
| 
      
 26 
     | 
    
         
            +
            require "models/randomly_named_c1"
         
     | 
| 
      
 27 
     | 
    
         
            +
            require "models/reply"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require "models/ship"
         
     | 
| 
      
 29 
     | 
    
         
            +
            require "models/task"
         
     | 
| 
      
 30 
     | 
    
         
            +
            require "models/topic"
         
     | 
| 
      
 31 
     | 
    
         
            +
            require "models/traffic_light"
         
     | 
| 
      
 32 
     | 
    
         
            +
            require "models/treasure"
         
     | 
| 
      
 33 
     | 
    
         
            +
            require "tempfile"
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            class FixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 36 
     | 
    
         
            +
              include ConnectionHelper
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              self.use_instantiated_fixtures = true
         
     | 
| 
      
 39 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              # other_topics fixture should not be included here
         
     | 
| 
      
 42 
     | 
    
         
            +
              fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries, :traffic_lights, :treasures
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              FIXTURES = %w( accounts binaries companies customers
         
     | 
| 
      
 45 
     | 
    
         
            +
                             developers developers_projects entrants
         
     | 
| 
      
 46 
     | 
    
         
            +
                             movies projects subscribers topics tasks )
         
     | 
| 
      
 47 
     | 
    
         
            +
              MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-\w]*/
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 50 
     | 
    
         
            +
                Arel::Table.engine = nil # should not rely on the global Arel::Table.engine
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 54 
     | 
    
         
            +
                Arel::Table.engine = ActiveRecord::Base
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              def test_clean_fixtures
         
     | 
| 
      
 58 
     | 
    
         
            +
                FIXTURES.each do |name|
         
     | 
| 
      
 59 
     | 
    
         
            +
                  fixtures = nil
         
     | 
| 
      
 60 
     | 
    
         
            +
                  assert_nothing_raised { fixtures = create_fixtures(name).first }
         
     | 
| 
      
 61 
     | 
    
         
            +
                  assert_kind_of(ActiveRecord::FixtureSet, fixtures)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  fixtures.each { |_name, fixture|
         
     | 
| 
      
 63 
     | 
    
         
            +
                    fixture.each { |key, value|
         
     | 
| 
      
 64 
     | 
    
         
            +
                      assert_match(MATCH_ATTRIBUTE_NAME, key)
         
     | 
| 
      
 65 
     | 
    
         
            +
                    }
         
     | 
| 
      
 66 
     | 
    
         
            +
                  }
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
              class InsertQuerySubscriber
         
     | 
| 
      
 71 
     | 
    
         
            +
                attr_reader :events
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 74 
     | 
    
         
            +
                  @events = []
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                def call(_, _, _, _, values)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  @events << values[:sql] if /INSERT/.match?(values[:sql])
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
              if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter)
         
     | 
| 
      
 83 
     | 
    
         
            +
                def test_bulk_insert
         
     | 
| 
      
 84 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 85 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  create_fixtures("bulbs")
         
     | 
| 
      
 87 
     | 
    
         
            +
                  assert_equal 1, subscriber.events.size, "It takes one INSERT query to insert two fixtures"
         
     | 
| 
      
 88 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 89 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                def test_bulk_insert_multiple_table_with_a_multi_statement_query
         
     | 
| 
      
 93 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 94 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  create_fixtures("bulbs", "authors", "computers")
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                  expected_sql = <<~EOS.chop
         
     | 
| 
      
 99 
     | 
    
         
            +
                    INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("bulbs")} .*
         
     | 
| 
      
 100 
     | 
    
         
            +
                    INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("authors")} .*
         
     | 
| 
      
 101 
     | 
    
         
            +
                    INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("computers")} .*
         
     | 
| 
      
 102 
     | 
    
         
            +
                  EOS
         
     | 
| 
      
 103 
     | 
    
         
            +
                  assert_equal 1, subscriber.events.size
         
     | 
| 
      
 104 
     | 
    
         
            +
                  assert_match(/#{expected_sql}/, subscriber.events.first)
         
     | 
| 
      
 105 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 106 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                def test_bulk_insert_with_a_multi_statement_query_raises_an_exception_when_any_insert_fails
         
     | 
| 
      
 110 
     | 
    
         
            +
                  require "models/aircraft"
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                  assert_equal false, Aircraft.columns_hash["wheels_count"].null
         
     | 
| 
      
 113 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 114 
     | 
    
         
            +
                    "aircraft" => [
         
     | 
| 
      
 115 
     | 
    
         
            +
                      { "name" => "working_aircrafts", "wheels_count" => 2 },
         
     | 
| 
      
 116 
     | 
    
         
            +
                      { "name" => "broken_aircrafts", "wheels_count" => nil },
         
     | 
| 
      
 117 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 118 
     | 
    
         
            +
                  }
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                  assert_no_difference "Aircraft.count" do
         
     | 
| 
      
 121 
     | 
    
         
            +
                    assert_raises(ActiveRecord::NotNullViolation) do
         
     | 
| 
      
 122 
     | 
    
         
            +
                      ActiveRecord::Base.connection.insert_fixtures_set(fixtures)
         
     | 
| 
      
 123 
     | 
    
         
            +
                    end
         
     | 
| 
      
 124 
     | 
    
         
            +
                  end
         
     | 
| 
      
 125 
     | 
    
         
            +
                end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                def test_bulk_insert_with_a_multi_statement_query_in_a_nested_transaction
         
     | 
| 
      
 128 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 129 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 130 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a"] },
         
     | 
| 
      
 131 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 132 
     | 
    
         
            +
                  }
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                  assert_difference "TrafficLight.count" do
         
     | 
| 
      
 135 
     | 
    
         
            +
                    ActiveRecord::Base.transaction do
         
     | 
| 
      
 136 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 137 
     | 
    
         
            +
                      assert_equal 1, conn.open_transactions
         
     | 
| 
      
 138 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 139 
     | 
    
         
            +
                      assert_equal 1, conn.open_transactions
         
     | 
| 
      
 140 
     | 
    
         
            +
                    end
         
     | 
| 
      
 141 
     | 
    
         
            +
                  end
         
     | 
| 
      
 142 
     | 
    
         
            +
                end
         
     | 
| 
      
 143 
     | 
    
         
            +
              end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
              if current_adapter?(:Mysql2Adapter)
         
     | 
| 
      
 146 
     | 
    
         
            +
                def test_bulk_insert_with_multi_statements_enabled
         
     | 
| 
      
 147 
     | 
    
         
            +
                  run_without_connection do |orig_connection|
         
     | 
| 
      
 148 
     | 
    
         
            +
                    ActiveRecord::Base.establish_connection(
         
     | 
| 
      
 149 
     | 
    
         
            +
                      orig_connection.merge(flags: %w[MULTI_STATEMENTS])
         
     | 
| 
      
 150 
     | 
    
         
            +
                    )
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                    fixtures = {
         
     | 
| 
      
 153 
     | 
    
         
            +
                      "traffic_lights" => [
         
     | 
| 
      
 154 
     | 
    
         
            +
                        { "location" => "US", "state" => ["NY"], "long_state" => ["a"] },
         
     | 
| 
      
 155 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 156 
     | 
    
         
            +
                    }
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 159 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 160 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 161 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 162 
     | 
    
         
            +
                    end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
                    assert_difference "TrafficLight.count" do
         
     | 
| 
      
 165 
     | 
    
         
            +
                      ActiveRecord::Base.transaction do
         
     | 
| 
      
 166 
     | 
    
         
            +
                        conn = ActiveRecord::Base.connection
         
     | 
| 
      
 167 
     | 
    
         
            +
                        assert_equal 1, conn.open_transactions
         
     | 
| 
      
 168 
     | 
    
         
            +
                        conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 169 
     | 
    
         
            +
                        assert_equal 1, conn.open_transactions
         
     | 
| 
      
 170 
     | 
    
         
            +
                      end
         
     | 
| 
      
 171 
     | 
    
         
            +
                    end
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 174 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 175 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 176 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 177 
     | 
    
         
            +
                    end
         
     | 
| 
      
 178 
     | 
    
         
            +
                  end
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                def test_bulk_insert_with_multi_statements_disabled
         
     | 
| 
      
 182 
     | 
    
         
            +
                  run_without_connection do |orig_connection|
         
     | 
| 
      
 183 
     | 
    
         
            +
                    ActiveRecord::Base.establish_connection(
         
     | 
| 
      
 184 
     | 
    
         
            +
                      orig_connection.merge(flags: [])
         
     | 
| 
      
 185 
     | 
    
         
            +
                    )
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                    fixtures = {
         
     | 
| 
      
 188 
     | 
    
         
            +
                      "traffic_lights" => [
         
     | 
| 
      
 189 
     | 
    
         
            +
                        { "location" => "US", "state" => ["NY"], "long_state" => ["a"] },
         
     | 
| 
      
 190 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 191 
     | 
    
         
            +
                    }
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                    assert_raises(ActiveRecord::StatementInvalid) do
         
     | 
| 
      
 194 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 195 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 196 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 197 
     | 
    
         
            +
                    end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                    assert_difference "TrafficLight.count" do
         
     | 
| 
      
 200 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 201 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 202 
     | 
    
         
            +
                    end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
                    assert_raises(ActiveRecord::StatementInvalid) do
         
     | 
| 
      
 205 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 206 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 207 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 208 
     | 
    
         
            +
                    end
         
     | 
| 
      
 209 
     | 
    
         
            +
                  end
         
     | 
| 
      
 210 
     | 
    
         
            +
                end
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                def test_insert_fixtures_set_raises_an_error_when_max_allowed_packet_is_smaller_than_fixtures_set_size
         
     | 
| 
      
 213 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 214 
     | 
    
         
            +
                  mysql_margin = 2
         
     | 
| 
      
 215 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 216 
     | 
    
         
            +
                  bytes_needed_to_have_a_1024_bytes_fixture = 906
         
     | 
| 
      
 217 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 218 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 219 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * bytes_needed_to_have_a_1024_bytes_fixture] },
         
     | 
| 
      
 220 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 221 
     | 
    
         
            +
                  }
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size - mysql_margin) do
         
     | 
| 
      
 224 
     | 
    
         
            +
                    error = assert_raises(ActiveRecord::ActiveRecordError) { conn.insert_fixtures_set(fixtures) }
         
     | 
| 
      
 225 
     | 
    
         
            +
                    assert_match(/Fixtures set is too large #{packet_size}\./, error.message)
         
     | 
| 
      
 226 
     | 
    
         
            +
                  end
         
     | 
| 
      
 227 
     | 
    
         
            +
                end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                def test_insert_fixture_set_when_max_allowed_packet_is_bigger_than_fixtures_set_size
         
     | 
| 
      
 230 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 231 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 232 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 233 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 234 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * 51] },
         
     | 
| 
      
 235 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 236 
     | 
    
         
            +
                  }
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size) do
         
     | 
| 
      
 239 
     | 
    
         
            +
                    assert_difference "TrafficLight.count" do
         
     | 
| 
      
 240 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 241 
     | 
    
         
            +
                    end
         
     | 
| 
      
 242 
     | 
    
         
            +
                  end
         
     | 
| 
      
 243 
     | 
    
         
            +
                end
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                def test_insert_fixtures_set_split_the_total_sql_into_two_chunks_smaller_than_max_allowed_packet
         
     | 
| 
      
 246 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 247 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 248 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 249 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 250 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 251 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 252 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * 450] },
         
     | 
| 
      
 253 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 254 
     | 
    
         
            +
                    "comments" => [
         
     | 
| 
      
 255 
     | 
    
         
            +
                      { "post_id" => 1, "body" => "a" * 450 },
         
     | 
| 
      
 256 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 257 
     | 
    
         
            +
                  }
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size) do
         
     | 
| 
      
 260 
     | 
    
         
            +
                    conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                    assert_equal 2, subscriber.events.size
         
     | 
| 
      
 263 
     | 
    
         
            +
                    assert_operator subscriber.events.first.bytesize, :<, packet_size
         
     | 
| 
      
 264 
     | 
    
         
            +
                    assert_operator subscriber.events.second.bytesize, :<, packet_size
         
     | 
| 
      
 265 
     | 
    
         
            +
                  end
         
     | 
| 
      
 266 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 267 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 268 
     | 
    
         
            +
                end
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
                def test_insert_fixtures_set_concat_total_sql_into_a_single_packet_smaller_than_max_allowed_packet
         
     | 
| 
      
 271 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 272 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 273 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 274 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 275 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 276 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 277 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * 200] },
         
     | 
| 
      
 278 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 279 
     | 
    
         
            +
                    "comments" => [
         
     | 
| 
      
 280 
     | 
    
         
            +
                      { "post_id" => 1, "body" => "a" * 200 },
         
     | 
| 
      
 281 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 282 
     | 
    
         
            +
                  }
         
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
      
 284 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size) do
         
     | 
| 
      
 285 
     | 
    
         
            +
                    assert_difference ["TrafficLight.count", "Comment.count"], +1 do
         
     | 
| 
      
 286 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 287 
     | 
    
         
            +
                    end
         
     | 
| 
      
 288 
     | 
    
         
            +
                  end
         
     | 
| 
      
 289 
     | 
    
         
            +
                  assert_equal 1, subscriber.events.size
         
     | 
| 
      
 290 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 291 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 292 
     | 
    
         
            +
                end
         
     | 
| 
      
 293 
     | 
    
         
            +
              end
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
              def test_auto_value_on_primary_key
         
     | 
| 
      
 296 
     | 
    
         
            +
                fixtures = [
         
     | 
| 
      
 297 
     | 
    
         
            +
                  { "name" => "first", "wheels_count" => 2 },
         
     | 
| 
      
 298 
     | 
    
         
            +
                  { "name" => "second", "wheels_count" => 3 }
         
     | 
| 
      
 299 
     | 
    
         
            +
                ]
         
     | 
| 
      
 300 
     | 
    
         
            +
                conn = ActiveRecord::Base.connection
         
     | 
| 
      
 301 
     | 
    
         
            +
                assert_nothing_raised do
         
     | 
| 
      
 302 
     | 
    
         
            +
                  conn.insert_fixtures_set({ "aircraft" => fixtures }, ["aircraft"])
         
     | 
| 
      
 303 
     | 
    
         
            +
                end
         
     | 
| 
      
 304 
     | 
    
         
            +
                result = conn.select_all("SELECT name, wheels_count FROM aircraft ORDER BY id")
         
     | 
| 
      
 305 
     | 
    
         
            +
                assert_equal fixtures, result.to_a
         
     | 
| 
      
 306 
     | 
    
         
            +
              end
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
      
 308 
     | 
    
         
            +
              def test_broken_yaml_exception
         
     | 
| 
      
 309 
     | 
    
         
            +
                badyaml = Tempfile.new ["foo", ".yml"]
         
     | 
| 
      
 310 
     | 
    
         
            +
                badyaml.write "a: : "
         
     | 
| 
      
 311 
     | 
    
         
            +
                badyaml.flush
         
     | 
| 
      
 312 
     | 
    
         
            +
             
     | 
| 
      
 313 
     | 
    
         
            +
                dir  = File.dirname badyaml.path
         
     | 
| 
      
 314 
     | 
    
         
            +
                name = File.basename badyaml.path, ".yml"
         
     | 
| 
      
 315 
     | 
    
         
            +
                assert_raises(ActiveRecord::Fixture::FormatError) do
         
     | 
| 
      
 316 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.create_fixtures(dir, name)
         
     | 
| 
      
 317 
     | 
    
         
            +
                end
         
     | 
| 
      
 318 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 319 
     | 
    
         
            +
                badyaml.close
         
     | 
| 
      
 320 
     | 
    
         
            +
                badyaml.unlink
         
     | 
| 
      
 321 
     | 
    
         
            +
              end
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
              def test_create_fixtures
         
     | 
| 
      
 324 
     | 
    
         
            +
                fixtures = ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT, "parrots")
         
     | 
| 
      
 325 
     | 
    
         
            +
                assert Parrot.find_by_name("Curious George"), "George is not in the database"
         
     | 
| 
      
 326 
     | 
    
         
            +
                assert fixtures.detect { |f| f.name == "parrots" }, "no fixtures named 'parrots' in #{fixtures.map(&:name).inspect}"
         
     | 
| 
      
 327 
     | 
    
         
            +
              end
         
     | 
| 
      
 328 
     | 
    
         
            +
             
     | 
| 
      
 329 
     | 
    
         
            +
              def test_multiple_clean_fixtures
         
     | 
| 
      
 330 
     | 
    
         
            +
                fixtures_array = nil
         
     | 
| 
      
 331 
     | 
    
         
            +
                assert_nothing_raised { fixtures_array = create_fixtures(*FIXTURES) }
         
     | 
| 
      
 332 
     | 
    
         
            +
                assert_kind_of(Array, fixtures_array)
         
     | 
| 
      
 333 
     | 
    
         
            +
                fixtures_array.each { |fixtures| assert_kind_of(ActiveRecord::FixtureSet, fixtures) }
         
     | 
| 
      
 334 
     | 
    
         
            +
              end
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
              def test_create_symbol_fixtures
         
     | 
| 
      
 337 
     | 
    
         
            +
                fixtures = ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT, :collections, collections: Course) { Course.connection }
         
     | 
| 
      
 338 
     | 
    
         
            +
             
     | 
| 
      
 339 
     | 
    
         
            +
                assert Course.find_by_name("Collection"), "course is not in the database"
         
     | 
| 
      
 340 
     | 
    
         
            +
                assert fixtures.detect { |f| f.name == "collections" }, "no fixtures named 'collections' in #{fixtures.map(&:name).inspect}"
         
     | 
| 
      
 341 
     | 
    
         
            +
              end
         
     | 
| 
      
 342 
     | 
    
         
            +
             
     | 
| 
      
 343 
     | 
    
         
            +
              def test_attributes
         
     | 
| 
      
 344 
     | 
    
         
            +
                topics = create_fixtures("topics").first
         
     | 
| 
      
 345 
     | 
    
         
            +
                assert_equal("The First Topic", topics["first"]["title"])
         
     | 
| 
      
 346 
     | 
    
         
            +
                assert_nil(topics["second"]["author_email_address"])
         
     | 
| 
      
 347 
     | 
    
         
            +
              end
         
     | 
| 
      
 348 
     | 
    
         
            +
             
     | 
| 
      
 349 
     | 
    
         
            +
              def test_no_args_returns_all
         
     | 
| 
      
 350 
     | 
    
         
            +
                all_topics = topics
         
     | 
| 
      
 351 
     | 
    
         
            +
                assert_equal 5, all_topics.length
         
     | 
| 
      
 352 
     | 
    
         
            +
                assert_equal "The First Topic", all_topics.first["title"]
         
     | 
| 
      
 353 
     | 
    
         
            +
                assert_equal 5, all_topics.last.id
         
     | 
| 
      
 354 
     | 
    
         
            +
              end
         
     | 
| 
      
 355 
     | 
    
         
            +
             
     | 
| 
      
 356 
     | 
    
         
            +
              def test_no_args_record_returns_all_without_array
         
     | 
| 
      
 357 
     | 
    
         
            +
                all_binaries = binaries
         
     | 
| 
      
 358 
     | 
    
         
            +
                assert_kind_of(Array, all_binaries)
         
     | 
| 
      
 359 
     | 
    
         
            +
                assert_equal 2, binaries.length
         
     | 
| 
      
 360 
     | 
    
         
            +
              end
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
              def test_nil_raises
         
     | 
| 
      
 363 
     | 
    
         
            +
                assert_raise(StandardError) { topics(nil) }
         
     | 
| 
      
 364 
     | 
    
         
            +
                assert_raise(StandardError) { topics([nil]) }
         
     | 
| 
      
 365 
     | 
    
         
            +
              end
         
     | 
| 
      
 366 
     | 
    
         
            +
             
     | 
| 
      
 367 
     | 
    
         
            +
              def test_inserts
         
     | 
| 
      
 368 
     | 
    
         
            +
                create_fixtures("topics")
         
     | 
| 
      
 369 
     | 
    
         
            +
                first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'")
         
     | 
| 
      
 370 
     | 
    
         
            +
                assert_equal("The First Topic", first_row["title"])
         
     | 
| 
      
 371 
     | 
    
         
            +
             
     | 
| 
      
 372 
     | 
    
         
            +
                second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'Mary'")
         
     | 
| 
      
 373 
     | 
    
         
            +
                assert_nil(second_row["author_email_address"])
         
     | 
| 
      
 374 
     | 
    
         
            +
              end
         
     | 
| 
      
 375 
     | 
    
         
            +
             
     | 
| 
      
 376 
     | 
    
         
            +
              def test_inserts_with_pre_and_suffix
         
     | 
| 
      
 377 
     | 
    
         
            +
                # Reset cache to make finds on the new table work
         
     | 
| 
      
 378 
     | 
    
         
            +
                ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
      
 379 
     | 
    
         
            +
             
     | 
| 
      
 380 
     | 
    
         
            +
                ActiveRecord::Base.connection.create_table :prefix_other_topics_suffix do |t|
         
     | 
| 
      
 381 
     | 
    
         
            +
                  t.column :title, :string
         
     | 
| 
      
 382 
     | 
    
         
            +
                  t.column :author_name, :string
         
     | 
| 
      
 383 
     | 
    
         
            +
                  t.column :author_email_address, :string
         
     | 
| 
      
 384 
     | 
    
         
            +
                  t.column :written_on, :datetime
         
     | 
| 
      
 385 
     | 
    
         
            +
                  t.column :bonus_time, :time
         
     | 
| 
      
 386 
     | 
    
         
            +
                  t.column :last_read, :date
         
     | 
| 
      
 387 
     | 
    
         
            +
                  t.column :content, :string
         
     | 
| 
      
 388 
     | 
    
         
            +
                  t.column :approved, :boolean, default: true
         
     | 
| 
      
 389 
     | 
    
         
            +
                  t.column :replies_count, :integer, default: 0
         
     | 
| 
      
 390 
     | 
    
         
            +
                  t.column :parent_id, :integer
         
     | 
| 
      
 391 
     | 
    
         
            +
                  t.column :type, :string, limit: 50
         
     | 
| 
      
 392 
     | 
    
         
            +
                end
         
     | 
| 
      
 393 
     | 
    
         
            +
             
     | 
| 
      
 394 
     | 
    
         
            +
                # Store existing prefix/suffix
         
     | 
| 
      
 395 
     | 
    
         
            +
                old_prefix = ActiveRecord::Base.table_name_prefix
         
     | 
| 
      
 396 
     | 
    
         
            +
                old_suffix = ActiveRecord::Base.table_name_suffix
         
     | 
| 
      
 397 
     | 
    
         
            +
             
     | 
| 
      
 398 
     | 
    
         
            +
                # Set a prefix/suffix we can test against
         
     | 
| 
      
 399 
     | 
    
         
            +
                ActiveRecord::Base.table_name_prefix = "prefix_"
         
     | 
| 
      
 400 
     | 
    
         
            +
                ActiveRecord::Base.table_name_suffix = "_suffix"
         
     | 
| 
      
 401 
     | 
    
         
            +
             
     | 
| 
      
 402 
     | 
    
         
            +
                other_topic_klass = Class.new(ActiveRecord::Base) do
         
     | 
| 
      
 403 
     | 
    
         
            +
                  def self.name
         
     | 
| 
      
 404 
     | 
    
         
            +
                    "OtherTopic"
         
     | 
| 
      
 405 
     | 
    
         
            +
                  end
         
     | 
| 
      
 406 
     | 
    
         
            +
                end
         
     | 
| 
      
 407 
     | 
    
         
            +
             
     | 
| 
      
 408 
     | 
    
         
            +
                topics = [create_fixtures("other_topics")].flatten.first
         
     | 
| 
      
 409 
     | 
    
         
            +
             
     | 
| 
      
 410 
     | 
    
         
            +
                # This checks for a caching problem which causes a bug in the fixtures
         
     | 
| 
      
 411 
     | 
    
         
            +
                # class-level configuration helper.
         
     | 
| 
      
 412 
     | 
    
         
            +
                assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
         
     | 
| 
      
 413 
     | 
    
         
            +
             
     | 
| 
      
 414 
     | 
    
         
            +
                first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_other_topics_suffix WHERE author_name = 'David'")
         
     | 
| 
      
 415 
     | 
    
         
            +
                assert_not_nil first_row, "The prefix_other_topics_suffix table appears to be empty despite create_fixtures: the row with author_name = 'David' was not found"
         
     | 
| 
      
 416 
     | 
    
         
            +
                assert_equal("The First Topic", first_row["title"])
         
     | 
| 
      
 417 
     | 
    
         
            +
             
     | 
| 
      
 418 
     | 
    
         
            +
                second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_other_topics_suffix WHERE author_name = 'Mary'")
         
     | 
| 
      
 419 
     | 
    
         
            +
                assert_nil(second_row["author_email_address"])
         
     | 
| 
      
 420 
     | 
    
         
            +
             
     | 
| 
      
 421 
     | 
    
         
            +
                assert_equal :prefix_other_topics_suffix, topics.table_name.to_sym
         
     | 
| 
      
 422 
     | 
    
         
            +
                # This assertion should preferably be the last in the list, because calling
         
     | 
| 
      
 423 
     | 
    
         
            +
                # other_topic_klass.table_name sets a class-level instance variable
         
     | 
| 
      
 424 
     | 
    
         
            +
                assert_equal :prefix_other_topics_suffix, other_topic_klass.table_name.to_sym
         
     | 
| 
      
 425 
     | 
    
         
            +
             
     | 
| 
      
 426 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 427 
     | 
    
         
            +
                # Restore prefix/suffix to its previous values
         
     | 
| 
      
 428 
     | 
    
         
            +
                ActiveRecord::Base.table_name_prefix = old_prefix
         
     | 
| 
      
 429 
     | 
    
         
            +
                ActiveRecord::Base.table_name_suffix = old_suffix
         
     | 
| 
      
 430 
     | 
    
         
            +
             
     | 
| 
      
 431 
     | 
    
         
            +
                ActiveRecord::Base.connection.drop_table :prefix_other_topics_suffix rescue nil
         
     | 
| 
      
 432 
     | 
    
         
            +
              end
         
     | 
| 
      
 433 
     | 
    
         
            +
             
     | 
| 
      
 434 
     | 
    
         
            +
              def test_insert_with_datetime
         
     | 
| 
      
 435 
     | 
    
         
            +
                create_fixtures("tasks")
         
     | 
| 
      
 436 
     | 
    
         
            +
                first = Task.find(1)
         
     | 
| 
      
 437 
     | 
    
         
            +
                assert first
         
     | 
| 
      
 438 
     | 
    
         
            +
              end
         
     | 
| 
      
 439 
     | 
    
         
            +
             
     | 
| 
      
 440 
     | 
    
         
            +
              def test_logger_level_invariant
         
     | 
| 
      
 441 
     | 
    
         
            +
                level = ActiveRecord::Base.logger.level
         
     | 
| 
      
 442 
     | 
    
         
            +
                create_fixtures("topics")
         
     | 
| 
      
 443 
     | 
    
         
            +
                assert_equal level, ActiveRecord::Base.logger.level
         
     | 
| 
      
 444 
     | 
    
         
            +
              end
         
     | 
| 
      
 445 
     | 
    
         
            +
             
     | 
| 
      
 446 
     | 
    
         
            +
              def test_instantiation
         
     | 
| 
      
 447 
     | 
    
         
            +
                topics = create_fixtures("topics").first
         
     | 
| 
      
 448 
     | 
    
         
            +
                assert_kind_of Topic, topics["first"].find
         
     | 
| 
      
 449 
     | 
    
         
            +
              end
         
     | 
| 
      
 450 
     | 
    
         
            +
             
     | 
| 
      
 451 
     | 
    
         
            +
              def test_complete_instantiation
         
     | 
| 
      
 452 
     | 
    
         
            +
                assert_equal "The First Topic", @first.title
         
     | 
| 
      
 453 
     | 
    
         
            +
              end
         
     | 
| 
      
 454 
     | 
    
         
            +
             
     | 
| 
      
 455 
     | 
    
         
            +
              def test_fixtures_from_root_yml_with_instantiation
         
     | 
| 
      
 456 
     | 
    
         
            +
                assert_equal 50, @unknown.credit_limit
         
     | 
| 
      
 457 
     | 
    
         
            +
              end
         
     | 
| 
      
 458 
     | 
    
         
            +
             
     | 
| 
      
 459 
     | 
    
         
            +
              def test_erb_in_fixtures
         
     | 
| 
      
 460 
     | 
    
         
            +
                assert_equal "fixture_5", @dev_5.name
         
     | 
| 
      
 461 
     | 
    
         
            +
              end
         
     | 
| 
      
 462 
     | 
    
         
            +
             
     | 
| 
      
 463 
     | 
    
         
            +
              def test_empty_yaml_fixture
         
     | 
| 
      
 464 
     | 
    
         
            +
                assert_not_nil ActiveRecord::FixtureSet.new(nil, "accounts", Account, FIXTURES_ROOT + "/naked/yml/accounts")
         
     | 
| 
      
 465 
     | 
    
         
            +
              end
         
     | 
| 
      
 466 
     | 
    
         
            +
             
     | 
| 
      
 467 
     | 
    
         
            +
              def test_empty_yaml_fixture_with_a_comment_in_it
         
     | 
| 
      
 468 
     | 
    
         
            +
                assert_not_nil ActiveRecord::FixtureSet.new(nil, "companies", Company, FIXTURES_ROOT + "/naked/yml/companies")
         
     | 
| 
      
 469 
     | 
    
         
            +
              end
         
     | 
| 
      
 470 
     | 
    
         
            +
             
     | 
| 
      
 471 
     | 
    
         
            +
              def test_nonexistent_fixture_file
         
     | 
| 
      
 472 
     | 
    
         
            +
                nonexistent_fixture_path = FIXTURES_ROOT + "/imnothere"
         
     | 
| 
      
 473 
     | 
    
         
            +
             
     | 
| 
      
 474 
     | 
    
         
            +
                # sanity check to make sure that this file never exists
         
     | 
| 
      
 475 
     | 
    
         
            +
                assert_empty Dir[nonexistent_fixture_path + "*"]
         
     | 
| 
      
 476 
     | 
    
         
            +
             
     | 
| 
      
 477 
     | 
    
         
            +
                assert_raise(Errno::ENOENT) do
         
     | 
| 
      
 478 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.new(nil, "companies", Company, nonexistent_fixture_path)
         
     | 
| 
      
 479 
     | 
    
         
            +
                end
         
     | 
| 
      
 480 
     | 
    
         
            +
              end
         
     | 
| 
      
 481 
     | 
    
         
            +
             
     | 
| 
      
 482 
     | 
    
         
            +
              def test_dirty_dirty_yaml_file
         
     | 
| 
      
 483 
     | 
    
         
            +
                fixture_path = FIXTURES_ROOT + "/naked/yml/courses"
         
     | 
| 
      
 484 
     | 
    
         
            +
                error = assert_raise(ActiveRecord::Fixture::FormatError) do
         
     | 
| 
      
 485 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.new(nil, "courses", Course, fixture_path)
         
     | 
| 
      
 486 
     | 
    
         
            +
                end
         
     | 
| 
      
 487 
     | 
    
         
            +
                assert_equal "fixture is not a hash: #{fixture_path}.yml", error.to_s
         
     | 
| 
      
 488 
     | 
    
         
            +
              end
         
     | 
| 
      
 489 
     | 
    
         
            +
             
     | 
| 
      
 490 
     | 
    
         
            +
              def test_yaml_file_with_one_invalid_fixture
         
     | 
| 
      
 491 
     | 
    
         
            +
                fixture_path = FIXTURES_ROOT + "/naked/yml/courses_with_invalid_key"
         
     | 
| 
      
 492 
     | 
    
         
            +
                error = assert_raise(ActiveRecord::Fixture::FormatError) do
         
     | 
| 
      
 493 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.new(nil, "courses", Course, fixture_path)
         
     | 
| 
      
 494 
     | 
    
         
            +
                end
         
     | 
| 
      
 495 
     | 
    
         
            +
                assert_equal "fixture key is not a hash: #{fixture_path}.yml, keys: [\"two\"]", error.to_s
         
     | 
| 
      
 496 
     | 
    
         
            +
              end
         
     | 
| 
      
 497 
     | 
    
         
            +
             
     | 
| 
      
 498 
     | 
    
         
            +
              def test_yaml_file_with_invalid_column
         
     | 
| 
      
 499 
     | 
    
         
            +
                e = assert_raise(ActiveRecord::Fixture::FixtureError) do
         
     | 
| 
      
 500 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT + "/naked/yml", "parrots")
         
     | 
| 
      
 501 
     | 
    
         
            +
                end
         
     | 
| 
      
 502 
     | 
    
         
            +
             
     | 
| 
      
 503 
     | 
    
         
            +
                assert_equal(%(table "parrots" has no columns named "arrr", "foobar".), e.message)
         
     | 
| 
      
 504 
     | 
    
         
            +
              end
         
     | 
| 
      
 505 
     | 
    
         
            +
             
     | 
| 
      
 506 
     | 
    
         
            +
              def test_yaml_file_with_symbol_columns
         
     | 
| 
      
 507 
     | 
    
         
            +
                ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT + "/naked/yml", "trees")
         
     | 
| 
      
 508 
     | 
    
         
            +
              end
         
     | 
| 
      
 509 
     | 
    
         
            +
             
     | 
| 
      
 510 
     | 
    
         
            +
              def test_omap_fixtures
         
     | 
| 
      
 511 
     | 
    
         
            +
                assert_nothing_raised do
         
     | 
| 
      
 512 
     | 
    
         
            +
                  fixtures = ActiveRecord::FixtureSet.new(nil, "categories", Category, FIXTURES_ROOT + "/categories_ordered")
         
     | 
| 
      
 513 
     | 
    
         
            +
             
     | 
| 
      
 514 
     | 
    
         
            +
                  fixtures.each.with_index do |(name, fixture), i|
         
     | 
| 
      
 515 
     | 
    
         
            +
                    assert_equal "fixture_no_#{i}", name
         
     | 
| 
      
 516 
     | 
    
         
            +
                    assert_equal "Category #{i}", fixture["name"]
         
     | 
| 
      
 517 
     | 
    
         
            +
                  end
         
     | 
| 
      
 518 
     | 
    
         
            +
                end
         
     | 
| 
      
 519 
     | 
    
         
            +
              end
         
     | 
| 
      
 520 
     | 
    
         
            +
             
     | 
| 
      
 521 
     | 
    
         
            +
              def test_yml_file_in_subdirectory
         
     | 
| 
      
 522 
     | 
    
         
            +
                assert_equal(categories(:sub_special_1).name, "A special category in a subdir file")
         
     | 
| 
      
 523 
     | 
    
         
            +
                assert_equal(categories(:sub_special_1).class, SpecialCategory)
         
     | 
| 
      
 524 
     | 
    
         
            +
              end
         
     | 
| 
      
 525 
     | 
    
         
            +
             
     | 
| 
      
 526 
     | 
    
         
            +
              def test_subsubdir_file_with_arbitrary_name
         
     | 
| 
      
 527 
     | 
    
         
            +
                assert_equal(categories(:sub_special_3).name, "A special category in an arbitrarily named subsubdir file")
         
     | 
| 
      
 528 
     | 
    
         
            +
                assert_equal(categories(:sub_special_3).class, SpecialCategory)
         
     | 
| 
      
 529 
     | 
    
         
            +
              end
         
     | 
| 
      
 530 
     | 
    
         
            +
             
     | 
| 
      
 531 
     | 
    
         
            +
              def test_binary_in_fixtures
         
     | 
| 
      
 532 
     | 
    
         
            +
                data = File.binread(ASSETS_ROOT + "/flowers.jpg")
         
     | 
| 
      
 533 
     | 
    
         
            +
                data.force_encoding("ASCII-8BIT")
         
     | 
| 
      
 534 
     | 
    
         
            +
                data.freeze
         
     | 
| 
      
 535 
     | 
    
         
            +
                assert_equal data, @flowers.data
         
     | 
| 
      
 536 
     | 
    
         
            +
                assert_equal data, @binary_helper.data
         
     | 
| 
      
 537 
     | 
    
         
            +
              end
         
     | 
| 
      
 538 
     | 
    
         
            +
             
     | 
| 
      
 539 
     | 
    
         
            +
              def test_serialized_fixtures
         
     | 
| 
      
 540 
     | 
    
         
            +
                assert_equal ["Green", "Red", "Orange"], traffic_lights(:uk).state
         
     | 
| 
      
 541 
     | 
    
         
            +
              end
         
     | 
| 
      
 542 
     | 
    
         
            +
             
     | 
| 
      
 543 
     | 
    
         
            +
              def test_fixtures_are_set_up_with_database_env_variable
         
     | 
| 
      
 544 
     | 
    
         
            +
                db_url_tmp = ENV["DATABASE_URL"]
         
     | 
| 
      
 545 
     | 
    
         
            +
                ENV["DATABASE_URL"] = "sqlite3::memory:"
         
     | 
| 
      
 546 
     | 
    
         
            +
                ActiveRecord::Base.stub(:configurations, {}) do
         
     | 
| 
      
 547 
     | 
    
         
            +
                  test_case = Class.new(ActiveRecord::TestCase) do
         
     | 
| 
      
 548 
     | 
    
         
            +
                    fixtures :accounts
         
     | 
| 
      
 549 
     | 
    
         
            +
             
     | 
| 
      
 550 
     | 
    
         
            +
                    def test_fixtures
         
     | 
| 
      
 551 
     | 
    
         
            +
                      assert accounts(:signals37)
         
     | 
| 
      
 552 
     | 
    
         
            +
                    end
         
     | 
| 
      
 553 
     | 
    
         
            +
                  end
         
     | 
| 
      
 554 
     | 
    
         
            +
             
     | 
| 
      
 555 
     | 
    
         
            +
                  result = test_case.new(:test_fixtures).run
         
     | 
| 
      
 556 
     | 
    
         
            +
             
     | 
| 
      
 557 
     | 
    
         
            +
                  assert result.passed?, "Expected #{result.name} to pass:\n#{result}"
         
     | 
| 
      
 558 
     | 
    
         
            +
                end
         
     | 
| 
      
 559 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 560 
     | 
    
         
            +
                ENV["DATABASE_URL"] = db_url_tmp
         
     | 
| 
      
 561 
     | 
    
         
            +
              end
         
     | 
| 
      
 562 
     | 
    
         
            +
            end
         
     | 
| 
      
 563 
     | 
    
         
            +
             
     | 
| 
      
 564 
     | 
    
         
            +
            class HasManyThroughFixture < ActiveRecord::TestCase
         
     | 
| 
      
 565 
     | 
    
         
            +
              def make_model(name)
         
     | 
| 
      
 566 
     | 
    
         
            +
                Class.new(ActiveRecord::Base) { define_singleton_method(:name) { name } }
         
     | 
| 
      
 567 
     | 
    
         
            +
              end
         
     | 
| 
      
 568 
     | 
    
         
            +
             
     | 
| 
      
 569 
     | 
    
         
            +
              def test_has_many_through_with_default_table_name
         
     | 
| 
      
 570 
     | 
    
         
            +
                pt = make_model "ParrotTreasure"
         
     | 
| 
      
 571 
     | 
    
         
            +
                parrot = make_model "Parrot"
         
     | 
| 
      
 572 
     | 
    
         
            +
                treasure = make_model "Treasure"
         
     | 
| 
      
 573 
     | 
    
         
            +
             
     | 
| 
      
 574 
     | 
    
         
            +
                pt.table_name = "parrots_treasures"
         
     | 
| 
      
 575 
     | 
    
         
            +
                pt.belongs_to :parrot, anonymous_class: parrot
         
     | 
| 
      
 576 
     | 
    
         
            +
                pt.belongs_to :treasure, anonymous_class: treasure
         
     | 
| 
      
 577 
     | 
    
         
            +
             
     | 
| 
      
 578 
     | 
    
         
            +
                parrot.has_many :parrot_treasures, anonymous_class: pt
         
     | 
| 
      
 579 
     | 
    
         
            +
                parrot.has_many :treasures, through: :parrot_treasures
         
     | 
| 
      
 580 
     | 
    
         
            +
             
     | 
| 
      
 581 
     | 
    
         
            +
                parrots = File.join FIXTURES_ROOT, "parrots"
         
     | 
| 
      
 582 
     | 
    
         
            +
             
     | 
| 
      
 583 
     | 
    
         
            +
                fs = ActiveRecord::FixtureSet.new(nil, "parrots", parrot, parrots)
         
     | 
| 
      
 584 
     | 
    
         
            +
                rows = fs.table_rows
         
     | 
| 
      
 585 
     | 
    
         
            +
                assert_equal load_has_and_belongs_to_many["parrots_treasures"], rows["parrots_treasures"]
         
     | 
| 
      
 586 
     | 
    
         
            +
              end
         
     | 
| 
      
 587 
     | 
    
         
            +
             
     | 
| 
      
 588 
     | 
    
         
            +
              def test_has_many_through_with_renamed_table
         
     | 
| 
      
 589 
     | 
    
         
            +
                pt = make_model "ParrotTreasure"
         
     | 
| 
      
 590 
     | 
    
         
            +
                parrot = make_model "Parrot"
         
     | 
| 
      
 591 
     | 
    
         
            +
                treasure = make_model "Treasure"
         
     | 
| 
      
 592 
     | 
    
         
            +
             
     | 
| 
      
 593 
     | 
    
         
            +
                pt.belongs_to :parrot, anonymous_class: parrot
         
     | 
| 
      
 594 
     | 
    
         
            +
                pt.belongs_to :treasure, anonymous_class: treasure
         
     | 
| 
      
 595 
     | 
    
         
            +
             
     | 
| 
      
 596 
     | 
    
         
            +
                parrot.has_many :parrot_treasures, anonymous_class: pt
         
     | 
| 
      
 597 
     | 
    
         
            +
                parrot.has_many :treasures, through: :parrot_treasures
         
     | 
| 
      
 598 
     | 
    
         
            +
             
     | 
| 
      
 599 
     | 
    
         
            +
                parrots = File.join FIXTURES_ROOT, "parrots"
         
     | 
| 
      
 600 
     | 
    
         
            +
             
     | 
| 
      
 601 
     | 
    
         
            +
                fs = ActiveRecord::FixtureSet.new(nil, "parrots", parrot, parrots)
         
     | 
| 
      
 602 
     | 
    
         
            +
                rows = fs.table_rows
         
     | 
| 
      
 603 
     | 
    
         
            +
                assert_equal load_has_and_belongs_to_many["parrots_treasures"], rows["parrot_treasures"]
         
     | 
| 
      
 604 
     | 
    
         
            +
              end
         
     | 
| 
      
 605 
     | 
    
         
            +
             
     | 
| 
      
 606 
     | 
    
         
            +
              def test_has_and_belongs_to_many_order
         
     | 
| 
      
 607 
     | 
    
         
            +
                assert_equal ["parrots", "parrots_treasures"], load_has_and_belongs_to_many.keys
         
     | 
| 
      
 608 
     | 
    
         
            +
              end
         
     | 
| 
      
 609 
     | 
    
         
            +
             
     | 
| 
      
 610 
     | 
    
         
            +
              def load_has_and_belongs_to_many
         
     | 
| 
      
 611 
     | 
    
         
            +
                parrot = make_model "Parrot"
         
     | 
| 
      
 612 
     | 
    
         
            +
                parrot.has_and_belongs_to_many :treasures
         
     | 
| 
      
 613 
     | 
    
         
            +
             
     | 
| 
      
 614 
     | 
    
         
            +
                parrots = File.join FIXTURES_ROOT, "parrots"
         
     | 
| 
      
 615 
     | 
    
         
            +
             
     | 
| 
      
 616 
     | 
    
         
            +
                fs = ActiveRecord::FixtureSet.new(nil, "parrots", parrot, parrots)
         
     | 
| 
      
 617 
     | 
    
         
            +
                fs.table_rows
         
     | 
| 
      
 618 
     | 
    
         
            +
              end
         
     | 
| 
      
 619 
     | 
    
         
            +
            end
         
     | 
| 
      
 620 
     | 
    
         
            +
             
     | 
| 
      
 621 
     | 
    
         
            +
            if Account.connection.respond_to?(:reset_pk_sequence!)
         
     | 
| 
      
 622 
     | 
    
         
            +
              class FixturesResetPkSequenceTest < ActiveRecord::TestCase
         
     | 
| 
      
 623 
     | 
    
         
            +
                fixtures :accounts
         
     | 
| 
      
 624 
     | 
    
         
            +
                fixtures :companies
         
     | 
| 
      
 625 
     | 
    
         
            +
                self.use_transactional_tests = false
         
     | 
| 
      
 626 
     | 
    
         
            +
             
     | 
| 
      
 627 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 628 
     | 
    
         
            +
                  @instances = [Account.new(credit_limit: 50), Company.new(name: "RoR Consulting"), Course.new(name: "Test")]
         
     | 
| 
      
 629 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.reset_cache # make sure tables get reinitialized
         
     | 
| 
      
 630 
     | 
    
         
            +
                end
         
     | 
| 
      
 631 
     | 
    
         
            +
             
     | 
| 
      
 632 
     | 
    
         
            +
                def test_resets_to_min_pk_with_specified_pk_and_sequence
         
     | 
| 
      
 633 
     | 
    
         
            +
                  @instances.each do |instance|
         
     | 
| 
      
 634 
     | 
    
         
            +
                    model = instance.class
         
     | 
| 
      
 635 
     | 
    
         
            +
                    model.delete_all
         
     | 
| 
      
 636 
     | 
    
         
            +
                    model.connection.reset_pk_sequence!(model.table_name, model.primary_key, model.sequence_name)
         
     | 
| 
      
 637 
     | 
    
         
            +
             
     | 
| 
      
 638 
     | 
    
         
            +
                    instance.save!
         
     | 
| 
      
 639 
     | 
    
         
            +
                    assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed."
         
     | 
| 
      
 640 
     | 
    
         
            +
                  end
         
     | 
| 
      
 641 
     | 
    
         
            +
                end
         
     | 
| 
      
 642 
     | 
    
         
            +
             
     | 
| 
      
 643 
     | 
    
         
            +
                def test_resets_to_min_pk_with_default_pk_and_sequence
         
     | 
| 
      
 644 
     | 
    
         
            +
                  @instances.each do |instance|
         
     | 
| 
      
 645 
     | 
    
         
            +
                    model = instance.class
         
     | 
| 
      
 646 
     | 
    
         
            +
                    model.delete_all
         
     | 
| 
      
 647 
     | 
    
         
            +
                    model.connection.reset_pk_sequence!(model.table_name)
         
     | 
| 
      
 648 
     | 
    
         
            +
             
     | 
| 
      
 649 
     | 
    
         
            +
                    instance.save!
         
     | 
| 
      
 650 
     | 
    
         
            +
                    assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed."
         
     | 
| 
      
 651 
     | 
    
         
            +
                  end
         
     | 
| 
      
 652 
     | 
    
         
            +
                end
         
     | 
| 
      
 653 
     | 
    
         
            +
             
     | 
| 
      
 654 
     | 
    
         
            +
                def test_create_fixtures_resets_sequences_when_not_cached
         
     | 
| 
      
 655 
     | 
    
         
            +
                  @instances.each do |instance|
         
     | 
| 
      
 656 
     | 
    
         
            +
                    max_id = create_fixtures(instance.class.table_name).first.fixtures.inject(0) do |_max_id, (_, fixture)|
         
     | 
| 
      
 657 
     | 
    
         
            +
                      fixture_id = fixture["id"].to_i
         
     | 
| 
      
 658 
     | 
    
         
            +
                      fixture_id > _max_id ? fixture_id : _max_id
         
     | 
| 
      
 659 
     | 
    
         
            +
                    end
         
     | 
| 
      
 660 
     | 
    
         
            +
             
     | 
| 
      
 661 
     | 
    
         
            +
                    # Clone the last fixture to check that it gets the next greatest id.
         
     | 
| 
      
 662 
     | 
    
         
            +
                    instance.save!
         
     | 
| 
      
 663 
     | 
    
         
            +
                    assert_equal max_id + 1, instance.id, "Sequence reset for #{instance.class.table_name} failed."
         
     | 
| 
      
 664 
     | 
    
         
            +
                  end
         
     | 
| 
      
 665 
     | 
    
         
            +
                end
         
     | 
| 
      
 666 
     | 
    
         
            +
              end
         
     | 
| 
      
 667 
     | 
    
         
            +
            end
         
     | 
| 
      
 668 
     | 
    
         
            +
             
     | 
| 
      
 669 
     | 
    
         
            +
            class FixturesWithoutInstantiationTest < ActiveRecord::TestCase
         
     | 
| 
      
 670 
     | 
    
         
            +
              self.use_instantiated_fixtures = false
         
     | 
| 
      
 671 
     | 
    
         
            +
              fixtures :topics, :developers, :accounts
         
     | 
| 
      
 672 
     | 
    
         
            +
             
     | 
| 
      
 673 
     | 
    
         
            +
              def test_without_complete_instantiation
         
     | 
| 
      
 674 
     | 
    
         
            +
                assert_not defined?(@first)
         
     | 
| 
      
 675 
     | 
    
         
            +
                assert_not defined?(@topics)
         
     | 
| 
      
 676 
     | 
    
         
            +
                assert_not defined?(@developers)
         
     | 
| 
      
 677 
     | 
    
         
            +
                assert_not defined?(@accounts)
         
     | 
| 
      
 678 
     | 
    
         
            +
              end
         
     | 
| 
      
 679 
     | 
    
         
            +
             
     | 
| 
      
 680 
     | 
    
         
            +
              def test_fixtures_from_root_yml_without_instantiation
         
     | 
| 
      
 681 
     | 
    
         
            +
                assert_not defined?(@unknown), "@unknown is not defined"
         
     | 
| 
      
 682 
     | 
    
         
            +
              end
         
     | 
| 
      
 683 
     | 
    
         
            +
             
     | 
| 
      
 684 
     | 
    
         
            +
              def test_visibility_of_accessor_method
         
     | 
| 
      
 685 
     | 
    
         
            +
                assert_equal false, respond_to?(:topics, false), "should be private method"
         
     | 
| 
      
 686 
     | 
    
         
            +
                assert_equal true, respond_to?(:topics, true), "confirm to respond surely"
         
     | 
| 
      
 687 
     | 
    
         
            +
              end
         
     | 
| 
      
 688 
     | 
    
         
            +
             
     | 
| 
      
 689 
     | 
    
         
            +
              def test_accessor_methods
         
     | 
| 
      
 690 
     | 
    
         
            +
                assert_equal "The First Topic", topics(:first).title
         
     | 
| 
      
 691 
     | 
    
         
            +
                assert_equal "Jamis", developers(:jamis).name
         
     | 
| 
      
 692 
     | 
    
         
            +
                assert_equal 50, accounts(:signals37).credit_limit
         
     | 
| 
      
 693 
     | 
    
         
            +
              end
         
     | 
| 
      
 694 
     | 
    
         
            +
             
     | 
| 
      
 695 
     | 
    
         
            +
              def test_accessor_methods_with_multiple_args
         
     | 
| 
      
 696 
     | 
    
         
            +
                assert_equal 2, topics(:first, :second).size
         
     | 
| 
      
 697 
     | 
    
         
            +
                assert_raise(StandardError) { topics([:first, :second]) }
         
     | 
| 
      
 698 
     | 
    
         
            +
              end
         
     | 
| 
      
 699 
     | 
    
         
            +
             
     | 
| 
      
 700 
     | 
    
         
            +
              def test_reloading_fixtures_through_accessor_methods
         
     | 
| 
      
 701 
     | 
    
         
            +
                topic = Struct.new(:title)
         
     | 
| 
      
 702 
     | 
    
         
            +
                assert_equal "The First Topic", topics(:first).title
         
     | 
| 
      
 703 
     | 
    
         
            +
                assert_called(@loaded_fixtures["topics"]["first"], :find, returns: topic.new("Fresh Topic!")) do
         
     | 
| 
      
 704 
     | 
    
         
            +
                  assert_equal "Fresh Topic!", topics(:first, true).title
         
     | 
| 
      
 705 
     | 
    
         
            +
                end
         
     | 
| 
      
 706 
     | 
    
         
            +
              end
         
     | 
| 
      
 707 
     | 
    
         
            +
            end
         
     | 
| 
      
 708 
     | 
    
         
            +
             
     | 
| 
      
 709 
     | 
    
         
            +
            class FixturesWithoutInstanceInstantiationTest < ActiveRecord::TestCase
         
     | 
| 
      
 710 
     | 
    
         
            +
              self.use_instantiated_fixtures = true
         
     | 
| 
      
 711 
     | 
    
         
            +
              self.use_instantiated_fixtures = :no_instances
         
     | 
| 
      
 712 
     | 
    
         
            +
             
     | 
| 
      
 713 
     | 
    
         
            +
              fixtures :topics, :developers, :accounts
         
     | 
| 
      
 714 
     | 
    
         
            +
             
     | 
| 
      
 715 
     | 
    
         
            +
              def test_without_instance_instantiation
         
     | 
| 
      
 716 
     | 
    
         
            +
                assert_not defined?(@first), "@first is not defined"
         
     | 
| 
      
 717 
     | 
    
         
            +
              end
         
     | 
| 
      
 718 
     | 
    
         
            +
            end
         
     | 
| 
      
 719 
     | 
    
         
            +
             
     | 
| 
      
 720 
     | 
    
         
            +
            class TransactionalFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 721 
     | 
    
         
            +
              self.use_instantiated_fixtures = true
         
     | 
| 
      
 722 
     | 
    
         
            +
              self.use_transactional_tests = true
         
     | 
| 
      
 723 
     | 
    
         
            +
             
     | 
| 
      
 724 
     | 
    
         
            +
              fixtures :topics
         
     | 
| 
      
 725 
     | 
    
         
            +
             
     | 
| 
      
 726 
     | 
    
         
            +
              def test_destroy
         
     | 
| 
      
 727 
     | 
    
         
            +
                assert_not_nil @first
         
     | 
| 
      
 728 
     | 
    
         
            +
                @first.destroy
         
     | 
| 
      
 729 
     | 
    
         
            +
              end
         
     | 
| 
      
 730 
     | 
    
         
            +
             
     | 
| 
      
 731 
     | 
    
         
            +
              def test_destroy_just_kidding
         
     | 
| 
      
 732 
     | 
    
         
            +
                assert_not_nil @first
         
     | 
| 
      
 733 
     | 
    
         
            +
              end
         
     | 
| 
      
 734 
     | 
    
         
            +
            end
         
     | 
| 
      
 735 
     | 
    
         
            +
             
     | 
| 
      
 736 
     | 
    
         
            +
            class MultipleFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 737 
     | 
    
         
            +
              fixtures :topics
         
     | 
| 
      
 738 
     | 
    
         
            +
              fixtures :developers, :accounts
         
     | 
| 
      
 739 
     | 
    
         
            +
             
     | 
| 
      
 740 
     | 
    
         
            +
              def test_fixture_table_names
         
     | 
| 
      
 741 
     | 
    
         
            +
                assert_equal %w(topics developers accounts), fixture_table_names
         
     | 
| 
      
 742 
     | 
    
         
            +
              end
         
     | 
| 
      
 743 
     | 
    
         
            +
            end
         
     | 
| 
      
 744 
     | 
    
         
            +
             
     | 
| 
      
 745 
     | 
    
         
            +
            class SetupTest < ActiveRecord::TestCase
         
     | 
| 
      
 746 
     | 
    
         
            +
              # fixtures :topics
         
     | 
| 
      
 747 
     | 
    
         
            +
             
     | 
| 
      
 748 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 749 
     | 
    
         
            +
                @first = true
         
     | 
| 
      
 750 
     | 
    
         
            +
              end
         
     | 
| 
      
 751 
     | 
    
         
            +
             
     | 
| 
      
 752 
     | 
    
         
            +
              def test_nothing
         
     | 
| 
      
 753 
     | 
    
         
            +
              end
         
     | 
| 
      
 754 
     | 
    
         
            +
            end
         
     | 
| 
      
 755 
     | 
    
         
            +
             
     | 
| 
      
 756 
     | 
    
         
            +
            class SetupSubclassTest < SetupTest
         
     | 
| 
      
 757 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 758 
     | 
    
         
            +
                super
         
     | 
| 
      
 759 
     | 
    
         
            +
                @second = true
         
     | 
| 
      
 760 
     | 
    
         
            +
              end
         
     | 
| 
      
 761 
     | 
    
         
            +
             
     | 
| 
      
 762 
     | 
    
         
            +
              def test_subclassing_should_preserve_setups
         
     | 
| 
      
 763 
     | 
    
         
            +
                assert @first
         
     | 
| 
      
 764 
     | 
    
         
            +
                assert @second
         
     | 
| 
      
 765 
     | 
    
         
            +
              end
         
     | 
| 
      
 766 
     | 
    
         
            +
            end
         
     | 
| 
      
 767 
     | 
    
         
            +
             
     | 
| 
      
 768 
     | 
    
         
            +
            class OverlappingFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 769 
     | 
    
         
            +
              fixtures :topics, :developers
         
     | 
| 
      
 770 
     | 
    
         
            +
              fixtures :developers, :accounts
         
     | 
| 
      
 771 
     | 
    
         
            +
             
     | 
| 
      
 772 
     | 
    
         
            +
              def test_fixture_table_names
         
     | 
| 
      
 773 
     | 
    
         
            +
                assert_equal %w(topics developers accounts), fixture_table_names
         
     | 
| 
      
 774 
     | 
    
         
            +
              end
         
     | 
| 
      
 775 
     | 
    
         
            +
            end
         
     | 
| 
      
 776 
     | 
    
         
            +
             
     | 
| 
      
 777 
     | 
    
         
            +
            class ForeignKeyFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 778 
     | 
    
         
            +
              fixtures :fk_test_has_pk, :fk_test_has_fk
         
     | 
| 
      
 779 
     | 
    
         
            +
             
     | 
| 
      
 780 
     | 
    
         
            +
              # if foreign keys are implemented and fixtures
         
     | 
| 
      
 781 
     | 
    
         
            +
              # are not deleted in reverse order then this test
         
     | 
| 
      
 782 
     | 
    
         
            +
              # case will raise StatementInvalid
         
     | 
| 
      
 783 
     | 
    
         
            +
             
     | 
| 
      
 784 
     | 
    
         
            +
              def test_number1
         
     | 
| 
      
 785 
     | 
    
         
            +
                assert true
         
     | 
| 
      
 786 
     | 
    
         
            +
              end
         
     | 
| 
      
 787 
     | 
    
         
            +
             
     | 
| 
      
 788 
     | 
    
         
            +
              def test_number2
         
     | 
| 
      
 789 
     | 
    
         
            +
                assert true
         
     | 
| 
      
 790 
     | 
    
         
            +
              end
         
     | 
| 
      
 791 
     | 
    
         
            +
            end
         
     | 
| 
      
 792 
     | 
    
         
            +
             
     | 
| 
      
 793 
     | 
    
         
            +
            class OverRideFixtureMethodTest < ActiveRecord::TestCase
         
     | 
| 
      
 794 
     | 
    
         
            +
              fixtures :topics
         
     | 
| 
      
 795 
     | 
    
         
            +
             
     | 
| 
      
 796 
     | 
    
         
            +
              def topics(name)
         
     | 
| 
      
 797 
     | 
    
         
            +
                topic = super
         
     | 
| 
      
 798 
     | 
    
         
            +
                topic.title = "omg"
         
     | 
| 
      
 799 
     | 
    
         
            +
                topic
         
     | 
| 
      
 800 
     | 
    
         
            +
              end
         
     | 
| 
      
 801 
     | 
    
         
            +
             
     | 
| 
      
 802 
     | 
    
         
            +
              def test_fixture_methods_can_be_overridden
         
     | 
| 
      
 803 
     | 
    
         
            +
                x = topics :first
         
     | 
| 
      
 804 
     | 
    
         
            +
                assert_equal "omg", x.title
         
     | 
| 
      
 805 
     | 
    
         
            +
              end
         
     | 
| 
      
 806 
     | 
    
         
            +
            end
         
     | 
| 
      
 807 
     | 
    
         
            +
             
     | 
| 
      
 808 
     | 
    
         
            +
            class FixtureWithSetModelClassTest < ActiveRecord::TestCase
         
     | 
| 
      
 809 
     | 
    
         
            +
              fixtures :other_posts, :other_comments
         
     | 
| 
      
 810 
     | 
    
         
            +
             
     | 
| 
      
 811 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 812 
     | 
    
         
            +
              # and thus takes into account the `model_class` set in the fixture.
         
     | 
| 
      
 813 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 814 
     | 
    
         
            +
             
     | 
| 
      
 815 
     | 
    
         
            +
              def test_uses_fixture_class_defined_in_yaml
         
     | 
| 
      
 816 
     | 
    
         
            +
                assert_kind_of Post, other_posts(:second_welcome)
         
     | 
| 
      
 817 
     | 
    
         
            +
              end
         
     | 
| 
      
 818 
     | 
    
         
            +
             
     | 
| 
      
 819 
     | 
    
         
            +
              def test_loads_the_associations_to_fixtures_with_set_model_class
         
     | 
| 
      
 820 
     | 
    
         
            +
                post = other_posts(:second_welcome)
         
     | 
| 
      
 821 
     | 
    
         
            +
                comment = other_comments(:second_greetings)
         
     | 
| 
      
 822 
     | 
    
         
            +
                assert_equal [comment], post.comments
         
     | 
| 
      
 823 
     | 
    
         
            +
                assert_equal post, comment.post
         
     | 
| 
      
 824 
     | 
    
         
            +
              end
         
     | 
| 
      
 825 
     | 
    
         
            +
            end
         
     | 
| 
      
 826 
     | 
    
         
            +
             
     | 
| 
      
 827 
     | 
    
         
            +
            class SetFixtureClassPrevailsTest < ActiveRecord::TestCase
         
     | 
| 
      
 828 
     | 
    
         
            +
              set_fixture_class bad_posts: Post
         
     | 
| 
      
 829 
     | 
    
         
            +
              fixtures :bad_posts
         
     | 
| 
      
 830 
     | 
    
         
            +
             
     | 
| 
      
 831 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 832 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
      
 833 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 834 
     | 
    
         
            +
             
     | 
| 
      
 835 
     | 
    
         
            +
              def test_uses_set_fixture_class
         
     | 
| 
      
 836 
     | 
    
         
            +
                assert_kind_of Post, bad_posts(:bad_welcome)
         
     | 
| 
      
 837 
     | 
    
         
            +
              end
         
     | 
| 
      
 838 
     | 
    
         
            +
            end
         
     | 
| 
      
 839 
     | 
    
         
            +
             
     | 
| 
      
 840 
     | 
    
         
            +
            class CheckSetTableNameFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 841 
     | 
    
         
            +
              set_fixture_class funny_jokes: Joke
         
     | 
| 
      
 842 
     | 
    
         
            +
              fixtures :funny_jokes
         
     | 
| 
      
 843 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 844 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
      
 845 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 846 
     | 
    
         
            +
             
     | 
| 
      
 847 
     | 
    
         
            +
              def test_table_method
         
     | 
| 
      
 848 
     | 
    
         
            +
                assert_kind_of Joke, funny_jokes(:a_joke)
         
     | 
| 
      
 849 
     | 
    
         
            +
              end
         
     | 
| 
      
 850 
     | 
    
         
            +
            end
         
     | 
| 
      
 851 
     | 
    
         
            +
             
     | 
| 
      
 852 
     | 
    
         
            +
            class FixtureNameIsNotTableNameFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 853 
     | 
    
         
            +
              set_fixture_class items: Book
         
     | 
| 
      
 854 
     | 
    
         
            +
              fixtures :items
         
     | 
| 
      
 855 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 856 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
      
 857 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 858 
     | 
    
         
            +
             
     | 
| 
      
 859 
     | 
    
         
            +
              def test_named_accessor
         
     | 
| 
      
 860 
     | 
    
         
            +
                assert_kind_of Book, items(:dvd)
         
     | 
| 
      
 861 
     | 
    
         
            +
              end
         
     | 
| 
      
 862 
     | 
    
         
            +
            end
         
     | 
| 
      
 863 
     | 
    
         
            +
             
     | 
| 
      
 864 
     | 
    
         
            +
            class FixtureNameIsNotTableNameMultipleFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 865 
     | 
    
         
            +
              set_fixture_class items: Book, funny_jokes: Joke
         
     | 
| 
      
 866 
     | 
    
         
            +
              fixtures :items, :funny_jokes
         
     | 
| 
      
 867 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 868 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
      
 869 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 870 
     | 
    
         
            +
             
     | 
| 
      
 871 
     | 
    
         
            +
              def test_named_accessor_of_differently_named_fixture
         
     | 
| 
      
 872 
     | 
    
         
            +
                assert_kind_of Book, items(:dvd)
         
     | 
| 
      
 873 
     | 
    
         
            +
              end
         
     | 
| 
      
 874 
     | 
    
         
            +
             
     | 
| 
      
 875 
     | 
    
         
            +
              def test_named_accessor_of_same_named_fixture
         
     | 
| 
      
 876 
     | 
    
         
            +
                assert_kind_of Joke, funny_jokes(:a_joke)
         
     | 
| 
      
 877 
     | 
    
         
            +
              end
         
     | 
| 
      
 878 
     | 
    
         
            +
            end
         
     | 
| 
      
 879 
     | 
    
         
            +
             
     | 
| 
      
 880 
     | 
    
         
            +
            class CustomConnectionFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 881 
     | 
    
         
            +
              set_fixture_class courses: Course
         
     | 
| 
      
 882 
     | 
    
         
            +
              fixtures :courses
         
     | 
| 
      
 883 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 884 
     | 
    
         
            +
             
     | 
| 
      
 885 
     | 
    
         
            +
              def test_leaky_destroy
         
     | 
| 
      
 886 
     | 
    
         
            +
                assert_nothing_raised { courses(:ruby) }
         
     | 
| 
      
 887 
     | 
    
         
            +
                courses(:ruby).destroy
         
     | 
| 
      
 888 
     | 
    
         
            +
              end
         
     | 
| 
      
 889 
     | 
    
         
            +
             
     | 
| 
      
 890 
     | 
    
         
            +
              def test_it_twice_in_whatever_order_to_check_for_fixture_leakage
         
     | 
| 
      
 891 
     | 
    
         
            +
                test_leaky_destroy
         
     | 
| 
      
 892 
     | 
    
         
            +
              end
         
     | 
| 
      
 893 
     | 
    
         
            +
            end
         
     | 
| 
      
 894 
     | 
    
         
            +
             
     | 
| 
      
 895 
     | 
    
         
            +
            class TransactionalFixturesOnCustomConnectionTest < ActiveRecord::TestCase
         
     | 
| 
      
 896 
     | 
    
         
            +
              set_fixture_class courses: Course
         
     | 
| 
      
 897 
     | 
    
         
            +
              fixtures :courses
         
     | 
| 
      
 898 
     | 
    
         
            +
              self.use_transactional_tests = true
         
     | 
| 
      
 899 
     | 
    
         
            +
             
     | 
| 
      
 900 
     | 
    
         
            +
              def test_leaky_destroy
         
     | 
| 
      
 901 
     | 
    
         
            +
                assert_nothing_raised { courses(:ruby) }
         
     | 
| 
      
 902 
     | 
    
         
            +
                courses(:ruby).destroy
         
     | 
| 
      
 903 
     | 
    
         
            +
              end
         
     | 
| 
      
 904 
     | 
    
         
            +
             
     | 
| 
      
 905 
     | 
    
         
            +
              def test_it_twice_in_whatever_order_to_check_for_fixture_leakage
         
     | 
| 
      
 906 
     | 
    
         
            +
                test_leaky_destroy
         
     | 
| 
      
 907 
     | 
    
         
            +
              end
         
     | 
| 
      
 908 
     | 
    
         
            +
            end
         
     | 
| 
      
 909 
     | 
    
         
            +
             
     | 
| 
      
 910 
     | 
    
         
            +
            class TransactionalFixturesOnConnectionNotification < ActiveRecord::TestCase
         
     | 
| 
      
 911 
     | 
    
         
            +
              self.use_transactional_tests = true
         
     | 
| 
      
 912 
     | 
    
         
            +
              self.use_instantiated_fixtures = false
         
     | 
| 
      
 913 
     | 
    
         
            +
             
     | 
| 
      
 914 
     | 
    
         
            +
              def test_transaction_created_on_connection_notification
         
     | 
| 
      
 915 
     | 
    
         
            +
                connection = Class.new do
         
     | 
| 
      
 916 
     | 
    
         
            +
                  attr_accessor :pool
         
     | 
| 
      
 917 
     | 
    
         
            +
             
     | 
| 
      
 918 
     | 
    
         
            +
                  def transaction_open?; end
         
     | 
| 
      
 919 
     | 
    
         
            +
                  def begin_transaction(*args); end
         
     | 
| 
      
 920 
     | 
    
         
            +
                  def rollback_transaction(*args); end
         
     | 
| 
      
 921 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 922 
     | 
    
         
            +
             
     | 
| 
      
 923 
     | 
    
         
            +
                connection.pool = Class.new do
         
     | 
| 
      
 924 
     | 
    
         
            +
                  def lock_thread=(lock_thread); end
         
     | 
| 
      
 925 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 926 
     | 
    
         
            +
             
     | 
| 
      
 927 
     | 
    
         
            +
                assert_called_with(connection, :begin_transaction, [joinable: false, _lazy: false]) do
         
     | 
| 
      
 928 
     | 
    
         
            +
                  fire_connection_notification(connection)
         
     | 
| 
      
 929 
     | 
    
         
            +
                end
         
     | 
| 
      
 930 
     | 
    
         
            +
              end
         
     | 
| 
      
 931 
     | 
    
         
            +
             
     | 
| 
      
 932 
     | 
    
         
            +
              def test_notification_established_transactions_are_rolled_back
         
     | 
| 
      
 933 
     | 
    
         
            +
                connection = Class.new do
         
     | 
| 
      
 934 
     | 
    
         
            +
                  attr_accessor :rollback_transaction_called
         
     | 
| 
      
 935 
     | 
    
         
            +
                  attr_accessor :pool
         
     | 
| 
      
 936 
     | 
    
         
            +
             
     | 
| 
      
 937 
     | 
    
         
            +
                  def transaction_open?; true; end
         
     | 
| 
      
 938 
     | 
    
         
            +
                  def begin_transaction(*args); end
         
     | 
| 
      
 939 
     | 
    
         
            +
                  def rollback_transaction(*args)
         
     | 
| 
      
 940 
     | 
    
         
            +
                    @rollback_transaction_called = true
         
     | 
| 
      
 941 
     | 
    
         
            +
                  end
         
     | 
| 
      
 942 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 943 
     | 
    
         
            +
             
     | 
| 
      
 944 
     | 
    
         
            +
                connection.pool = Class.new do
         
     | 
| 
      
 945 
     | 
    
         
            +
                  def lock_thread=(lock_thread); end
         
     | 
| 
      
 946 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 947 
     | 
    
         
            +
             
     | 
| 
      
 948 
     | 
    
         
            +
                fire_connection_notification(connection)
         
     | 
| 
      
 949 
     | 
    
         
            +
                teardown_fixtures
         
     | 
| 
      
 950 
     | 
    
         
            +
             
     | 
| 
      
 951 
     | 
    
         
            +
                assert(connection.rollback_transaction_called, "Expected <mock connection>#rollback_transaction to be called but was not")
         
     | 
| 
      
 952 
     | 
    
         
            +
              end
         
     | 
| 
      
 953 
     | 
    
         
            +
             
     | 
| 
      
 954 
     | 
    
         
            +
              def test_transaction_created_on_connection_notification_for_shard
         
     | 
| 
      
 955 
     | 
    
         
            +
                connection = Class.new do
         
     | 
| 
      
 956 
     | 
    
         
            +
                  attr_accessor :pool
         
     | 
| 
      
 957 
     | 
    
         
            +
             
     | 
| 
      
 958 
     | 
    
         
            +
                  def transaction_open?; end
         
     | 
| 
      
 959 
     | 
    
         
            +
                  def begin_transaction(*args); end
         
     | 
| 
      
 960 
     | 
    
         
            +
                  def rollback_transaction(*args); end
         
     | 
| 
      
 961 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 962 
     | 
    
         
            +
             
     | 
| 
      
 963 
     | 
    
         
            +
                connection.pool = Class.new do
         
     | 
| 
      
 964 
     | 
    
         
            +
                  def lock_thread=(lock_thread); end
         
     | 
| 
      
 965 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 966 
     | 
    
         
            +
             
     | 
| 
      
 967 
     | 
    
         
            +
                assert_called_with(connection, :begin_transaction, [joinable: false, _lazy: false]) do
         
     | 
| 
      
 968 
     | 
    
         
            +
                  fire_connection_notification(connection, shard: :shard_two)
         
     | 
| 
      
 969 
     | 
    
         
            +
                end
         
     | 
| 
      
 970 
     | 
    
         
            +
              end
         
     | 
| 
      
 971 
     | 
    
         
            +
             
     | 
| 
      
 972 
     | 
    
         
            +
              private
         
     | 
| 
      
 973 
     | 
    
         
            +
                def fire_connection_notification(connection, shard: ActiveRecord::Base.default_shard)
         
     | 
| 
      
 974 
     | 
    
         
            +
                  assert_called_with(ActiveRecord::Base.connection_handler, :retrieve_connection, ["book", { shard: shard }], returns: connection) do
         
     | 
| 
      
 975 
     | 
    
         
            +
                    message_bus = ActiveSupport::Notifications.instrumenter
         
     | 
| 
      
 976 
     | 
    
         
            +
                    payload = {
         
     | 
| 
      
 977 
     | 
    
         
            +
                      spec_name: "book",
         
     | 
| 
      
 978 
     | 
    
         
            +
                      shard: shard,
         
     | 
| 
      
 979 
     | 
    
         
            +
                      config: nil,
         
     | 
| 
      
 980 
     | 
    
         
            +
                    }
         
     | 
| 
      
 981 
     | 
    
         
            +
             
     | 
| 
      
 982 
     | 
    
         
            +
                    message_bus.instrument("!connection.active_record", payload) { }
         
     | 
| 
      
 983 
     | 
    
         
            +
                  end
         
     | 
| 
      
 984 
     | 
    
         
            +
                end
         
     | 
| 
      
 985 
     | 
    
         
            +
            end
         
     | 
| 
      
 986 
     | 
    
         
            +
             
     | 
| 
      
 987 
     | 
    
         
            +
            class InvalidTableNameFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 988 
     | 
    
         
            +
              fixtures :funny_jokes
         
     | 
| 
      
 989 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 990 
     | 
    
         
            +
              # and thus takes into account our lack of set_fixture_class
         
     | 
| 
      
 991 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 992 
     | 
    
         
            +
             
     | 
| 
      
 993 
     | 
    
         
            +
              def test_raises_error
         
     | 
| 
      
 994 
     | 
    
         
            +
                assert_raise ActiveRecord::FixtureClassNotFound do
         
     | 
| 
      
 995 
     | 
    
         
            +
                  funny_jokes(:a_joke)
         
     | 
| 
      
 996 
     | 
    
         
            +
                end
         
     | 
| 
      
 997 
     | 
    
         
            +
              end
         
     | 
| 
      
 998 
     | 
    
         
            +
            end
         
     | 
| 
      
 999 
     | 
    
         
            +
             
     | 
| 
      
 1000 
     | 
    
         
            +
            class CheckEscapedYamlFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1001 
     | 
    
         
            +
              set_fixture_class funny_jokes: Joke
         
     | 
| 
      
 1002 
     | 
    
         
            +
              fixtures :funny_jokes
         
     | 
| 
      
 1003 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 1004 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
      
 1005 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 1006 
     | 
    
         
            +
             
     | 
| 
      
 1007 
     | 
    
         
            +
              def test_proper_escaped_fixture
         
     | 
| 
      
 1008 
     | 
    
         
            +
                assert_equal "The \\n Aristocrats\nAte the candy\n", funny_jokes(:another_joke).name
         
     | 
| 
      
 1009 
     | 
    
         
            +
              end
         
     | 
| 
      
 1010 
     | 
    
         
            +
            end
         
     | 
| 
      
 1011 
     | 
    
         
            +
             
     | 
| 
      
 1012 
     | 
    
         
            +
            class DevelopersProject; end
         
     | 
| 
      
 1013 
     | 
    
         
            +
            class ManyToManyFixturesWithClassDefined < ActiveRecord::TestCase
         
     | 
| 
      
 1014 
     | 
    
         
            +
              fixtures :developers_projects
         
     | 
| 
      
 1015 
     | 
    
         
            +
             
     | 
| 
      
 1016 
     | 
    
         
            +
              def test_this_should_run_cleanly
         
     | 
| 
      
 1017 
     | 
    
         
            +
                assert true
         
     | 
| 
      
 1018 
     | 
    
         
            +
              end
         
     | 
| 
      
 1019 
     | 
    
         
            +
            end
         
     | 
| 
      
 1020 
     | 
    
         
            +
             
     | 
| 
      
 1021 
     | 
    
         
            +
            class FixturesBrokenRollbackTest < ActiveRecord::TestCase
         
     | 
| 
      
 1022 
     | 
    
         
            +
              def blank_setup
         
     | 
| 
      
 1023 
     | 
    
         
            +
                @fixture_connections = [ActiveRecord::Base.connection]
         
     | 
| 
      
 1024 
     | 
    
         
            +
              end
         
     | 
| 
      
 1025 
     | 
    
         
            +
              alias_method :ar_setup_fixtures, :setup_fixtures
         
     | 
| 
      
 1026 
     | 
    
         
            +
              alias_method :setup_fixtures, :blank_setup
         
     | 
| 
      
 1027 
     | 
    
         
            +
              alias_method :setup, :blank_setup
         
     | 
| 
      
 1028 
     | 
    
         
            +
             
     | 
| 
      
 1029 
     | 
    
         
            +
              def blank_teardown; end
         
     | 
| 
      
 1030 
     | 
    
         
            +
              alias_method :ar_teardown_fixtures, :teardown_fixtures
         
     | 
| 
      
 1031 
     | 
    
         
            +
              alias_method :teardown_fixtures, :blank_teardown
         
     | 
| 
      
 1032 
     | 
    
         
            +
              alias_method :teardown, :blank_teardown
         
     | 
| 
      
 1033 
     | 
    
         
            +
             
     | 
| 
      
 1034 
     | 
    
         
            +
              def test_no_rollback_in_teardown_unless_transaction_active
         
     | 
| 
      
 1035 
     | 
    
         
            +
                assert_equal 0, ActiveRecord::Base.connection.open_transactions
         
     | 
| 
      
 1036 
     | 
    
         
            +
                assert_raise(RuntimeError) { ar_setup_fixtures }
         
     | 
| 
      
 1037 
     | 
    
         
            +
                assert_equal 0, ActiveRecord::Base.connection.open_transactions
         
     | 
| 
      
 1038 
     | 
    
         
            +
                assert_nothing_raised { ar_teardown_fixtures }
         
     | 
| 
      
 1039 
     | 
    
         
            +
                assert_equal 0, ActiveRecord::Base.connection.open_transactions
         
     | 
| 
      
 1040 
     | 
    
         
            +
              end
         
     | 
| 
      
 1041 
     | 
    
         
            +
             
     | 
| 
      
 1042 
     | 
    
         
            +
              private
         
     | 
| 
      
 1043 
     | 
    
         
            +
                def load_fixtures(config)
         
     | 
| 
      
 1044 
     | 
    
         
            +
                  raise "argh"
         
     | 
| 
      
 1045 
     | 
    
         
            +
                end
         
     | 
| 
      
 1046 
     | 
    
         
            +
            end
         
     | 
| 
      
 1047 
     | 
    
         
            +
             
     | 
| 
      
 1048 
     | 
    
         
            +
            class LoadAllFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1049 
     | 
    
         
            +
              def test_all_there
         
     | 
| 
      
 1050 
     | 
    
         
            +
                self.class.fixture_path = FIXTURES_ROOT + "/all"
         
     | 
| 
      
 1051 
     | 
    
         
            +
                self.class.fixtures :all
         
     | 
| 
      
 1052 
     | 
    
         
            +
             
     | 
| 
      
 1053 
     | 
    
         
            +
                if File.symlink? FIXTURES_ROOT + "/all/admin"
         
     | 
| 
      
 1054 
     | 
    
         
            +
                  assert_equal %w(admin/accounts admin/users developers namespaced/accounts people tasks), fixture_table_names.sort
         
     | 
| 
      
 1055 
     | 
    
         
            +
                end
         
     | 
| 
      
 1056 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 1057 
     | 
    
         
            +
                ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
      
 1058 
     | 
    
         
            +
              end
         
     | 
| 
      
 1059 
     | 
    
         
            +
            end
         
     | 
| 
      
 1060 
     | 
    
         
            +
             
     | 
| 
      
 1061 
     | 
    
         
            +
            class LoadAllFixturesWithPathnameTest < ActiveRecord::TestCase
         
     | 
| 
      
 1062 
     | 
    
         
            +
              def test_all_there
         
     | 
| 
      
 1063 
     | 
    
         
            +
                self.class.fixture_path = Pathname.new(FIXTURES_ROOT).join("all")
         
     | 
| 
      
 1064 
     | 
    
         
            +
                self.class.fixtures :all
         
     | 
| 
      
 1065 
     | 
    
         
            +
             
     | 
| 
      
 1066 
     | 
    
         
            +
                if File.symlink? FIXTURES_ROOT + "/all/admin"
         
     | 
| 
      
 1067 
     | 
    
         
            +
                  assert_equal %w(admin/accounts admin/users developers namespaced/accounts people tasks), fixture_table_names.sort
         
     | 
| 
      
 1068 
     | 
    
         
            +
                end
         
     | 
| 
      
 1069 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 1070 
     | 
    
         
            +
                ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
      
 1071 
     | 
    
         
            +
              end
         
     | 
| 
      
 1072 
     | 
    
         
            +
            end
         
     | 
| 
      
 1073 
     | 
    
         
            +
             
     | 
| 
      
 1074 
     | 
    
         
            +
            class FasterFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1075 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 1076 
     | 
    
         
            +
              fixtures :categories, :authors, :author_addresses
         
     | 
| 
      
 1077 
     | 
    
         
            +
             
     | 
| 
      
 1078 
     | 
    
         
            +
              def load_extra_fixture(name)
         
     | 
| 
      
 1079 
     | 
    
         
            +
                fixture = create_fixtures(name).first
         
     | 
| 
      
 1080 
     | 
    
         
            +
                assert fixture.is_a?(ActiveRecord::FixtureSet)
         
     | 
| 
      
 1081 
     | 
    
         
            +
                @loaded_fixtures[fixture.table_name] = fixture
         
     | 
| 
      
 1082 
     | 
    
         
            +
              end
         
     | 
| 
      
 1083 
     | 
    
         
            +
             
     | 
| 
      
 1084 
     | 
    
         
            +
              def test_cache
         
     | 
| 
      
 1085 
     | 
    
         
            +
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection, "categories")
         
     | 
| 
      
 1086 
     | 
    
         
            +
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection, "authors")
         
     | 
| 
      
 1087 
     | 
    
         
            +
             
     | 
| 
      
 1088 
     | 
    
         
            +
                assert_no_queries do
         
     | 
| 
      
 1089 
     | 
    
         
            +
                  create_fixtures("categories")
         
     | 
| 
      
 1090 
     | 
    
         
            +
                  create_fixtures("authors")
         
     | 
| 
      
 1091 
     | 
    
         
            +
                end
         
     | 
| 
      
 1092 
     | 
    
         
            +
             
     | 
| 
      
 1093 
     | 
    
         
            +
                load_extra_fixture("posts")
         
     | 
| 
      
 1094 
     | 
    
         
            +
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection, "posts")
         
     | 
| 
      
 1095 
     | 
    
         
            +
                self.class.setup_fixture_accessors :posts
         
     | 
| 
      
 1096 
     | 
    
         
            +
                assert_equal "Welcome to the weblog", posts(:welcome).title
         
     | 
| 
      
 1097 
     | 
    
         
            +
              end
         
     | 
| 
      
 1098 
     | 
    
         
            +
            end
         
     | 
| 
      
 1099 
     | 
    
         
            +
             
     | 
| 
      
 1100 
     | 
    
         
            +
            class FoxyFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1101 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 1102 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 1103 
     | 
    
         
            +
              fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers,
         
     | 
| 
      
 1104 
     | 
    
         
            +
                       :developers, :"admin/accounts", :"admin/users", :live_parrots, :dead_parrots, :books
         
     | 
| 
      
 1105 
     | 
    
         
            +
             
     | 
| 
      
 1106 
     | 
    
         
            +
              if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
         
     | 
| 
      
 1107 
     | 
    
         
            +
                require "models/uuid_parent"
         
     | 
| 
      
 1108 
     | 
    
         
            +
                require "models/uuid_child"
         
     | 
| 
      
 1109 
     | 
    
         
            +
                fixtures :uuid_parents, :uuid_children
         
     | 
| 
      
 1110 
     | 
    
         
            +
              end
         
     | 
| 
      
 1111 
     | 
    
         
            +
             
     | 
| 
      
 1112 
     | 
    
         
            +
              def test_identifies_strings
         
     | 
| 
      
 1113 
     | 
    
         
            +
                assert_equal(ActiveRecord::FixtureSet.identify("foo"), ActiveRecord::FixtureSet.identify("foo"))
         
     | 
| 
      
 1114 
     | 
    
         
            +
                assert_not_equal(ActiveRecord::FixtureSet.identify("foo"), ActiveRecord::FixtureSet.identify("FOO"))
         
     | 
| 
      
 1115 
     | 
    
         
            +
              end
         
     | 
| 
      
 1116 
     | 
    
         
            +
             
     | 
| 
      
 1117 
     | 
    
         
            +
              def test_identifies_symbols
         
     | 
| 
      
 1118 
     | 
    
         
            +
                assert_equal(ActiveRecord::FixtureSet.identify(:foo), ActiveRecord::FixtureSet.identify(:foo))
         
     | 
| 
      
 1119 
     | 
    
         
            +
              end
         
     | 
| 
      
 1120 
     | 
    
         
            +
             
     | 
| 
      
 1121 
     | 
    
         
            +
              def test_identifies_consistently
         
     | 
| 
      
 1122 
     | 
    
         
            +
                assert_equal 207281424, ActiveRecord::FixtureSet.identify(:ruby)
         
     | 
| 
      
 1123 
     | 
    
         
            +
                assert_equal 1066363776, ActiveRecord::FixtureSet.identify(:sapphire_2)
         
     | 
| 
      
 1124 
     | 
    
         
            +
             
     | 
| 
      
 1125 
     | 
    
         
            +
                assert_equal "f92b6bda-0d0d-5fe1-9124-502b18badded", ActiveRecord::FixtureSet.identify(:daddy, :uuid)
         
     | 
| 
      
 1126 
     | 
    
         
            +
                assert_equal "b4b10018-ad47-595d-b42f-d8bdaa6d01bf", ActiveRecord::FixtureSet.identify(:sonny, :uuid)
         
     | 
| 
      
 1127 
     | 
    
         
            +
              end
         
     | 
| 
      
 1128 
     | 
    
         
            +
             
     | 
| 
      
 1129 
     | 
    
         
            +
              TIMESTAMP_COLUMNS = %w(created_at created_on updated_at updated_on)
         
     | 
| 
      
 1130 
     | 
    
         
            +
             
     | 
| 
      
 1131 
     | 
    
         
            +
              def test_populates_timestamp_columns
         
     | 
| 
      
 1132 
     | 
    
         
            +
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
      
 1133 
     | 
    
         
            +
                  assert_not_nil(parrots(:george).public_send(property), "should set #{property}")
         
     | 
| 
      
 1134 
     | 
    
         
            +
                end
         
     | 
| 
      
 1135 
     | 
    
         
            +
              end
         
     | 
| 
      
 1136 
     | 
    
         
            +
             
     | 
| 
      
 1137 
     | 
    
         
            +
              def test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false
         
     | 
| 
      
 1138 
     | 
    
         
            +
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
      
 1139 
     | 
    
         
            +
                  assert_nil(ships(:black_pearl).public_send(property), "should not set #{property}")
         
     | 
| 
      
 1140 
     | 
    
         
            +
                end
         
     | 
| 
      
 1141 
     | 
    
         
            +
              end
         
     | 
| 
      
 1142 
     | 
    
         
            +
             
     | 
| 
      
 1143 
     | 
    
         
            +
              def test_populates_all_columns_with_the_same_time
         
     | 
| 
      
 1144 
     | 
    
         
            +
                last = nil
         
     | 
| 
      
 1145 
     | 
    
         
            +
             
     | 
| 
      
 1146 
     | 
    
         
            +
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
      
 1147 
     | 
    
         
            +
                  current = parrots(:george).public_send(property)
         
     | 
| 
      
 1148 
     | 
    
         
            +
                  last ||= current
         
     | 
| 
      
 1149 
     | 
    
         
            +
             
     | 
| 
      
 1150 
     | 
    
         
            +
                  assert_equal(last, current)
         
     | 
| 
      
 1151 
     | 
    
         
            +
                  last = current
         
     | 
| 
      
 1152 
     | 
    
         
            +
                end
         
     | 
| 
      
 1153 
     | 
    
         
            +
              end
         
     | 
| 
      
 1154 
     | 
    
         
            +
             
     | 
| 
      
 1155 
     | 
    
         
            +
              def test_only_populates_columns_that_exist
         
     | 
| 
      
 1156 
     | 
    
         
            +
                assert_not_nil(pirates(:blackbeard).created_on)
         
     | 
| 
      
 1157 
     | 
    
         
            +
                assert_not_nil(pirates(:blackbeard).updated_on)
         
     | 
| 
      
 1158 
     | 
    
         
            +
              end
         
     | 
| 
      
 1159 
     | 
    
         
            +
             
     | 
| 
      
 1160 
     | 
    
         
            +
              def test_preserves_existing_fixture_data
         
     | 
| 
      
 1161 
     | 
    
         
            +
                assert_equal(2.weeks.ago.to_date, pirates(:redbeard).created_on.to_date)
         
     | 
| 
      
 1162 
     | 
    
         
            +
                assert_equal(2.weeks.ago.to_date, pirates(:redbeard).updated_on.to_date)
         
     | 
| 
      
 1163 
     | 
    
         
            +
              end
         
     | 
| 
      
 1164 
     | 
    
         
            +
             
     | 
| 
      
 1165 
     | 
    
         
            +
              def test_generates_unique_ids
         
     | 
| 
      
 1166 
     | 
    
         
            +
                assert_not_nil(parrots(:george).id)
         
     | 
| 
      
 1167 
     | 
    
         
            +
                assert_not_equal(parrots(:george).id, parrots(:louis).id)
         
     | 
| 
      
 1168 
     | 
    
         
            +
              end
         
     | 
| 
      
 1169 
     | 
    
         
            +
             
     | 
| 
      
 1170 
     | 
    
         
            +
              def test_automatically_sets_primary_key
         
     | 
| 
      
 1171 
     | 
    
         
            +
                assert_not_nil(ships(:black_pearl))
         
     | 
| 
      
 1172 
     | 
    
         
            +
              end
         
     | 
| 
      
 1173 
     | 
    
         
            +
             
     | 
| 
      
 1174 
     | 
    
         
            +
              def test_preserves_existing_primary_key
         
     | 
| 
      
 1175 
     | 
    
         
            +
                assert_equal(2, ships(:interceptor).id)
         
     | 
| 
      
 1176 
     | 
    
         
            +
              end
         
     | 
| 
      
 1177 
     | 
    
         
            +
             
     | 
| 
      
 1178 
     | 
    
         
            +
              def test_resolves_belongs_to_symbols
         
     | 
| 
      
 1179 
     | 
    
         
            +
                assert_equal(parrots(:george), pirates(:blackbeard).parrot)
         
     | 
| 
      
 1180 
     | 
    
         
            +
              end
         
     | 
| 
      
 1181 
     | 
    
         
            +
             
     | 
| 
      
 1182 
     | 
    
         
            +
              def test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same
         
     | 
| 
      
 1183 
     | 
    
         
            +
                assert_equal(developers(:david), computers(:workstation).developer)
         
     | 
| 
      
 1184 
     | 
    
         
            +
              end
         
     | 
| 
      
 1185 
     | 
    
         
            +
             
     | 
| 
      
 1186 
     | 
    
         
            +
              def test_supports_join_tables
         
     | 
| 
      
 1187 
     | 
    
         
            +
                assert(pirates(:blackbeard).parrots.include?(parrots(:george)))
         
     | 
| 
      
 1188 
     | 
    
         
            +
                assert(pirates(:blackbeard).parrots.include?(parrots(:louis)))
         
     | 
| 
      
 1189 
     | 
    
         
            +
                assert(parrots(:george).pirates.include?(pirates(:blackbeard)))
         
     | 
| 
      
 1190 
     | 
    
         
            +
              end
         
     | 
| 
      
 1191 
     | 
    
         
            +
             
     | 
| 
      
 1192 
     | 
    
         
            +
              def test_supports_inline_habtm
         
     | 
| 
      
 1193 
     | 
    
         
            +
                assert(parrots(:george).treasures.include?(treasures(:diamond)))
         
     | 
| 
      
 1194 
     | 
    
         
            +
                assert(parrots(:george).treasures.include?(treasures(:sapphire)))
         
     | 
| 
      
 1195 
     | 
    
         
            +
                assert_not(parrots(:george).treasures.include?(treasures(:ruby)))
         
     | 
| 
      
 1196 
     | 
    
         
            +
              end
         
     | 
| 
      
 1197 
     | 
    
         
            +
             
     | 
| 
      
 1198 
     | 
    
         
            +
              def test_supports_inline_habtm_with_specified_id
         
     | 
| 
      
 1199 
     | 
    
         
            +
                assert(parrots(:polly).treasures.include?(treasures(:ruby)))
         
     | 
| 
      
 1200 
     | 
    
         
            +
                assert(parrots(:polly).treasures.include?(treasures(:sapphire)))
         
     | 
| 
      
 1201 
     | 
    
         
            +
                assert_not(parrots(:polly).treasures.include?(treasures(:diamond)))
         
     | 
| 
      
 1202 
     | 
    
         
            +
              end
         
     | 
| 
      
 1203 
     | 
    
         
            +
             
     | 
| 
      
 1204 
     | 
    
         
            +
              def test_supports_yaml_arrays
         
     | 
| 
      
 1205 
     | 
    
         
            +
                assert(parrots(:louis).treasures.include?(treasures(:diamond)))
         
     | 
| 
      
 1206 
     | 
    
         
            +
                assert(parrots(:louis).treasures.include?(treasures(:sapphire)))
         
     | 
| 
      
 1207 
     | 
    
         
            +
              end
         
     | 
| 
      
 1208 
     | 
    
         
            +
             
     | 
| 
      
 1209 
     | 
    
         
            +
              def test_strips_DEFAULTS_key
         
     | 
| 
      
 1210 
     | 
    
         
            +
                assert_raise(StandardError) { parrots(:DEFAULTS) }
         
     | 
| 
      
 1211 
     | 
    
         
            +
             
     | 
| 
      
 1212 
     | 
    
         
            +
                # this lets us do YAML defaults and not have an extra fixture entry
         
     | 
| 
      
 1213 
     | 
    
         
            +
                %w(sapphire ruby).each { |t| assert(parrots(:davey).treasures.include?(treasures(t))) }
         
     | 
| 
      
 1214 
     | 
    
         
            +
              end
         
     | 
| 
      
 1215 
     | 
    
         
            +
             
     | 
| 
      
 1216 
     | 
    
         
            +
              def test_supports_label_interpolation
         
     | 
| 
      
 1217 
     | 
    
         
            +
                assert_equal("frederick", parrots(:frederick).name)
         
     | 
| 
      
 1218 
     | 
    
         
            +
              end
         
     | 
| 
      
 1219 
     | 
    
         
            +
             
     | 
| 
      
 1220 
     | 
    
         
            +
              def test_supports_label_string_interpolation
         
     | 
| 
      
 1221 
     | 
    
         
            +
                assert_equal("X marks the spot!", pirates(:mark).catchphrase)
         
     | 
| 
      
 1222 
     | 
    
         
            +
              end
         
     | 
| 
      
 1223 
     | 
    
         
            +
             
     | 
| 
      
 1224 
     | 
    
         
            +
              def test_supports_label_interpolation_for_integer_label
         
     | 
| 
      
 1225 
     | 
    
         
            +
                assert_equal("#1 pirate!", pirates(1).catchphrase)
         
     | 
| 
      
 1226 
     | 
    
         
            +
              end
         
     | 
| 
      
 1227 
     | 
    
         
            +
             
     | 
| 
      
 1228 
     | 
    
         
            +
              def test_supports_polymorphic_belongs_to
         
     | 
| 
      
 1229 
     | 
    
         
            +
                assert_equal(pirates(:redbeard), treasures(:sapphire).looter)
         
     | 
| 
      
 1230 
     | 
    
         
            +
                assert_equal(parrots(:louis), treasures(:ruby).looter)
         
     | 
| 
      
 1231 
     | 
    
         
            +
              end
         
     | 
| 
      
 1232 
     | 
    
         
            +
             
     | 
| 
      
 1233 
     | 
    
         
            +
              def test_only_generates_a_pk_if_necessary
         
     | 
| 
      
 1234 
     | 
    
         
            +
                m = Matey.first
         
     | 
| 
      
 1235 
     | 
    
         
            +
                m.pirate = pirates(:blackbeard)
         
     | 
| 
      
 1236 
     | 
    
         
            +
                m.target = pirates(:redbeard)
         
     | 
| 
      
 1237 
     | 
    
         
            +
              end
         
     | 
| 
      
 1238 
     | 
    
         
            +
             
     | 
| 
      
 1239 
     | 
    
         
            +
              def test_supports_sti
         
     | 
| 
      
 1240 
     | 
    
         
            +
                assert_kind_of DeadParrot, parrots(:polly)
         
     | 
| 
      
 1241 
     | 
    
         
            +
                assert_equal pirates(:blackbeard), parrots(:polly).killer
         
     | 
| 
      
 1242 
     | 
    
         
            +
              end
         
     | 
| 
      
 1243 
     | 
    
         
            +
             
     | 
| 
      
 1244 
     | 
    
         
            +
              def test_supports_sti_with_respective_files
         
     | 
| 
      
 1245 
     | 
    
         
            +
                assert_kind_of LiveParrot, live_parrots(:dusty)
         
     | 
| 
      
 1246 
     | 
    
         
            +
                assert_kind_of DeadParrot, dead_parrots(:deadbird)
         
     | 
| 
      
 1247 
     | 
    
         
            +
                assert_equal pirates(:blackbeard), dead_parrots(:deadbird).killer
         
     | 
| 
      
 1248 
     | 
    
         
            +
              end
         
     | 
| 
      
 1249 
     | 
    
         
            +
             
     | 
| 
      
 1250 
     | 
    
         
            +
              def test_namespaced_models
         
     | 
| 
      
 1251 
     | 
    
         
            +
                assert_includes admin_accounts(:signals37).users, admin_users(:david)
         
     | 
| 
      
 1252 
     | 
    
         
            +
                assert_equal 2, admin_accounts(:signals37).users.size
         
     | 
| 
      
 1253 
     | 
    
         
            +
              end
         
     | 
| 
      
 1254 
     | 
    
         
            +
             
     | 
| 
      
 1255 
     | 
    
         
            +
              def test_resolves_enums
         
     | 
| 
      
 1256 
     | 
    
         
            +
                assert_predicate books(:awdr), :published?
         
     | 
| 
      
 1257 
     | 
    
         
            +
                assert_predicate books(:awdr), :read?
         
     | 
| 
      
 1258 
     | 
    
         
            +
                assert_predicate books(:rfr), :proposed?
         
     | 
| 
      
 1259 
     | 
    
         
            +
                assert_predicate books(:ddd), :published?
         
     | 
| 
      
 1260 
     | 
    
         
            +
              end
         
     | 
| 
      
 1261 
     | 
    
         
            +
            end
         
     | 
| 
      
 1262 
     | 
    
         
            +
             
     | 
| 
      
 1263 
     | 
    
         
            +
            class ActiveSupportSubclassWithFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1264 
     | 
    
         
            +
              fixtures :parrots, :pirates, :parrots_pirates, :treasures
         
     | 
| 
      
 1265 
     | 
    
         
            +
             
     | 
| 
      
 1266 
     | 
    
         
            +
              # This seemingly useless assertion catches a bug that caused the fixtures
         
     | 
| 
      
 1267 
     | 
    
         
            +
              # setup code call nil[]
         
     | 
| 
      
 1268 
     | 
    
         
            +
              def test_foo
         
     | 
| 
      
 1269 
     | 
    
         
            +
                assert_equal parrots(:louis), Parrot.find_by_name("King Louis")
         
     | 
| 
      
 1270 
     | 
    
         
            +
              end
         
     | 
| 
      
 1271 
     | 
    
         
            +
            end
         
     | 
| 
      
 1272 
     | 
    
         
            +
             
     | 
| 
      
 1273 
     | 
    
         
            +
            class CustomNameForFixtureOrModelTest < ActiveRecord::TestCase
         
     | 
| 
      
 1274 
     | 
    
         
            +
              ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
      
 1275 
     | 
    
         
            +
             
     | 
| 
      
 1276 
     | 
    
         
            +
              set_fixture_class :randomly_named_a9 =>
         
     | 
| 
      
 1277 
     | 
    
         
            +
                                    ClassNameThatDoesNotFollowCONVENTIONS,
         
     | 
| 
      
 1278 
     | 
    
         
            +
                                :'admin/randomly_named_a9' =>
         
     | 
| 
      
 1279 
     | 
    
         
            +
                                    Admin::ClassNameThatDoesNotFollowCONVENTIONS1,
         
     | 
| 
      
 1280 
     | 
    
         
            +
                                "admin/randomly_named_b0"  =>
         
     | 
| 
      
 1281 
     | 
    
         
            +
                                    Admin::ClassNameThatDoesNotFollowCONVENTIONS2
         
     | 
| 
      
 1282 
     | 
    
         
            +
             
     | 
| 
      
 1283 
     | 
    
         
            +
              fixtures :randomly_named_a9, "admin/randomly_named_a9",
         
     | 
| 
      
 1284 
     | 
    
         
            +
                       :'admin/randomly_named_b0'
         
     | 
| 
      
 1285 
     | 
    
         
            +
             
     | 
| 
      
 1286 
     | 
    
         
            +
              def test_named_accessor_for_randomly_named_fixture_and_class
         
     | 
| 
      
 1287 
     | 
    
         
            +
                assert_kind_of ClassNameThatDoesNotFollowCONVENTIONS,
         
     | 
| 
      
 1288 
     | 
    
         
            +
                               randomly_named_a9(:first_instance)
         
     | 
| 
      
 1289 
     | 
    
         
            +
              end
         
     | 
| 
      
 1290 
     | 
    
         
            +
             
     | 
| 
      
 1291 
     | 
    
         
            +
              def test_named_accessor_for_randomly_named_namespaced_fixture_and_class
         
     | 
| 
      
 1292 
     | 
    
         
            +
                assert_kind_of Admin::ClassNameThatDoesNotFollowCONVENTIONS1,
         
     | 
| 
      
 1293 
     | 
    
         
            +
                               admin_randomly_named_a9(:first_instance)
         
     | 
| 
      
 1294 
     | 
    
         
            +
                assert_kind_of Admin::ClassNameThatDoesNotFollowCONVENTIONS2,
         
     | 
| 
      
 1295 
     | 
    
         
            +
                               admin_randomly_named_b0(:second_instance)
         
     | 
| 
      
 1296 
     | 
    
         
            +
              end
         
     | 
| 
      
 1297 
     | 
    
         
            +
             
     | 
| 
      
 1298 
     | 
    
         
            +
              def test_table_name_is_defined_in_the_model
         
     | 
| 
      
 1299 
     | 
    
         
            +
                assert_equal "randomly_named_table2", ActiveRecord::FixtureSet.all_loaded_fixtures["admin/randomly_named_a9"].table_name
         
     | 
| 
      
 1300 
     | 
    
         
            +
                assert_equal "randomly_named_table2", Admin::ClassNameThatDoesNotFollowCONVENTIONS1.table_name
         
     | 
| 
      
 1301 
     | 
    
         
            +
              end
         
     | 
| 
      
 1302 
     | 
    
         
            +
            end
         
     | 
| 
      
 1303 
     | 
    
         
            +
             
     | 
| 
      
 1304 
     | 
    
         
            +
            class IgnoreFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1305 
     | 
    
         
            +
              fixtures :other_books, :parrots
         
     | 
| 
      
 1306 
     | 
    
         
            +
             
     | 
| 
      
 1307 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 1308 
     | 
    
         
            +
              # without interfering with other tests that use the same `model_class`.
         
     | 
| 
      
 1309 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 1310 
     | 
    
         
            +
             
     | 
| 
      
 1311 
     | 
    
         
            +
              test "ignores books fixtures" do
         
     | 
| 
      
 1312 
     | 
    
         
            +
                assert_raise(StandardError) { other_books(:published) }
         
     | 
| 
      
 1313 
     | 
    
         
            +
                assert_raise(StandardError) { other_books(:published_paperback) }
         
     | 
| 
      
 1314 
     | 
    
         
            +
                assert_raise(StandardError) { other_books(:published_ebook) }
         
     | 
| 
      
 1315 
     | 
    
         
            +
             
     | 
| 
      
 1316 
     | 
    
         
            +
                assert_equal 2, Book.count
         
     | 
| 
      
 1317 
     | 
    
         
            +
                assert_equal "Agile Web Development with Rails", other_books(:awdr).name
         
     | 
| 
      
 1318 
     | 
    
         
            +
                assert_equal "published", other_books(:awdr).status
         
     | 
| 
      
 1319 
     | 
    
         
            +
                assert_equal "paperback", other_books(:awdr).format
         
     | 
| 
      
 1320 
     | 
    
         
            +
                assert_equal "english", other_books(:awdr).language
         
     | 
| 
      
 1321 
     | 
    
         
            +
             
     | 
| 
      
 1322 
     | 
    
         
            +
                assert_equal "Ruby for Rails", other_books(:rfr).name
         
     | 
| 
      
 1323 
     | 
    
         
            +
                assert_equal "ebook", other_books(:rfr).format
         
     | 
| 
      
 1324 
     | 
    
         
            +
                assert_equal "published", other_books(:rfr).status
         
     | 
| 
      
 1325 
     | 
    
         
            +
              end
         
     | 
| 
      
 1326 
     | 
    
         
            +
             
     | 
| 
      
 1327 
     | 
    
         
            +
              test "ignores parrots fixtures" do
         
     | 
| 
      
 1328 
     | 
    
         
            +
                assert_raise(StandardError) { parrots(:DEFAULT) }
         
     | 
| 
      
 1329 
     | 
    
         
            +
                assert_raise(StandardError) { parrots(:DEAD_PARROT) }
         
     | 
| 
      
 1330 
     | 
    
         
            +
             
     | 
| 
      
 1331 
     | 
    
         
            +
                assert_equal "DeadParrot", parrots(:polly).parrot_sti_class
         
     | 
| 
      
 1332 
     | 
    
         
            +
              end
         
     | 
| 
      
 1333 
     | 
    
         
            +
            end
         
     | 
| 
      
 1334 
     | 
    
         
            +
             
     | 
| 
      
 1335 
     | 
    
         
            +
            class FixturesWithDefaultScopeTest < ActiveRecord::TestCase
         
     | 
| 
      
 1336 
     | 
    
         
            +
              fixtures :bulbs
         
     | 
| 
      
 1337 
     | 
    
         
            +
             
     | 
| 
      
 1338 
     | 
    
         
            +
              test "inserts fixtures excluded by a default scope" do
         
     | 
| 
      
 1339 
     | 
    
         
            +
                assert_equal 1, Bulb.count
         
     | 
| 
      
 1340 
     | 
    
         
            +
                assert_equal 2, Bulb.unscoped.count
         
     | 
| 
      
 1341 
     | 
    
         
            +
              end
         
     | 
| 
      
 1342 
     | 
    
         
            +
             
     | 
| 
      
 1343 
     | 
    
         
            +
              test "allows access to fixtures excluded by a default scope" do
         
     | 
| 
      
 1344 
     | 
    
         
            +
                assert_equal "special", bulbs(:special).name
         
     | 
| 
      
 1345 
     | 
    
         
            +
              end
         
     | 
| 
      
 1346 
     | 
    
         
            +
            end
         
     | 
| 
      
 1347 
     | 
    
         
            +
             
     | 
| 
      
 1348 
     | 
    
         
            +
            class FixturesWithAbstractBelongsTo < ActiveRecord::TestCase
         
     | 
| 
      
 1349 
     | 
    
         
            +
              fixtures :pirates, :doubloons
         
     | 
| 
      
 1350 
     | 
    
         
            +
             
     | 
| 
      
 1351 
     | 
    
         
            +
              test "creates fixtures with belongs_to associations defined in abstract base classes" do
         
     | 
| 
      
 1352 
     | 
    
         
            +
                assert_not_nil doubloons(:blackbeards_doubloon)
         
     | 
| 
      
 1353 
     | 
    
         
            +
                assert_equal pirates(:blackbeard), doubloons(:blackbeards_doubloon).pirate
         
     | 
| 
      
 1354 
     | 
    
         
            +
              end
         
     | 
| 
      
 1355 
     | 
    
         
            +
            end
         
     | 
| 
      
 1356 
     | 
    
         
            +
             
     | 
| 
      
 1357 
     | 
    
         
            +
            class FixtureClassNamesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1358 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 1359 
     | 
    
         
            +
                @saved_cache = fixture_class_names.dup
         
     | 
| 
      
 1360 
     | 
    
         
            +
              end
         
     | 
| 
      
 1361 
     | 
    
         
            +
             
     | 
| 
      
 1362 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 1363 
     | 
    
         
            +
                fixture_class_names.replace(@saved_cache)
         
     | 
| 
      
 1364 
     | 
    
         
            +
              end
         
     | 
| 
      
 1365 
     | 
    
         
            +
             
     | 
| 
      
 1366 
     | 
    
         
            +
              test "fixture_class_names returns nil for unregistered identifier" do
         
     | 
| 
      
 1367 
     | 
    
         
            +
                assert_nil fixture_class_names["unregistered_identifier"]
         
     | 
| 
      
 1368 
     | 
    
         
            +
              end
         
     | 
| 
      
 1369 
     | 
    
         
            +
            end
         
     | 
| 
      
 1370 
     | 
    
         
            +
             
     | 
| 
      
 1371 
     | 
    
         
            +
            class SameNameDifferentDatabaseFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1372 
     | 
    
         
            +
              fixtures :dogs, :other_dogs
         
     | 
| 
      
 1373 
     | 
    
         
            +
             
     | 
| 
      
 1374 
     | 
    
         
            +
              test "fixtures are properly loaded" do
         
     | 
| 
      
 1375 
     | 
    
         
            +
                # Force loading the fixtures again to reproduce issue
         
     | 
| 
      
 1376 
     | 
    
         
            +
                ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
      
 1377 
     | 
    
         
            +
                create_fixtures("dogs", "other_dogs")
         
     | 
| 
      
 1378 
     | 
    
         
            +
             
     | 
| 
      
 1379 
     | 
    
         
            +
                assert_kind_of Dog, dogs(:sophie)
         
     | 
| 
      
 1380 
     | 
    
         
            +
                assert_kind_of OtherDog, other_dogs(:lassie)
         
     | 
| 
      
 1381 
     | 
    
         
            +
              end
         
     | 
| 
      
 1382 
     | 
    
         
            +
            end
         
     | 
| 
      
 1383 
     | 
    
         
            +
             
     | 
| 
      
 1384 
     | 
    
         
            +
            class NilFixturePathTest < ActiveRecord::TestCase
         
     | 
| 
      
 1385 
     | 
    
         
            +
              test "raises an error when all fixtures loaded" do
         
     | 
| 
      
 1386 
     | 
    
         
            +
                error = assert_raises(StandardError) do
         
     | 
| 
      
 1387 
     | 
    
         
            +
                  TestCase = Class.new(ActiveRecord::TestCase)
         
     | 
| 
      
 1388 
     | 
    
         
            +
                  TestCase.class_eval do
         
     | 
| 
      
 1389 
     | 
    
         
            +
                    self.fixture_path = nil
         
     | 
| 
      
 1390 
     | 
    
         
            +
                    fixtures :all
         
     | 
| 
      
 1391 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1392 
     | 
    
         
            +
                end
         
     | 
| 
      
 1393 
     | 
    
         
            +
                assert_equal <<~MSG.squish, error.message
         
     | 
| 
      
 1394 
     | 
    
         
            +
                  No fixture path found.
         
     | 
| 
      
 1395 
     | 
    
         
            +
                  Please set `NilFixturePathTest::TestCase.fixture_path`.
         
     | 
| 
      
 1396 
     | 
    
         
            +
                MSG
         
     | 
| 
      
 1397 
     | 
    
         
            +
              end
         
     | 
| 
      
 1398 
     | 
    
         
            +
            end
         
     | 
| 
      
 1399 
     | 
    
         
            +
             
     | 
| 
      
 1400 
     | 
    
         
            +
            class FileFixtureConflictTest < ActiveRecord::TestCase
         
     | 
| 
      
 1401 
     | 
    
         
            +
              def self.file_fixture_path
         
     | 
| 
      
 1402 
     | 
    
         
            +
                FIXTURES_ROOT + "/all/admin"
         
     | 
| 
      
 1403 
     | 
    
         
            +
              end
         
     | 
| 
      
 1404 
     | 
    
         
            +
             
     | 
| 
      
 1405 
     | 
    
         
            +
              test "ignores file fixtures" do
         
     | 
| 
      
 1406 
     | 
    
         
            +
                self.class.fixture_path = FIXTURES_ROOT + "/all"
         
     | 
| 
      
 1407 
     | 
    
         
            +
                self.class.fixtures :all
         
     | 
| 
      
 1408 
     | 
    
         
            +
             
     | 
| 
      
 1409 
     | 
    
         
            +
                assert_equal %w(developers namespaced/accounts people tasks), fixture_table_names.sort
         
     | 
| 
      
 1410 
     | 
    
         
            +
              end
         
     | 
| 
      
 1411 
     | 
    
         
            +
            end
         
     | 
| 
      
 1412 
     | 
    
         
            +
             
     | 
| 
      
 1413 
     | 
    
         
            +
            if current_adapter?(:SQLite3Adapter) && !in_memory_db?
         
     | 
| 
      
 1414 
     | 
    
         
            +
              class MultipleFixtureConnectionsTest < ActiveRecord::TestCase
         
     | 
| 
      
 1415 
     | 
    
         
            +
                include ActiveRecord::TestFixtures
         
     | 
| 
      
 1416 
     | 
    
         
            +
             
     | 
| 
      
 1417 
     | 
    
         
            +
                fixtures :dogs
         
     | 
| 
      
 1418 
     | 
    
         
            +
             
     | 
| 
      
 1419 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 1420 
     | 
    
         
            +
                  @old_handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1421 
     | 
    
         
            +
                  @prev_configs, ActiveRecord::Base.configurations = ActiveRecord::Base.configurations, config
         
     | 
| 
      
 1422 
     | 
    
         
            +
                  db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(ENV["RAILS_ENV"], "readonly", readonly_config)
         
     | 
| 
      
 1423 
     | 
    
         
            +
             
     | 
| 
      
 1424 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1425 
     | 
    
         
            +
             
     | 
| 
      
 1426 
     | 
    
         
            +
                  handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
         
     | 
| 
      
 1427 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = handler
         
     | 
| 
      
 1428 
     | 
    
         
            +
                  handler.establish_connection(db_config)
         
     | 
| 
      
 1429 
     | 
    
         
            +
             
     | 
| 
      
 1430 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to(database: { writing: :default, reading: :readonly })
         
     | 
| 
      
 1431 
     | 
    
         
            +
             
     | 
| 
      
 1432 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1433 
     | 
    
         
            +
                end
         
     | 
| 
      
 1434 
     | 
    
         
            +
             
     | 
| 
      
 1435 
     | 
    
         
            +
                def teardown
         
     | 
| 
      
 1436 
     | 
    
         
            +
                  ActiveRecord::Base.configurations = @prev_configs
         
     | 
| 
      
 1437 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = @old_handler
         
     | 
| 
      
 1438 
     | 
    
         
            +
                  clean_up_connection_handler
         
     | 
| 
      
 1439 
     | 
    
         
            +
                end
         
     | 
| 
      
 1440 
     | 
    
         
            +
             
     | 
| 
      
 1441 
     | 
    
         
            +
                def test_uses_writing_connection_for_fixtures
         
     | 
| 
      
 1442 
     | 
    
         
            +
                  ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1443 
     | 
    
         
            +
                    Dog.first
         
     | 
| 
      
 1444 
     | 
    
         
            +
             
     | 
| 
      
 1445 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 1446 
     | 
    
         
            +
                      ActiveRecord::Base.connected_to(role: :writing) { Dog.create! alias: "Doggo" }
         
     | 
| 
      
 1447 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1448 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1449 
     | 
    
         
            +
                end
         
     | 
| 
      
 1450 
     | 
    
         
            +
             
     | 
| 
      
 1451 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same
         
     | 
| 
      
 1452 
     | 
    
         
            +
                  handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1453 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing).connection
         
     | 
| 
      
 1454 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading).connection
         
     | 
| 
      
 1455 
     | 
    
         
            +
             
     | 
| 
      
 1456 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1457 
     | 
    
         
            +
             
     | 
| 
      
 1458 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1459 
     | 
    
         
            +
             
     | 
| 
      
 1460 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing).connection
         
     | 
| 
      
 1461 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading).connection
         
     | 
| 
      
 1462 
     | 
    
         
            +
             
     | 
| 
      
 1463 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1464 
     | 
    
         
            +
                end
         
     | 
| 
      
 1465 
     | 
    
         
            +
             
     | 
| 
      
 1466 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same_for_non_default_shards
         
     | 
| 
      
 1467 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1468 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1469 
     | 
    
         
            +
                    two: { writing: :default, reading: :readonly }
         
     | 
| 
      
 1470 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1471 
     | 
    
         
            +
             
     | 
| 
      
 1472 
     | 
    
         
            +
                  handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1473 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing, shard: :two).connection
         
     | 
| 
      
 1474 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading, shard: :two).connection
         
     | 
| 
      
 1475 
     | 
    
         
            +
             
     | 
| 
      
 1476 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1477 
     | 
    
         
            +
             
     | 
| 
      
 1478 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1479 
     | 
    
         
            +
             
     | 
| 
      
 1480 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing, shard: :two).connection
         
     | 
| 
      
 1481 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading, shard: :two).connection
         
     | 
| 
      
 1482 
     | 
    
         
            +
             
     | 
| 
      
 1483 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1484 
     | 
    
         
            +
                end
         
     | 
| 
      
 1485 
     | 
    
         
            +
             
     | 
| 
      
 1486 
     | 
    
         
            +
                def test_only_existing_connections_are_replaced
         
     | 
| 
      
 1487 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1488 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1489 
     | 
    
         
            +
                    two: { writing: :default }
         
     | 
| 
      
 1490 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1491 
     | 
    
         
            +
             
     | 
| 
      
 1492 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1493 
     | 
    
         
            +
             
     | 
| 
      
 1494 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1495 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading, shard: :two) do
         
     | 
| 
      
 1496 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1497 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1498 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1499 
     | 
    
         
            +
                end
         
     | 
| 
      
 1500 
     | 
    
         
            +
             
     | 
| 
      
 1501 
     | 
    
         
            +
                def test_only_existing_connections_are_restored
         
     | 
| 
      
 1502 
     | 
    
         
            +
                  clean_up_connection_handler
         
     | 
| 
      
 1503 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1504 
     | 
    
         
            +
             
     | 
| 
      
 1505 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1506 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1507 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1508 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1509 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1510 
     | 
    
         
            +
                end
         
     | 
| 
      
 1511 
     | 
    
         
            +
             
     | 
| 
      
 1512 
     | 
    
         
            +
                private
         
     | 
| 
      
 1513 
     | 
    
         
            +
                  def config
         
     | 
| 
      
 1514 
     | 
    
         
            +
                    { "default" => default_config, "readonly" => readonly_config }
         
     | 
| 
      
 1515 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1516 
     | 
    
         
            +
             
     | 
| 
      
 1517 
     | 
    
         
            +
                  def default_config
         
     | 
| 
      
 1518 
     | 
    
         
            +
                    { "adapter" => "sqlite3", "database" => "test/fixtures/fixture_database.sqlite3" }
         
     | 
| 
      
 1519 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1520 
     | 
    
         
            +
             
     | 
| 
      
 1521 
     | 
    
         
            +
                  def readonly_config
         
     | 
| 
      
 1522 
     | 
    
         
            +
                    default_config.merge("replica" => true)
         
     | 
| 
      
 1523 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1524 
     | 
    
         
            +
              end
         
     | 
| 
      
 1525 
     | 
    
         
            +
             
     | 
| 
      
 1526 
     | 
    
         
            +
              class MultipleFixtureLegacyConnectionsTest < ActiveRecord::TestCase
         
     | 
| 
      
 1527 
     | 
    
         
            +
                include ActiveRecord::TestFixtures
         
     | 
| 
      
 1528 
     | 
    
         
            +
             
     | 
| 
      
 1529 
     | 
    
         
            +
                fixtures :dogs
         
     | 
| 
      
 1530 
     | 
    
         
            +
             
     | 
| 
      
 1531 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 1532 
     | 
    
         
            +
                  @old_value = ActiveRecord::Base.legacy_connection_handling
         
     | 
| 
      
 1533 
     | 
    
         
            +
                  ActiveRecord::Base.legacy_connection_handling = true
         
     | 
| 
      
 1534 
     | 
    
         
            +
             
     | 
| 
      
 1535 
     | 
    
         
            +
                  @old_handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1536 
     | 
    
         
            +
                  @prev_configs, ActiveRecord::Base.configurations = ActiveRecord::Base.configurations, config
         
     | 
| 
      
 1537 
     | 
    
         
            +
                  db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(ENV["RAILS_ENV"], "readonly", readonly_config)
         
     | 
| 
      
 1538 
     | 
    
         
            +
             
     | 
| 
      
 1539 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1540 
     | 
    
         
            +
             
     | 
| 
      
 1541 
     | 
    
         
            +
                  handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
         
     | 
| 
      
 1542 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = handler
         
     | 
| 
      
 1543 
     | 
    
         
            +
                  handler.establish_connection(db_config)
         
     | 
| 
      
 1544 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handlers = {}
         
     | 
| 
      
 1545 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to(database: { writing: :default, reading: :readonly })
         
     | 
| 
      
 1546 
     | 
    
         
            +
             
     | 
| 
      
 1547 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1548 
     | 
    
         
            +
                end
         
     | 
| 
      
 1549 
     | 
    
         
            +
             
     | 
| 
      
 1550 
     | 
    
         
            +
                def teardown
         
     | 
| 
      
 1551 
     | 
    
         
            +
                  ActiveRecord::Base.configurations = @prev_configs
         
     | 
| 
      
 1552 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = @old_handler
         
     | 
| 
      
 1553 
     | 
    
         
            +
                  clean_up_legacy_connection_handlers
         
     | 
| 
      
 1554 
     | 
    
         
            +
                  ActiveRecord::Base.legacy_connection_handling = false
         
     | 
| 
      
 1555 
     | 
    
         
            +
                end
         
     | 
| 
      
 1556 
     | 
    
         
            +
             
     | 
| 
      
 1557 
     | 
    
         
            +
                def test_uses_writing_connection_for_fixtures
         
     | 
| 
      
 1558 
     | 
    
         
            +
                  ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1559 
     | 
    
         
            +
                    Dog.first
         
     | 
| 
      
 1560 
     | 
    
         
            +
             
     | 
| 
      
 1561 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 1562 
     | 
    
         
            +
                      ActiveRecord::Base.connected_to(role: :writing) { Dog.create! alias: "Doggo" }
         
     | 
| 
      
 1563 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1564 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1565 
     | 
    
         
            +
                end
         
     | 
| 
      
 1566 
     | 
    
         
            +
             
     | 
| 
      
 1567 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same_with_legacy_handling
         
     | 
| 
      
 1568 
     | 
    
         
            +
                  writing = ActiveRecord::Base.connection_handlers[:writing]
         
     | 
| 
      
 1569 
     | 
    
         
            +
                  reading = ActiveRecord::Base.connection_handlers[:reading]
         
     | 
| 
      
 1570 
     | 
    
         
            +
             
     | 
| 
      
 1571 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1572 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1573 
     | 
    
         
            +
             
     | 
| 
      
 1574 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1575 
     | 
    
         
            +
             
     | 
| 
      
 1576 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1577 
     | 
    
         
            +
             
     | 
| 
      
 1578 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1579 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1580 
     | 
    
         
            +
             
     | 
| 
      
 1581 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1582 
     | 
    
         
            +
                end
         
     | 
| 
      
 1583 
     | 
    
         
            +
             
     | 
| 
      
 1584 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same_for_non_default_shards_with_legacy_handling
         
     | 
| 
      
 1585 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1586 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1587 
     | 
    
         
            +
                    two: { writing: :default, reading: :readonly }
         
     | 
| 
      
 1588 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1589 
     | 
    
         
            +
             
     | 
| 
      
 1590 
     | 
    
         
            +
                  writing = ActiveRecord::Base.connection_handlers[:writing]
         
     | 
| 
      
 1591 
     | 
    
         
            +
                  reading = ActiveRecord::Base.connection_handlers[:reading]
         
     | 
| 
      
 1592 
     | 
    
         
            +
             
     | 
| 
      
 1593 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1594 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1595 
     | 
    
         
            +
             
     | 
| 
      
 1596 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1597 
     | 
    
         
            +
             
     | 
| 
      
 1598 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1599 
     | 
    
         
            +
             
     | 
| 
      
 1600 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1601 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1602 
     | 
    
         
            +
             
     | 
| 
      
 1603 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1604 
     | 
    
         
            +
                end
         
     | 
| 
      
 1605 
     | 
    
         
            +
             
     | 
| 
      
 1606 
     | 
    
         
            +
                def test_only_existing_connections_are_replaced
         
     | 
| 
      
 1607 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1608 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1609 
     | 
    
         
            +
                    two: { writing: :default }
         
     | 
| 
      
 1610 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1611 
     | 
    
         
            +
             
     | 
| 
      
 1612 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1613 
     | 
    
         
            +
             
     | 
| 
      
 1614 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1615 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading, shard: :two) do
         
     | 
| 
      
 1616 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1617 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1618 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1619 
     | 
    
         
            +
                end
         
     | 
| 
      
 1620 
     | 
    
         
            +
             
     | 
| 
      
 1621 
     | 
    
         
            +
                def test_only_existing_connections_are_restored
         
     | 
| 
      
 1622 
     | 
    
         
            +
                  clean_up_legacy_connection_handlers
         
     | 
| 
      
 1623 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1624 
     | 
    
         
            +
             
     | 
| 
      
 1625 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1626 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1627 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1628 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1629 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1630 
     | 
    
         
            +
                end
         
     | 
| 
      
 1631 
     | 
    
         
            +
             
     | 
| 
      
 1632 
     | 
    
         
            +
                private
         
     | 
| 
      
 1633 
     | 
    
         
            +
                  def config
         
     | 
| 
      
 1634 
     | 
    
         
            +
                    { "default" => default_config, "readonly" => readonly_config }
         
     | 
| 
      
 1635 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1636 
     | 
    
         
            +
             
     | 
| 
      
 1637 
     | 
    
         
            +
                  def default_config
         
     | 
| 
      
 1638 
     | 
    
         
            +
                    { "adapter" => "sqlite3", "database" => "test/fixtures/fixture_database.sqlite3" }
         
     | 
| 
      
 1639 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1640 
     | 
    
         
            +
             
     | 
| 
      
 1641 
     | 
    
         
            +
                  def readonly_config
         
     | 
| 
      
 1642 
     | 
    
         
            +
                    default_config.merge("replica" => true)
         
     | 
| 
      
 1643 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1644 
     | 
    
         
            +
              end
         
     | 
| 
      
 1645 
     | 
    
         
            +
            end
         
     |