ibm_db 3.0.5-x86-mingw32 → 5.0.5-x86-mingw32
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 +5 -5
 - data/CHANGES +4 -0
 - data/LICENSE +1 -1
 - data/ParameterizedQueries README +6 -6
 - data/README +38 -55
 - data/ext/Makefile +269 -0
 - data/ext/extconf.rb +34 -3
 - data/ext/gil_release_version +3 -0
 - data/ext/ibm_db-i386-mingw32.def +2 -0
 - data/ext/ibm_db.c +100 -108
 - data/ext/ibm_db.o +0 -0
 - data/ext/ibm_db.so +0 -0
 - data/ext/mkmf.log +110 -0
 - data/ext/ruby_ibm_db_cli.o +0 -0
 - data/ext/unicode_support_version +3 -0
 - data/lib/active_record/connection_adapters/ibm_db_adapter.rb +923 -527
 - data/lib/active_record/connection_adapters/ibmdb_adapter.rb +4 -1
 - data/lib/mswin32/ibm_db.rb +7 -39
 - data/lib/mswin32/rb2x/i386/ibm_db.so +0 -0
 - data/test/active_record/connection_adapters/fake_adapter.rb +8 -5
 - data/test/cases/adapter_test.rb +133 -58
 - data/test/cases/adapters/mysql2/active_schema_test.rb +193 -0
 - data/test/cases/adapters/mysql2/bind_parameter_test.rb +50 -0
 - data/test/cases/adapters/mysql2/boolean_test.rb +100 -0
 - data/test/cases/adapters/mysql2/case_sensitivity_test.rb +63 -0
 - data/test/cases/adapters/mysql2/charset_collation_test.rb +54 -0
 - data/test/cases/adapters/mysql2/connection_test.rb +210 -0
 - data/test/cases/adapters/mysql2/datetime_precision_quoting_test.rb +45 -0
 - data/test/cases/adapters/mysql2/enum_test.rb +26 -0
 - data/test/cases/adapters/mysql2/explain_test.rb +21 -0
 - data/test/cases/adapters/mysql2/json_test.rb +195 -0
 - data/test/cases/adapters/mysql2/mysql2_adapter_test.rb +83 -0
 - data/test/cases/adapters/mysql2/reserved_word_test.rb +152 -0
 - data/test/cases/adapters/mysql2/schema_migrations_test.rb +59 -0
 - data/test/cases/adapters/mysql2/schema_test.rb +126 -0
 - data/test/cases/adapters/mysql2/sp_test.rb +36 -0
 - data/test/cases/adapters/mysql2/sql_types_test.rb +14 -0
 - data/test/cases/adapters/mysql2/table_options_test.rb +42 -0
 - data/test/cases/adapters/mysql2/unsigned_type_test.rb +66 -0
 - data/test/cases/adapters/postgresql/active_schema_test.rb +98 -0
 - data/test/cases/adapters/postgresql/array_test.rb +339 -0
 - data/test/cases/adapters/postgresql/bit_string_test.rb +82 -0
 - data/test/cases/adapters/postgresql/bytea_test.rb +134 -0
 - data/test/cases/adapters/postgresql/case_insensitive_test.rb +26 -0
 - data/test/cases/adapters/postgresql/change_schema_test.rb +38 -0
 - data/test/cases/adapters/postgresql/cidr_test.rb +25 -0
 - data/test/cases/adapters/postgresql/citext_test.rb +78 -0
 - data/test/cases/adapters/postgresql/collation_test.rb +53 -0
 - data/test/cases/adapters/postgresql/composite_test.rb +132 -0
 - data/test/cases/adapters/postgresql/connection_test.rb +257 -0
 - data/test/cases/adapters/postgresql/datatype_test.rb +92 -0
 - data/test/cases/adapters/postgresql/domain_test.rb +47 -0
 - data/test/cases/adapters/postgresql/enum_test.rb +91 -0
 - data/test/cases/adapters/postgresql/explain_test.rb +20 -0
 - data/test/cases/adapters/postgresql/extension_migration_test.rb +63 -0
 - data/test/cases/adapters/postgresql/full_text_test.rb +44 -0
 - data/test/cases/adapters/postgresql/geometric_test.rb +378 -0
 - data/test/cases/adapters/postgresql/hstore_test.rb +382 -0
 - data/test/cases/adapters/postgresql/infinity_test.rb +69 -0
 - data/test/cases/adapters/postgresql/integer_test.rb +25 -0
 - data/test/cases/adapters/postgresql/json_test.rb +237 -0
 - data/test/cases/adapters/postgresql/ltree_test.rb +53 -0
 - data/test/cases/adapters/postgresql/money_test.rb +96 -0
 - data/test/cases/adapters/postgresql/network_test.rb +94 -0
 - data/test/cases/adapters/postgresql/numbers_test.rb +49 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_test.rb +405 -0
 - data/test/cases/adapters/postgresql/prepared_statements_test.rb +22 -0
 - data/test/cases/adapters/postgresql/quoting_test.rb +44 -0
 - data/test/cases/adapters/postgresql/range_test.rb +343 -0
 - data/test/cases/adapters/postgresql/referential_integrity_test.rb +111 -0
 - data/test/cases/adapters/postgresql/rename_table_test.rb +34 -0
 - data/test/cases/adapters/postgresql/schema_authorization_test.rb +119 -0
 - data/test/cases/adapters/postgresql/schema_test.rb +597 -0
 - data/test/cases/adapters/postgresql/serial_test.rb +154 -0
 - data/test/cases/adapters/postgresql/statement_pool_test.rb +41 -0
 - data/test/cases/adapters/postgresql/timestamp_test.rb +90 -0
 - data/test/cases/adapters/postgresql/type_lookup_test.rb +33 -0
 - data/test/cases/adapters/postgresql/utils_test.rb +62 -0
 - data/test/cases/adapters/postgresql/uuid_test.rb +294 -0
 - data/test/cases/adapters/postgresql/xml_test.rb +54 -0
 - data/test/cases/adapters/sqlite3/collation_test.rb +53 -0
 - data/test/cases/adapters/sqlite3/copy_table_test.rb +98 -0
 - data/test/cases/adapters/sqlite3/explain_test.rb +21 -0
 - data/test/cases/adapters/sqlite3/quoting_test.rb +101 -0
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +441 -0
 - data/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb +24 -0
 - data/test/cases/adapters/sqlite3/statement_pool_test.rb +20 -0
 - data/test/cases/aggregations_test.rb +11 -1
 - data/test/cases/ar_schema_test.rb +35 -50
 - data/test/cases/associations/association_scope_test.rb +1 -6
 - data/test/cases/associations/belongs_to_associations_test.rb +122 -10
 - data/test/cases/associations/bidirectional_destroy_dependencies_test.rb +41 -0
 - data/test/cases/associations/callbacks_test.rb +5 -7
 - data/test/cases/associations/cascaded_eager_loading_test.rb +1 -1
 - data/test/cases/associations/eager_load_nested_include_test.rb +1 -3
 - data/test/cases/associations/eager_test.rb +158 -73
 - data/test/cases/associations/extension_test.rb +7 -2
 - data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +64 -32
 - data/test/cases/associations/has_many_associations_test.rb +362 -43
 - data/test/cases/associations/has_many_through_associations_test.rb +108 -41
 - data/test/cases/associations/has_one_associations_test.rb +105 -8
 - data/test/cases/associations/has_one_through_associations_test.rb +6 -3
 - data/test/cases/associations/inner_join_association_test.rb +3 -3
 - data/test/cases/associations/inverse_associations_test.rb +38 -11
 - data/test/cases/associations/join_model_test.rb +59 -36
 - data/test/cases/associations/left_outer_join_association_test.rb +88 -0
 - data/test/cases/associations/nested_through_associations_test.rb +2 -2
 - data/test/cases/associations/required_test.rb +25 -5
 - data/test/cases/associations_test.rb +39 -34
 - data/test/cases/attribute_decorators_test.rb +9 -8
 - data/test/cases/attribute_methods/read_test.rb +5 -5
 - data/test/cases/attribute_methods_test.rb +97 -40
 - data/test/cases/attribute_set_test.rb +64 -4
 - data/test/cases/attribute_test.rb +84 -18
 - data/test/cases/attributes_test.rb +151 -34
 - data/test/cases/autosave_association_test.rb +149 -36
 - data/test/cases/base_test.rb +290 -241
 - data/test/cases/batches_test.rb +299 -22
 - data/test/cases/binary_test.rb +2 -10
 - data/test/cases/bind_parameter_test.rb +76 -66
 - data/test/cases/cache_key_test.rb +26 -0
 - data/test/cases/calculations_test.rb +167 -15
 - data/test/cases/callbacks_test.rb +161 -68
 - data/test/cases/coders/json_test.rb +15 -0
 - data/test/cases/collection_cache_key_test.rb +115 -0
 - data/test/cases/column_definition_test.rb +26 -57
 - data/test/cases/comment_test.rb +145 -0
 - data/test/cases/connection_adapters/adapter_leasing_test.rb +5 -3
 - data/test/cases/connection_adapters/connection_handler_test.rb +128 -21
 - data/test/cases/connection_adapters/connection_specification_test.rb +1 -1
 - data/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +0 -38
 - data/test/cases/connection_adapters/mysql_type_lookup_test.rb +5 -1
 - data/test/cases/connection_adapters/schema_cache_test.rb +8 -3
 - data/test/cases/connection_adapters/type_lookup_test.rb +15 -7
 - data/test/cases/connection_management_test.rb +46 -56
 - data/test/cases/connection_pool_test.rb +195 -20
 - data/test/cases/connection_specification/resolver_test.rb +15 -0
 - data/test/cases/counter_cache_test.rb +10 -5
 - data/test/cases/custom_locking_test.rb +1 -1
 - data/test/cases/database_statements_test.rb +18 -3
 - data/test/cases/{invalid_date_test.rb → date_test.rb} +13 -1
 - data/test/cases/date_time_precision_test.rb +107 -0
 - data/test/cases/defaults_test.rb +85 -89
 - data/test/cases/dirty_test.rb +30 -52
 - data/test/cases/disconnected_test.rb +4 -2
 - data/test/cases/enum_test.rb +178 -24
 - data/test/cases/errors_test.rb +16 -0
 - data/test/cases/explain_test.rb +32 -21
 - data/test/cases/finder_test.rb +273 -148
 - data/test/cases/fixture_set/file_test.rb +18 -0
 - data/test/cases/fixtures_test.rb +112 -32
 - data/test/cases/forbidden_attributes_protection_test.rb +69 -3
 - data/test/cases/helper.rb +10 -16
 - data/test/cases/hot_compatibility_test.rb +89 -1
 - data/test/cases/inheritance_test.rb +284 -53
 - data/test/cases/integration_test.rb +23 -7
 - data/test/cases/invalid_connection_test.rb +4 -2
 - data/test/cases/invertible_migration_test.rb +124 -32
 - data/test/cases/json_serialization_test.rb +11 -2
 - data/test/cases/locking_test.rb +22 -6
 - data/test/cases/log_subscriber_test.rb +106 -17
 - data/test/cases/migration/change_schema_test.rb +60 -114
 - data/test/cases/migration/change_table_test.rb +34 -2
 - data/test/cases/migration/column_attributes_test.rb +7 -23
 - data/test/cases/migration/column_positioning_test.rb +8 -8
 - data/test/cases/migration/columns_test.rb +17 -11
 - data/test/cases/migration/command_recorder_test.rb +47 -2
 - data/test/cases/migration/compatibility_test.rb +118 -0
 - data/test/cases/migration/create_join_table_test.rb +21 -12
 - data/test/cases/migration/foreign_key_test.rb +52 -18
 - data/test/cases/migration/index_test.rb +14 -12
 - data/test/cases/migration/logger_test.rb +1 -1
 - data/test/cases/migration/pending_migrations_test.rb +0 -1
 - data/test/cases/migration/references_foreign_key_test.rb +59 -7
 - data/test/cases/migration/references_index_test.rb +4 -4
 - data/test/cases/migration/references_statements_test.rb +26 -6
 - data/test/cases/migration/rename_table_test.rb +25 -25
 - data/test/cases/migration_test.rb +279 -81
 - data/test/cases/migrator_test.rb +91 -8
 - data/test/cases/mixin_test.rb +0 -2
 - data/test/cases/modules_test.rb +3 -4
 - data/test/cases/multiparameter_attributes_test.rb +24 -2
 - data/test/cases/multiple_db_test.rb +11 -4
 - data/test/cases/nested_attributes_test.rb +61 -33
 - data/test/cases/persistence_test.rb +102 -10
 - data/test/cases/pooled_connections_test.rb +3 -3
 - data/test/cases/primary_keys_test.rb +170 -31
 - data/test/cases/query_cache_test.rb +216 -96
 - data/test/cases/quoting_test.rb +65 -19
 - data/test/cases/readonly_test.rb +2 -1
 - data/test/cases/reflection_test.rb +68 -22
 - data/test/cases/relation/delegation_test.rb +3 -8
 - data/test/cases/relation/merging_test.rb +10 -14
 - data/test/cases/relation/mutation_test.rb +42 -24
 - data/test/cases/relation/or_test.rb +92 -0
 - data/test/cases/relation/predicate_builder_test.rb +4 -2
 - data/test/cases/relation/record_fetch_warning_test.rb +40 -0
 - data/test/cases/relation/where_chain_test.rb +23 -99
 - data/test/cases/relation/where_clause_test.rb +182 -0
 - data/test/cases/relation/where_test.rb +45 -23
 - data/test/cases/relation_test.rb +67 -58
 - data/test/cases/relations_test.rb +249 -38
 - data/test/cases/result_test.rb +10 -0
 - data/test/cases/sanitize_test.rb +108 -15
 - data/test/cases/schema_dumper_test.rb +119 -125
 - data/test/cases/schema_loading_test.rb +52 -0
 - data/test/cases/scoping/default_scoping_test.rb +113 -39
 - data/test/cases/scoping/named_scoping_test.rb +46 -9
 - data/test/cases/scoping/relation_scoping_test.rb +47 -4
 - data/test/cases/secure_token_test.rb +32 -0
 - data/test/cases/serialization_test.rb +1 -1
 - data/test/cases/serialized_attribute_test.rb +93 -6
 - data/test/cases/statement_cache_test.rb +38 -0
 - data/test/cases/store_test.rb +2 -1
 - data/test/cases/suppressor_test.rb +63 -0
 - data/test/cases/tasks/database_tasks_test.rb +73 -9
 - data/test/cases/tasks/mysql_rake_test.rb +139 -118
 - data/test/cases/tasks/postgresql_rake_test.rb +60 -6
 - data/test/cases/tasks/sqlite_rake_test.rb +30 -3
 - data/test/cases/test_case.rb +28 -20
 - data/test/cases/test_fixtures_test.rb +36 -0
 - data/test/cases/time_precision_test.rb +103 -0
 - data/test/cases/timestamp_test.rb +44 -10
 - data/test/cases/touch_later_test.rb +121 -0
 - data/test/cases/transaction_callbacks_test.rb +128 -62
 - data/test/cases/transaction_isolation_test.rb +2 -2
 - data/test/cases/transactions_test.rb +61 -43
 - data/test/cases/type/adapter_specific_registry_test.rb +133 -0
 - data/test/cases/type/date_time_test.rb +14 -0
 - data/test/cases/type/integer_test.rb +2 -96
 - data/test/cases/type/string_test.rb +0 -14
 - data/test/cases/type_test.rb +39 -0
 - data/test/cases/types_test.rb +1 -118
 - data/test/cases/unconnected_test.rb +1 -1
 - data/test/cases/validations/absence_validation_test.rb +73 -0
 - data/test/cases/validations/association_validation_test.rb +13 -2
 - data/test/cases/validations/i18n_validation_test.rb +6 -10
 - data/test/cases/validations/length_validation_test.rb +62 -30
 - data/test/cases/validations/presence_validation_test.rb +36 -1
 - data/test/cases/validations/uniqueness_validation_test.rb +128 -37
 - data/test/cases/validations_repair_helper.rb +2 -6
 - data/test/cases/validations_test.rb +36 -7
 - data/test/cases/view_test.rb +102 -5
 - data/test/cases/yaml_serialization_test.rb +21 -26
 - data/test/config.example.yml +97 -0
 - data/test/fixtures/bad_posts.yml +9 -0
 - data/test/fixtures/books.yml +20 -0
 - data/test/fixtures/content.yml +3 -0
 - data/test/fixtures/content_positions.yml +3 -0
 - data/test/fixtures/dead_parrots.yml +5 -0
 - data/test/fixtures/live_parrots.yml +4 -0
 - data/test/fixtures/naked/yml/parrots.yml +2 -0
 - data/test/fixtures/naked/yml/trees.yml +3 -0
 - data/test/fixtures/nodes.yml +29 -0
 - data/test/fixtures/other_comments.yml +6 -0
 - data/test/fixtures/other_dogs.yml +2 -0
 - data/test/fixtures/other_posts.yml +7 -0
 - data/test/fixtures/price_estimates.yml +10 -1
 - data/test/fixtures/trees.yml +3 -0
 - data/test/migrations/10_urban/9_add_expressions.rb +1 -1
 - data/test/migrations/decimal/1_give_me_big_numbers.rb +1 -1
 - data/test/migrations/magic/1_currencies_have_symbols.rb +1 -1
 - data/test/migrations/missing/1000_people_have_middle_names.rb +2 -2
 - data/test/migrations/missing/1_people_have_last_names.rb +2 -2
 - data/test/migrations/missing/3_we_need_reminders.rb +2 -2
 - data/test/migrations/missing/4_innocent_jointable.rb +2 -2
 - data/test/migrations/rename/1_we_need_things.rb +2 -2
 - data/test/migrations/rename/2_rename_things.rb +2 -2
 - data/test/migrations/to_copy/1_people_have_hobbies.rb +1 -1
 - data/test/migrations/to_copy/2_people_have_descriptions.rb +1 -1
 - data/test/migrations/to_copy2/1_create_articles.rb +1 -1
 - data/test/migrations/to_copy2/2_create_comments.rb +1 -1
 - data/test/migrations/to_copy_with_name_collision/1_people_have_hobbies.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps/20090101010101_people_have_hobbies.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps/20090101010202_people_have_descriptions.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb +1 -1
 - data/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb +1 -1
 - data/test/migrations/valid/1_valid_people_have_last_names.rb +1 -1
 - data/test/migrations/valid/2_we_need_reminders.rb +2 -2
 - data/test/migrations/valid/3_innocent_jointable.rb +2 -2
 - data/test/migrations/valid_with_subdirectories/1_valid_people_have_last_names.rb +1 -1
 - data/test/migrations/valid_with_subdirectories/sub/2_we_need_reminders.rb +2 -2
 - data/test/migrations/valid_with_subdirectories/sub1/3_innocent_jointable.rb +2 -2
 - data/test/migrations/valid_with_timestamps/20100101010101_valid_with_timestamps_people_have_last_names.rb +1 -1
 - data/test/migrations/valid_with_timestamps/20100201010101_valid_with_timestamps_we_need_reminders.rb +1 -1
 - data/test/migrations/valid_with_timestamps/20100301010101_valid_with_timestamps_innocent_jointable.rb +1 -1
 - data/test/migrations/version_check/20131219224947_migration_version_check.rb +1 -1
 - data/test/models/admin/randomly_named_c1.rb +6 -2
 - data/test/models/aircraft.rb +1 -0
 - data/test/models/author.rb +4 -7
 - data/test/models/bird.rb +1 -1
 - data/test/models/book.rb +5 -0
 - data/test/models/bulb.rb +2 -1
 - data/test/models/car.rb +3 -0
 - data/test/models/cat.rb +10 -0
 - data/test/models/chef.rb +1 -0
 - data/test/models/club.rb +2 -0
 - data/test/models/comment.rb +17 -5
 - data/test/models/company.rb +4 -2
 - data/test/models/company_in_module.rb +1 -1
 - data/test/models/contact.rb +1 -1
 - data/test/models/content.rb +40 -0
 - data/test/models/customer.rb +8 -2
 - data/test/models/developer.rb +19 -0
 - data/test/models/face.rb +1 -1
 - data/test/models/guitar.rb +4 -0
 - data/test/models/hotel.rb +2 -0
 - data/test/models/member.rb +1 -0
 - data/test/models/member_detail.rb +4 -3
 - data/test/models/mentor.rb +3 -0
 - data/test/models/mocktail_designer.rb +2 -0
 - data/test/models/node.rb +5 -0
 - data/test/models/non_primary_key.rb +2 -0
 - data/test/models/notification.rb +3 -0
 - data/test/models/other_dog.rb +5 -0
 - data/test/models/owner.rb +4 -1
 - data/test/models/parrot.rb +6 -7
 - data/test/models/person.rb +0 -1
 - data/test/models/pet.rb +3 -0
 - data/test/models/pet_treasure.rb +6 -0
 - data/test/models/pirate.rb +3 -3
 - data/test/models/post.rb +18 -9
 - data/test/models/project.rb +9 -0
 - data/test/models/randomly_named_c1.rb +1 -1
 - data/test/models/recipe.rb +3 -0
 - data/test/models/ship.rb +8 -2
 - data/test/models/tag.rb +6 -0
 - data/test/models/topic.rb +2 -8
 - data/test/models/tree.rb +3 -0
 - data/test/models/tuning_peg.rb +4 -0
 - data/test/models/user.rb +14 -0
 - data/test/models/uuid_item.rb +6 -0
 - data/test/schema/mysql2_specific_schema.rb +33 -23
 - data/test/schema/oracle_specific_schema.rb +1 -4
 - data/test/schema/postgresql_specific_schema.rb +36 -124
 - data/test/schema/schema.rb +170 -65
 - data/test/schema/schema.rb.original +1057 -0
 - data/test/schema/sqlite_specific_schema.rb +1 -5
 - data/test/support/connection.rb +1 -0
 - data/test/support/schema_dumping_helper.rb +1 -1
 - 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
 - metadata +146 -30
 - data/lib/mswin32/rb19x/ibm_db.so +0 -0
 - data/lib/mswin32/rb21x/i386/ibm_db.so +0 -0
 - data/lib/mswin32/rb22x/i386/ibm_db.so +0 -0
 - data/lib/mswin32/rb23x/i386/ibm_db.so +0 -0
 - data/test/cases/associations/deprecated_counter_cache_on_has_many_through_test.rb +0 -26
 - data/test/cases/attribute_methods/serialization_test.rb +0 -29
 - data/test/cases/migration/change_schema_test - Copy.rb +0 -448
 - data/test/cases/migration/foreign_key_test - Changed.rb +0 -325
 - data/test/cases/migration/table_and_index_test.rb +0 -24
 - data/test/cases/relation/where_test2.rb +0 -36
 - data/test/cases/type/decimal_test.rb +0 -56
 - data/test/cases/type/unsigned_integer_test.rb +0 -18
 - data/test/cases/xml_serialization_test.rb +0 -457
 - data/test/fixtures/naked/csv/accounts.csv +0 -1
 - data/test/schema/mysql_specific_schema.rb +0 -70
 
| 
         @@ -24,6 +24,8 @@ require 'models/molecule' 
     | 
|
| 
       24 
24 
     | 
    
         
             
            require 'models/member'
         
     | 
| 
       25 
25 
     | 
    
         
             
            require 'models/member_detail'
         
     | 
| 
       26 
26 
     | 
    
         
             
            require 'models/organization'
         
     | 
| 
      
 27 
     | 
    
         
            +
            require 'models/guitar'
         
     | 
| 
      
 28 
     | 
    
         
            +
            require 'models/tuning_peg'
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
       28 
30 
     | 
    
         
             
            class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase
         
     | 
| 
       29 
31 
     | 
    
         
             
              def test_autosave_validation
         
     | 
| 
         @@ -67,6 +69,14 @@ class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase 
     | 
|
| 
       67 
69 
     | 
    
         
             
                assert_no_difference_when_adding_callbacks_twice_for Pirate, :parrots
         
     | 
| 
       68 
70 
     | 
    
         
             
              end
         
     | 
| 
       69 
71 
     | 
    
         | 
| 
      
 72 
     | 
    
         
            +
              def test_cyclic_autosaves_do_not_add_multiple_validations
         
     | 
| 
      
 73 
     | 
    
         
            +
                ship = ShipWithoutNestedAttributes.new
         
     | 
| 
      
 74 
     | 
    
         
            +
                ship.prisoners.build
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                assert_not ship.valid?
         
     | 
| 
      
 77 
     | 
    
         
            +
                assert_equal 1, ship.errors[:name].length
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
       70 
80 
     | 
    
         
             
              private
         
     | 
| 
       71 
81 
     | 
    
         | 
| 
       72 
82 
     | 
    
         
             
              def assert_no_difference_when_adding_callbacks_twice_for(model, association_name)
         
     | 
| 
         @@ -149,7 +159,8 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCas 
     | 
|
| 
       149 
159 
     | 
    
         
             
                assert_equal a, firm.account
         
     | 
| 
       150 
160 
     | 
    
         
             
                assert firm.save
         
     | 
| 
       151 
161 
     | 
    
         
             
                assert_equal a, firm.account
         
     | 
| 
       152 
     | 
    
         
            -
                 
     | 
| 
      
 162 
     | 
    
         
            +
                firm.association(:account).reload
         
     | 
| 
      
 163 
     | 
    
         
            +
                assert_equal a, firm.account
         
     | 
| 
       153 
164 
     | 
    
         
             
              end
         
     | 
| 
       154 
165 
     | 
    
         | 
| 
       155 
166 
     | 
    
         
             
              def test_assignment_before_either_saved
         
     | 
| 
         @@ -162,7 +173,8 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCas 
     | 
|
| 
       162 
173 
     | 
    
         
             
                assert firm.persisted?
         
     | 
| 
       163 
174 
     | 
    
         
             
                assert a.persisted?
         
     | 
| 
       164 
175 
     | 
    
         
             
                assert_equal a, firm.account
         
     | 
| 
       165 
     | 
    
         
            -
                 
     | 
| 
      
 176 
     | 
    
         
            +
                firm.association(:account).reload
         
     | 
| 
      
 177 
     | 
    
         
            +
                assert_equal a, firm.account
         
     | 
| 
       166 
178 
     | 
    
         
             
              end
         
     | 
| 
       167 
179 
     | 
    
         | 
| 
       168 
180 
     | 
    
         
             
              def test_not_resaved_when_unchanged
         
     | 
| 
         @@ -248,7 +260,8 @@ class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::Test 
     | 
|
| 
       248 
260 
     | 
    
         
             
                assert apple.save
         
     | 
| 
       249 
261 
     | 
    
         
             
                assert apple.persisted?
         
     | 
| 
       250 
262 
     | 
    
         
             
                assert_equal apple, client.firm
         
     | 
| 
       251 
     | 
    
         
            -
                 
     | 
| 
      
 263 
     | 
    
         
            +
                client.association(:firm).reload
         
     | 
| 
      
 264 
     | 
    
         
            +
                assert_equal apple, client.firm
         
     | 
| 
       252 
265 
     | 
    
         
             
              end
         
     | 
| 
       253 
266 
     | 
    
         | 
| 
       254 
267 
     | 
    
         
             
              def test_assignment_before_either_saved
         
     | 
| 
         @@ -261,7 +274,8 @@ class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::Test 
     | 
|
| 
       261 
274 
     | 
    
         
             
                assert final_cut.persisted?
         
     | 
| 
       262 
275 
     | 
    
         
             
                assert apple.persisted?
         
     | 
| 
       263 
276 
     | 
    
         
             
                assert_equal apple, final_cut.firm
         
     | 
| 
       264 
     | 
    
         
            -
                 
     | 
| 
      
 277 
     | 
    
         
            +
                final_cut.association(:firm).reload
         
     | 
| 
      
 278 
     | 
    
         
            +
                assert_equal apple, final_cut.firm
         
     | 
| 
       265 
279 
     | 
    
         
             
              end
         
     | 
| 
       266 
280 
     | 
    
         | 
| 
       267 
281 
     | 
    
         
             
              def test_store_two_association_with_one_save
         
     | 
| 
         @@ -385,6 +399,87 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociationWithAcceptsNestedAttrib 
     | 
|
| 
       385 
399 
     | 
    
         
             
                assert_not molecule.persisted?, 'Molecule should not be persisted when its electrons are invalid'
         
     | 
| 
       386 
400 
     | 
    
         
             
              end
         
     | 
| 
       387 
401 
     | 
    
         | 
| 
      
 402 
     | 
    
         
            +
              def test_errors_should_be_indexed_when_passed_as_array
         
     | 
| 
      
 403 
     | 
    
         
            +
                guitar = Guitar.new
         
     | 
| 
      
 404 
     | 
    
         
            +
                tuning_peg_valid = TuningPeg.new
         
     | 
| 
      
 405 
     | 
    
         
            +
                tuning_peg_valid.pitch = 440.0
         
     | 
| 
      
 406 
     | 
    
         
            +
                tuning_peg_invalid = TuningPeg.new
         
     | 
| 
      
 407 
     | 
    
         
            +
             
     | 
| 
      
 408 
     | 
    
         
            +
                guitar.tuning_pegs = [tuning_peg_valid, tuning_peg_invalid]
         
     | 
| 
      
 409 
     | 
    
         
            +
             
     | 
| 
      
 410 
     | 
    
         
            +
                assert_not tuning_peg_invalid.valid?
         
     | 
| 
      
 411 
     | 
    
         
            +
                assert tuning_peg_valid.valid?
         
     | 
| 
      
 412 
     | 
    
         
            +
                assert_not guitar.valid?
         
     | 
| 
      
 413 
     | 
    
         
            +
                assert_equal ["is not a number"], guitar.errors["tuning_pegs[1].pitch"]
         
     | 
| 
      
 414 
     | 
    
         
            +
                assert_not_equal ["is not a number"], guitar.errors["tuning_pegs.pitch"]
         
     | 
| 
      
 415 
     | 
    
         
            +
              end
         
     | 
| 
      
 416 
     | 
    
         
            +
             
     | 
| 
      
 417 
     | 
    
         
            +
              def test_errors_should_be_indexed_when_global_flag_is_set
         
     | 
| 
      
 418 
     | 
    
         
            +
                old_attribute_config = ActiveRecord::Base.index_nested_attribute_errors
         
     | 
| 
      
 419 
     | 
    
         
            +
                ActiveRecord::Base.index_nested_attribute_errors = true
         
     | 
| 
      
 420 
     | 
    
         
            +
             
     | 
| 
      
 421 
     | 
    
         
            +
                molecule = Molecule.new
         
     | 
| 
      
 422 
     | 
    
         
            +
                valid_electron = Electron.new(name: 'electron')
         
     | 
| 
      
 423 
     | 
    
         
            +
                invalid_electron = Electron.new
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
                molecule.electrons = [valid_electron, invalid_electron]
         
     | 
| 
      
 426 
     | 
    
         
            +
             
     | 
| 
      
 427 
     | 
    
         
            +
                assert_not invalid_electron.valid?
         
     | 
| 
      
 428 
     | 
    
         
            +
                assert valid_electron.valid?
         
     | 
| 
      
 429 
     | 
    
         
            +
                assert_not molecule.valid?
         
     | 
| 
      
 430 
     | 
    
         
            +
                assert_equal ["can't be blank"], molecule.errors["electrons[1].name"]
         
     | 
| 
      
 431 
     | 
    
         
            +
                assert_not_equal ["can't be blank"], molecule.errors["electrons.name"]
         
     | 
| 
      
 432 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 433 
     | 
    
         
            +
                ActiveRecord::Base.index_nested_attribute_errors = old_attribute_config
         
     | 
| 
      
 434 
     | 
    
         
            +
              end
         
     | 
| 
      
 435 
     | 
    
         
            +
             
     | 
| 
      
 436 
     | 
    
         
            +
              def test_errors_details_should_be_set
         
     | 
| 
      
 437 
     | 
    
         
            +
                molecule = Molecule.new
         
     | 
| 
      
 438 
     | 
    
         
            +
                valid_electron = Electron.new(name: 'electron')
         
     | 
| 
      
 439 
     | 
    
         
            +
                invalid_electron = Electron.new
         
     | 
| 
      
 440 
     | 
    
         
            +
             
     | 
| 
      
 441 
     | 
    
         
            +
                molecule.electrons = [valid_electron, invalid_electron]
         
     | 
| 
      
 442 
     | 
    
         
            +
             
     | 
| 
      
 443 
     | 
    
         
            +
                assert_not invalid_electron.valid?
         
     | 
| 
      
 444 
     | 
    
         
            +
                assert valid_electron.valid?
         
     | 
| 
      
 445 
     | 
    
         
            +
                assert_not molecule.valid?
         
     | 
| 
      
 446 
     | 
    
         
            +
                assert_equal [{ error: :blank }], molecule.errors.details[:"electrons.name"]
         
     | 
| 
      
 447 
     | 
    
         
            +
              end
         
     | 
| 
      
 448 
     | 
    
         
            +
             
     | 
| 
      
 449 
     | 
    
         
            +
              def test_errors_details_should_be_indexed_when_passed_as_array
         
     | 
| 
      
 450 
     | 
    
         
            +
                guitar = Guitar.new
         
     | 
| 
      
 451 
     | 
    
         
            +
                tuning_peg_valid = TuningPeg.new
         
     | 
| 
      
 452 
     | 
    
         
            +
                tuning_peg_valid.pitch = 440.0
         
     | 
| 
      
 453 
     | 
    
         
            +
                tuning_peg_invalid = TuningPeg.new
         
     | 
| 
      
 454 
     | 
    
         
            +
             
     | 
| 
      
 455 
     | 
    
         
            +
                guitar.tuning_pegs = [tuning_peg_valid, tuning_peg_invalid]
         
     | 
| 
      
 456 
     | 
    
         
            +
             
     | 
| 
      
 457 
     | 
    
         
            +
                assert_not tuning_peg_invalid.valid?
         
     | 
| 
      
 458 
     | 
    
         
            +
                assert tuning_peg_valid.valid?
         
     | 
| 
      
 459 
     | 
    
         
            +
                assert_not guitar.valid?
         
     | 
| 
      
 460 
     | 
    
         
            +
                assert_equal [{ error: :not_a_number, value: nil }], guitar.errors.details[:"tuning_pegs[1].pitch"]
         
     | 
| 
      
 461 
     | 
    
         
            +
                assert_equal [], guitar.errors.details[:"tuning_pegs.pitch"]
         
     | 
| 
      
 462 
     | 
    
         
            +
              end
         
     | 
| 
      
 463 
     | 
    
         
            +
             
     | 
| 
      
 464 
     | 
    
         
            +
              def test_errors_details_should_be_indexed_when_global_flag_is_set
         
     | 
| 
      
 465 
     | 
    
         
            +
                old_attribute_config = ActiveRecord::Base.index_nested_attribute_errors
         
     | 
| 
      
 466 
     | 
    
         
            +
                ActiveRecord::Base.index_nested_attribute_errors = true
         
     | 
| 
      
 467 
     | 
    
         
            +
             
     | 
| 
      
 468 
     | 
    
         
            +
                molecule = Molecule.new
         
     | 
| 
      
 469 
     | 
    
         
            +
                valid_electron = Electron.new(name: 'electron')
         
     | 
| 
      
 470 
     | 
    
         
            +
                invalid_electron = Electron.new
         
     | 
| 
      
 471 
     | 
    
         
            +
             
     | 
| 
      
 472 
     | 
    
         
            +
                molecule.electrons = [valid_electron, invalid_electron]
         
     | 
| 
      
 473 
     | 
    
         
            +
             
     | 
| 
      
 474 
     | 
    
         
            +
                assert_not invalid_electron.valid?
         
     | 
| 
      
 475 
     | 
    
         
            +
                assert valid_electron.valid?
         
     | 
| 
      
 476 
     | 
    
         
            +
                assert_not molecule.valid?
         
     | 
| 
      
 477 
     | 
    
         
            +
                assert_equal [{ error: :blank }], molecule.errors.details[:"electrons[1].name"]
         
     | 
| 
      
 478 
     | 
    
         
            +
                assert_equal [], molecule.errors.details[:"electrons.name"]
         
     | 
| 
      
 479 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 480 
     | 
    
         
            +
                ActiveRecord::Base.index_nested_attribute_errors = old_attribute_config
         
     | 
| 
      
 481 
     | 
    
         
            +
              end
         
     | 
| 
      
 482 
     | 
    
         
            +
             
     | 
| 
       388 
483 
     | 
    
         
             
              def test_valid_adding_with_nested_attributes
         
     | 
| 
       389 
484 
     | 
    
         
             
                molecule = Molecule.new
         
     | 
| 
       390 
485 
     | 
    
         
             
                valid_electron = Electron.new(name: 'electron')
         
     | 
| 
         @@ -456,7 +551,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa 
     | 
|
| 
       456 
551 
     | 
    
         
             
                assert_equal new_client, companies(:first_firm).clients_of_firm.last
         
     | 
| 
       457 
552 
     | 
    
         
             
                assert !companies(:first_firm).save
         
     | 
| 
       458 
553 
     | 
    
         
             
                assert !new_client.persisted?
         
     | 
| 
       459 
     | 
    
         
            -
                assert_equal 2, companies(:first_firm).clients_of_firm 
     | 
| 
      
 554 
     | 
    
         
            +
                assert_equal 2, companies(:first_firm).clients_of_firm.reload.size
         
     | 
| 
       460 
555 
     | 
    
         
             
              end
         
     | 
| 
       461 
556 
     | 
    
         | 
| 
       462 
557 
     | 
    
         
             
              def test_adding_before_save
         
     | 
| 
         @@ -481,7 +576,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa 
     | 
|
| 
       481 
576 
     | 
    
         
             
                assert_equal no_of_clients + 2, Client.count  # Clients were saved to database.
         
     | 
| 
       482 
577 
     | 
    
         | 
| 
       483 
578 
     | 
    
         
             
                assert_equal 2, new_firm.clients_of_firm.size
         
     | 
| 
       484 
     | 
    
         
            -
                assert_equal 2, new_firm.clients_of_firm 
     | 
| 
      
 579 
     | 
    
         
            +
                assert_equal 2, new_firm.clients_of_firm.reload.size
         
     | 
| 
       485 
580 
     | 
    
         
             
              end
         
     | 
| 
       486 
581 
     | 
    
         | 
| 
       487 
582 
     | 
    
         
             
              def test_assign_ids
         
     | 
| 
         @@ -510,7 +605,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa 
     | 
|
| 
       510 
605 
     | 
    
         
             
                company.name += '-changed'
         
     | 
| 
       511 
606 
     | 
    
         
             
                assert_queries(2) { assert company.save }
         
     | 
| 
       512 
607 
     | 
    
         
             
                assert new_client.persisted?
         
     | 
| 
       513 
     | 
    
         
            -
                assert_equal 3, company.clients_of_firm 
     | 
| 
      
 608 
     | 
    
         
            +
                assert_equal 3, company.clients_of_firm.reload.size
         
     | 
| 
       514 
609 
     | 
    
         
             
              end
         
     | 
| 
       515 
610 
     | 
    
         | 
| 
       516 
611 
     | 
    
         
             
              def test_build_many_before_save
         
     | 
| 
         @@ -519,7 +614,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa 
     | 
|
| 
       519 
614 
     | 
    
         | 
| 
       520 
615 
     | 
    
         
             
                company.name += '-changed'
         
     | 
| 
       521 
616 
     | 
    
         
             
                assert_queries(3) { assert company.save }
         
     | 
| 
       522 
     | 
    
         
            -
                assert_equal 4, company.clients_of_firm 
     | 
| 
      
 617 
     | 
    
         
            +
                assert_equal 4, company.clients_of_firm.reload.size
         
     | 
| 
       523 
618 
     | 
    
         
             
              end
         
     | 
| 
       524 
619 
     | 
    
         | 
| 
       525 
620 
     | 
    
         
             
              def test_build_via_block_before_save
         
     | 
| 
         @@ -530,7 +625,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa 
     | 
|
| 
       530 
625 
     | 
    
         
             
                company.name += '-changed'
         
     | 
| 
       531 
626 
     | 
    
         
             
                assert_queries(2) { assert company.save }
         
     | 
| 
       532 
627 
     | 
    
         
             
                assert new_client.persisted?
         
     | 
| 
       533 
     | 
    
         
            -
                assert_equal 3, company.clients_of_firm 
     | 
| 
      
 628 
     | 
    
         
            +
                assert_equal 3, company.clients_of_firm.reload.size
         
     | 
| 
       534 
629 
     | 
    
         
             
              end
         
     | 
| 
       535 
630 
     | 
    
         | 
| 
       536 
631 
     | 
    
         
             
              def test_build_many_via_block_before_save
         
     | 
| 
         @@ -543,7 +638,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa 
     | 
|
| 
       543 
638 
     | 
    
         | 
| 
       544 
639 
     | 
    
         
             
                company.name += '-changed'
         
     | 
| 
       545 
640 
     | 
    
         
             
                assert_queries(3) { assert company.save }
         
     | 
| 
       546 
     | 
    
         
            -
                assert_equal 4, company.clients_of_firm 
     | 
| 
      
 641 
     | 
    
         
            +
                assert_equal 4, company.clients_of_firm.reload.size
         
     | 
| 
       547 
642 
     | 
    
         
             
              end
         
     | 
| 
       548 
643 
     | 
    
         | 
| 
       549 
644 
     | 
    
         
             
              def test_replace_on_new_object
         
     | 
| 
         @@ -629,7 +724,7 @@ class TestDefaultAutosaveAssociationOnNewRecord < ActiveRecord::TestCase 
     | 
|
| 
       629 
724 
     | 
    
         
             
            end
         
     | 
| 
       630 
725 
     | 
    
         | 
| 
       631 
726 
     | 
    
         
             
            class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
         
     | 
| 
       632 
     | 
    
         
            -
              self. 
     | 
| 
      
 727 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
       633 
728 
     | 
    
         | 
| 
       634 
729 
     | 
    
         
             
              setup do
         
     | 
| 
       635 
730 
     | 
    
         
             
                @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?")
         
     | 
| 
         @@ -637,7 +732,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       637 
732 
     | 
    
         
             
              end
         
     | 
| 
       638 
733 
     | 
    
         | 
| 
       639 
734 
     | 
    
         
             
              teardown do
         
     | 
| 
       640 
     | 
    
         
            -
                # We are running without transactional  
     | 
| 
      
 735 
     | 
    
         
            +
                # We are running without transactional tests and need to cleanup.
         
     | 
| 
       641 
736 
     | 
    
         
             
                Bird.delete_all
         
     | 
| 
       642 
737 
     | 
    
         
             
                Parrot.delete_all
         
     | 
| 
       643 
738 
     | 
    
         
             
                @ship.delete
         
     | 
| 
         @@ -654,7 +749,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       654 
749 
     | 
    
         
             
              end
         
     | 
| 
       655 
750 
     | 
    
         | 
| 
       656 
751 
     | 
    
         
             
              # has_one
         
     | 
| 
       657 
     | 
    
         
            -
              def  
     | 
| 
      
 752 
     | 
    
         
            +
              def test_should_destroy_a_child_association_as_part_of_the_save_transaction_if_it_was_marked_for_destruction
         
     | 
| 
       658 
753 
     | 
    
         
             
                assert !@pirate.ship.marked_for_destruction?
         
     | 
| 
       659 
754 
     | 
    
         | 
| 
       660 
755 
     | 
    
         
             
                @pirate.ship.mark_for_destruction
         
     | 
| 
         @@ -714,7 +809,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       714 
809 
     | 
    
         
             
              end
         
     | 
| 
       715 
810 
     | 
    
         | 
| 
       716 
811 
     | 
    
         
             
              # belongs_to
         
     | 
| 
       717 
     | 
    
         
            -
              def  
     | 
| 
      
 812 
     | 
    
         
            +
              def test_should_destroy_a_parent_association_as_part_of_the_save_transaction_if_it_was_marked_for_destruction
         
     | 
| 
       718 
813 
     | 
    
         
             
                assert !@ship.pirate.marked_for_destruction?
         
     | 
| 
       719 
814 
     | 
    
         | 
| 
       720 
815 
     | 
    
         
             
                @ship.pirate.mark_for_destruction
         
     | 
| 
         @@ -774,13 +869,13 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       774 
869 
     | 
    
         
             
              def test_should_destroy_has_many_as_part_of_the_save_transaction_if_they_were_marked_for_destruction
         
     | 
| 
       775 
870 
     | 
    
         
             
                2.times { |i| @pirate.birds.create!(:name => "birds_#{i}") }
         
     | 
| 
       776 
871 
     | 
    
         | 
| 
       777 
     | 
    
         
            -
                assert !@pirate.birds.any? 
     | 
| 
      
 872 
     | 
    
         
            +
                assert !@pirate.birds.any?(&:marked_for_destruction?)
         
     | 
| 
       778 
873 
     | 
    
         | 
| 
       779 
     | 
    
         
            -
                @pirate.birds.each 
     | 
| 
      
 874 
     | 
    
         
            +
                @pirate.birds.each(&:mark_for_destruction)
         
     | 
| 
       780 
875 
     | 
    
         
             
                klass = @pirate.birds.first.class
         
     | 
| 
       781 
876 
     | 
    
         
             
                ids = @pirate.birds.map(&:id)
         
     | 
| 
       782 
877 
     | 
    
         | 
| 
       783 
     | 
    
         
            -
                assert @pirate.birds.all? 
     | 
| 
      
 878 
     | 
    
         
            +
                assert @pirate.birds.all?(&:marked_for_destruction?)
         
     | 
| 
       784 
879 
     | 
    
         
             
                ids.each { |id| assert klass.find_by_id(id) }
         
     | 
| 
       785 
880 
     | 
    
         | 
| 
       786 
881 
     | 
    
         
             
                @pirate.save
         
     | 
| 
         @@ -814,14 +909,14 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       814 
909 
     | 
    
         
             
                @pirate.birds.each { |bird| bird.name = '' }
         
     | 
| 
       815 
910 
     | 
    
         
             
                assert !@pirate.valid?
         
     | 
| 
       816 
911 
     | 
    
         | 
| 
       817 
     | 
    
         
            -
                @pirate.birds.each 
     | 
| 
      
 912 
     | 
    
         
            +
                @pirate.birds.each(&:destroy)
         
     | 
| 
       818 
913 
     | 
    
         
             
                assert @pirate.valid?
         
     | 
| 
       819 
914 
     | 
    
         
             
              end
         
     | 
| 
       820 
915 
     | 
    
         | 
| 
       821 
916 
     | 
    
         
             
              def test_a_child_marked_for_destruction_should_not_be_destroyed_twice_while_saving_has_many
         
     | 
| 
       822 
917 
     | 
    
         
             
                @pirate.birds.create!(:name => "birds_1")
         
     | 
| 
       823 
918 
     | 
    
         | 
| 
       824 
     | 
    
         
            -
                @pirate.birds.each 
     | 
| 
      
 919 
     | 
    
         
            +
                @pirate.birds.each(&:mark_for_destruction)
         
     | 
| 
       825 
920 
     | 
    
         
             
                assert @pirate.save
         
     | 
| 
       826 
921 
     | 
    
         | 
| 
       827 
922 
     | 
    
         
             
                @pirate.birds.each { |bird| bird.expects(:destroy).never }
         
     | 
| 
         @@ -888,7 +983,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       888 
983 
     | 
    
         
             
                  association_name_with_callbacks = "birds_with_#{callback_type}_callbacks"
         
     | 
| 
       889 
984 
     | 
    
         | 
| 
       890 
985 
     | 
    
         
             
                  @pirate.send(association_name_with_callbacks).create!(:name => "Crowe the One-Eyed")
         
     | 
| 
       891 
     | 
    
         
            -
                  @pirate.send(association_name_with_callbacks).each 
     | 
| 
      
 986 
     | 
    
         
            +
                  @pirate.send(association_name_with_callbacks).each(&:mark_for_destruction)
         
     | 
| 
       892 
987 
     | 
    
         
             
                  child_id = @pirate.send(association_name_with_callbacks).first.id
         
     | 
| 
       893 
988 
     | 
    
         | 
| 
       894 
989 
     | 
    
         
             
                  @pirate.ship_log.clear
         
     | 
| 
         @@ -906,8 +1001,8 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       906 
1001 
     | 
    
         
             
              def test_should_destroy_habtm_as_part_of_the_save_transaction_if_they_were_marked_for_destruction
         
     | 
| 
       907 
1002 
     | 
    
         
             
                2.times { |i| @pirate.parrots.create!(:name => "parrots_#{i}") }
         
     | 
| 
       908 
1003 
     | 
    
         | 
| 
       909 
     | 
    
         
            -
                assert !@pirate.parrots.any? 
     | 
| 
       910 
     | 
    
         
            -
                @pirate.parrots.each 
     | 
| 
      
 1004 
     | 
    
         
            +
                assert !@pirate.parrots.any?(&:marked_for_destruction?)
         
     | 
| 
      
 1005 
     | 
    
         
            +
                @pirate.parrots.each(&:mark_for_destruction)
         
     | 
| 
       911 
1006 
     | 
    
         | 
| 
       912 
1007 
     | 
    
         
             
                assert_no_difference "Parrot.count" do
         
     | 
| 
       913 
1008 
     | 
    
         
             
                  @pirate.save
         
     | 
| 
         @@ -940,14 +1035,14 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       940 
1035 
     | 
    
         
             
                @pirate.parrots.each { |parrot| parrot.name = '' }
         
     | 
| 
       941 
1036 
     | 
    
         
             
                assert !@pirate.valid?
         
     | 
| 
       942 
1037 
     | 
    
         | 
| 
       943 
     | 
    
         
            -
                @pirate.parrots.each 
     | 
| 
      
 1038 
     | 
    
         
            +
                @pirate.parrots.each(&:destroy)
         
     | 
| 
       944 
1039 
     | 
    
         
             
                assert @pirate.valid?
         
     | 
| 
       945 
1040 
     | 
    
         
             
              end
         
     | 
| 
       946 
1041 
     | 
    
         | 
| 
       947 
1042 
     | 
    
         
             
              def test_a_child_marked_for_destruction_should_not_be_destroyed_twice_while_saving_habtm
         
     | 
| 
       948 
1043 
     | 
    
         
             
                @pirate.parrots.create!(:name => "parrots_1")
         
     | 
| 
       949 
1044 
     | 
    
         | 
| 
       950 
     | 
    
         
            -
                @pirate.parrots.each 
     | 
| 
      
 1045 
     | 
    
         
            +
                @pirate.parrots.each(&:mark_for_destruction)
         
     | 
| 
       951 
1046 
     | 
    
         
             
                assert @pirate.save
         
     | 
| 
       952 
1047 
     | 
    
         | 
| 
       953 
1048 
     | 
    
         
             
                Pirate.transaction do
         
     | 
| 
         @@ -992,7 +1087,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       992 
1087 
     | 
    
         
             
                  association_name_with_callbacks = "parrots_with_#{callback_type}_callbacks"
         
     | 
| 
       993 
1088 
     | 
    
         | 
| 
       994 
1089 
     | 
    
         
             
                  @pirate.send(association_name_with_callbacks).create!(:name => "Crowe the One-Eyed")
         
     | 
| 
       995 
     | 
    
         
            -
                  @pirate.send(association_name_with_callbacks).each 
     | 
| 
      
 1090 
     | 
    
         
            +
                  @pirate.send(association_name_with_callbacks).each(&:mark_for_destruction)
         
     | 
| 
       996 
1091 
     | 
    
         
             
                  child_id = @pirate.send(association_name_with_callbacks).first.id
         
     | 
| 
       997 
1092 
     | 
    
         | 
| 
       998 
1093 
     | 
    
         
             
                  @pirate.ship_log.clear
         
     | 
| 
         @@ -1009,7 +1104,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase 
     | 
|
| 
       1009 
1104 
     | 
    
         
             
            end
         
     | 
| 
       1010 
1105 
     | 
    
         | 
| 
       1011 
1106 
     | 
    
         
             
            class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase
         
     | 
| 
       1012 
     | 
    
         
            -
              self. 
     | 
| 
      
 1107 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1013 
1108 
     | 
    
         | 
| 
       1014 
1109 
     | 
    
         
             
              def setup
         
     | 
| 
       1015 
1110 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1152,7 +1247,7 @@ class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase 
     | 
|
| 
       1152 
1247 
     | 
    
         
             
            end
         
     | 
| 
       1153 
1248 
     | 
    
         | 
| 
       1154 
1249 
     | 
    
         
             
            class TestAutosaveAssociationOnAHasOneThroughAssociation < ActiveRecord::TestCase
         
     | 
| 
       1155 
     | 
    
         
            -
              self. 
     | 
| 
      
 1250 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1156 
1251 
     | 
    
         | 
| 
       1157 
1252 
     | 
    
         
             
              def setup
         
     | 
| 
       1158 
1253 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1173,7 +1268,7 @@ class TestAutosaveAssociationOnAHasOneThroughAssociation < ActiveRecord::TestCas 
     | 
|
| 
       1173 
1268 
     | 
    
         
             
            end
         
     | 
| 
       1174 
1269 
     | 
    
         | 
| 
       1175 
1270 
     | 
    
         
             
            class TestAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase
         
     | 
| 
       1176 
     | 
    
         
            -
              self. 
     | 
| 
      
 1271 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1177 
1272 
     | 
    
         | 
| 
       1178 
1273 
     | 
    
         
             
              def setup
         
     | 
| 
       1179 
1274 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1285,6 +1380,24 @@ module AutosaveAssociationOnACollectionAssociationTests 
     | 
|
| 
       1285 
1380 
     | 
    
         
             
                assert_equal new_names, @pirate.reload.send(@association_name).map(&:name)
         
     | 
| 
       1286 
1381 
     | 
    
         
             
              end
         
     | 
| 
       1287 
1382 
     | 
    
         | 
| 
      
 1383 
     | 
    
         
            +
              def test_should_update_children_when_autosave_is_true_and_parent_is_new_but_child_is_not
         
     | 
| 
      
 1384 
     | 
    
         
            +
                parrot = Parrot.create!(name: "Polly")
         
     | 
| 
      
 1385 
     | 
    
         
            +
                parrot.name = "Squawky"
         
     | 
| 
      
 1386 
     | 
    
         
            +
                pirate = Pirate.new(parrots: [parrot], catchphrase: "Arrrr")
         
     | 
| 
      
 1387 
     | 
    
         
            +
             
     | 
| 
      
 1388 
     | 
    
         
            +
                pirate.save!
         
     | 
| 
      
 1389 
     | 
    
         
            +
             
     | 
| 
      
 1390 
     | 
    
         
            +
                assert_equal "Squawky", parrot.reload.name
         
     | 
| 
      
 1391 
     | 
    
         
            +
              end
         
     | 
| 
      
 1392 
     | 
    
         
            +
             
     | 
| 
      
 1393 
     | 
    
         
            +
              def test_should_not_update_children_when_parent_creation_with_no_reason
         
     | 
| 
      
 1394 
     | 
    
         
            +
                parrot = Parrot.create!(name: "Polly")
         
     | 
| 
      
 1395 
     | 
    
         
            +
                assert_equal 0, parrot.updated_count
         
     | 
| 
      
 1396 
     | 
    
         
            +
             
     | 
| 
      
 1397 
     | 
    
         
            +
                Pirate.create!(parrot_ids: [parrot.id], catchphrase: "Arrrr")
         
     | 
| 
      
 1398 
     | 
    
         
            +
                assert_equal 0, parrot.reload.updated_count
         
     | 
| 
      
 1399 
     | 
    
         
            +
              end
         
     | 
| 
      
 1400 
     | 
    
         
            +
             
     | 
| 
       1288 
1401 
     | 
    
         
             
              def test_should_automatically_validate_the_associated_models
         
     | 
| 
       1289 
1402 
     | 
    
         
             
                @pirate.send(@association_name).each { |child| child.name = '' }
         
     | 
| 
       1290 
1403 
     | 
    
         | 
| 
         @@ -1421,7 +1534,7 @@ module AutosaveAssociationOnACollectionAssociationTests 
     | 
|
| 
       1421 
1534 
     | 
    
         
             
            end
         
     | 
| 
       1422 
1535 
     | 
    
         | 
| 
       1423 
1536 
     | 
    
         
             
            class TestAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase
         
     | 
| 
       1424 
     | 
    
         
            -
              self. 
     | 
| 
      
 1537 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1425 
1538 
     | 
    
         | 
| 
       1426 
1539 
     | 
    
         
             
              def setup
         
     | 
| 
       1427 
1540 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1437,7 +1550,7 @@ class TestAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase 
     | 
|
| 
       1437 
1550 
     | 
    
         
             
            end
         
     | 
| 
       1438 
1551 
     | 
    
         | 
| 
       1439 
1552 
     | 
    
         
             
            class TestAutosaveAssociationOnAHasAndBelongsToManyAssociation < ActiveRecord::TestCase
         
     | 
| 
       1440 
     | 
    
         
            -
              self. 
     | 
| 
      
 1553 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1441 
1554 
     | 
    
         | 
| 
       1442 
1555 
     | 
    
         
             
              def setup
         
     | 
| 
       1443 
1556 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1454,7 +1567,7 @@ class TestAutosaveAssociationOnAHasAndBelongsToManyAssociation < ActiveRecord::T 
     | 
|
| 
       1454 
1567 
     | 
    
         
             
            end
         
     | 
| 
       1455 
1568 
     | 
    
         | 
| 
       1456 
1569 
     | 
    
         
             
            class TestAutosaveAssociationOnAHasAndBelongsToManyAssociationWithAcceptsNestedAttributes < ActiveRecord::TestCase
         
     | 
| 
       1457 
     | 
    
         
            -
              self. 
     | 
| 
      
 1570 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1458 
1571 
     | 
    
         | 
| 
       1459 
1572 
     | 
    
         
             
              def setup
         
     | 
| 
       1460 
1573 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1471,7 +1584,7 @@ class TestAutosaveAssociationOnAHasAndBelongsToManyAssociationWithAcceptsNestedA 
     | 
|
| 
       1471 
1584 
     | 
    
         
             
            end
         
     | 
| 
       1472 
1585 
     | 
    
         | 
| 
       1473 
1586 
     | 
    
         
             
            class TestAutosaveAssociationValidationsOnAHasManyAssociation < ActiveRecord::TestCase
         
     | 
| 
       1474 
     | 
    
         
            -
              self. 
     | 
| 
      
 1587 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1475 
1588 
     | 
    
         | 
| 
       1476 
1589 
     | 
    
         
             
              def setup
         
     | 
| 
       1477 
1590 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1488,7 +1601,7 @@ class TestAutosaveAssociationValidationsOnAHasManyAssociation < ActiveRecord::Te 
     | 
|
| 
       1488 
1601 
     | 
    
         
             
            end
         
     | 
| 
       1489 
1602 
     | 
    
         | 
| 
       1490 
1603 
     | 
    
         
             
            class TestAutosaveAssociationValidationsOnAHasOneAssociation < ActiveRecord::TestCase
         
     | 
| 
       1491 
     | 
    
         
            -
              self. 
     | 
| 
      
 1604 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1492 
1605 
     | 
    
         | 
| 
       1493 
1606 
     | 
    
         
             
              def setup
         
     | 
| 
       1494 
1607 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1511,7 +1624,7 @@ class TestAutosaveAssociationValidationsOnAHasOneAssociation < ActiveRecord::Tes 
     | 
|
| 
       1511 
1624 
     | 
    
         
             
            end
         
     | 
| 
       1512 
1625 
     | 
    
         | 
| 
       1513 
1626 
     | 
    
         
             
            class TestAutosaveAssociationValidationsOnABelongsToAssociation < ActiveRecord::TestCase
         
     | 
| 
       1514 
     | 
    
         
            -
              self. 
     | 
| 
      
 1627 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1515 
1628 
     | 
    
         | 
| 
       1516 
1629 
     | 
    
         
             
              def setup
         
     | 
| 
       1517 
1630 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1532,7 +1645,7 @@ class TestAutosaveAssociationValidationsOnABelongsToAssociation < ActiveRecord:: 
     | 
|
| 
       1532 
1645 
     | 
    
         
             
            end
         
     | 
| 
       1533 
1646 
     | 
    
         | 
| 
       1534 
1647 
     | 
    
         
             
            class TestAutosaveAssociationValidationsOnAHABTMAssociation < ActiveRecord::TestCase
         
     | 
| 
       1535 
     | 
    
         
            -
              self. 
     | 
| 
      
 1648 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1536 
1649 
     | 
    
         | 
| 
       1537 
1650 
     | 
    
         
             
              def setup
         
     | 
| 
       1538 
1651 
     | 
    
         
             
                super
         
     | 
| 
         @@ -1555,7 +1668,7 @@ class TestAutosaveAssociationValidationsOnAHABTMAssociation < ActiveRecord::Test 
     | 
|
| 
       1555 
1668 
     | 
    
         
             
            end
         
     | 
| 
       1556 
1669 
     | 
    
         | 
| 
       1557 
1670 
     | 
    
         
             
            class TestAutosaveAssociationValidationMethodsGeneration < ActiveRecord::TestCase
         
     | 
| 
       1558 
     | 
    
         
            -
              self. 
     | 
| 
      
 1671 
     | 
    
         
            +
              self.use_transactional_tests = false unless supports_savepoints?
         
     | 
| 
       1559 
1672 
     | 
    
         | 
| 
       1560 
1673 
     | 
    
         
             
              def setup
         
     | 
| 
       1561 
1674 
     | 
    
         
             
                super
         
     | 
    
        data/test/cases/base_test.rb
    CHANGED
    
    | 
         @@ -1,7 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
1 
     | 
    
         
             
            require "cases/helper"
         
     | 
| 
       4 
     | 
    
         
            -
            require 'active_support/concurrency/latch'
         
     | 
| 
       5 
2 
     | 
    
         
             
            require 'models/post'
         
     | 
| 
       6 
3 
     | 
    
         
             
            require 'models/author'
         
     | 
| 
       7 
4 
     | 
    
         
             
            require 'models/topic'
         
     | 
| 
         @@ -29,6 +26,7 @@ require 'models/bird' 
     | 
|
| 
       29 
26 
     | 
    
         
             
            require 'models/car'
         
     | 
| 
       30 
27 
     | 
    
         
             
            require 'models/bulb'
         
     | 
| 
       31 
28 
     | 
    
         
             
            require 'rexml/document'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'concurrent/atomic/count_down_latch'
         
     | 
| 
       32 
30 
     | 
    
         | 
| 
       33 
31 
     | 
    
         
             
            class FirstAbstractClass < ActiveRecord::Base
         
     | 
| 
       34 
32 
     | 
    
         
             
              self.abstract_class = true
         
     | 
| 
         @@ -77,18 +75,20 @@ class LintTest < ActiveRecord::TestCase 
     | 
|
| 
       77 
75 
     | 
    
         
             
            end
         
     | 
| 
       78 
76 
     | 
    
         | 
| 
       79 
77 
     | 
    
         
             
            class BasicsTest < ActiveRecord::TestCase
         
     | 
| 
       80 
     | 
    
         
            -
              fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse_things', :authors, :categorizations, :categories, :posts 
     | 
| 
      
 78 
     | 
    
         
            +
              #fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse_things', :authors, :categorizations, :categories, :posts
         
     | 
| 
      
 79 
     | 
    
         
            +
              fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse_things',  :categorizations, :categories, :posts
         
     | 
| 
       81 
80 
     | 
    
         | 
| 
       82 
81 
     | 
    
         
             
              def test_column_names_are_escaped
         
     | 
| 
      
 82 
     | 
    
         
            +
                puts "In base_test test_column_names_are_escaped"
         
     | 
| 
       83 
83 
     | 
    
         
             
                conn      = ActiveRecord::Base.connection
         
     | 
| 
       84 
84 
     | 
    
         
             
                classname = conn.class.name[/[^:]*$/]
         
     | 
| 
       85 
85 
     | 
    
         
             
                badchar   = {
         
     | 
| 
       86 
86 
     | 
    
         
             
                  'SQLite3Adapter'    => '"',
         
     | 
| 
       87 
     | 
    
         
            -
                  'MysqlAdapter'      => '`',
         
     | 
| 
       88 
87 
     | 
    
         
             
                  'Mysql2Adapter'     => '`',
         
     | 
| 
       89 
88 
     | 
    
         
             
                  'PostgreSQLAdapter' => '"',
         
     | 
| 
       90 
89 
     | 
    
         
             
                  'OracleAdapter'     => '"',
         
     | 
| 
       91 
90 
     | 
    
         
             
                  'IBM_DBAdapter'     => '"',
         
     | 
| 
      
 91 
     | 
    
         
            +
                  'FbAdapter'         => '"'
         
     | 
| 
       92 
92 
     | 
    
         
             
                }.fetch(classname) {
         
     | 
| 
       93 
93 
     | 
    
         
             
                  raise "need a bad char for #{classname}"
         
     | 
| 
       94 
94 
     | 
    
         
             
                }
         
     | 
| 
         @@ -106,64 +106,81 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       106 
106 
     | 
    
         
             
              end
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
       108 
108 
     | 
    
         
             
              def test_columns_should_obey_set_primary_key
         
     | 
| 
      
 109 
     | 
    
         
            +
                puts "In base_test test_columns_should_obey_set_primary_key"
         
     | 
| 
       109 
110 
     | 
    
         
             
                pk = Subscriber.columns_hash[Subscriber.primary_key]
         
     | 
| 
       110 
111 
     | 
    
         
             
                assert_equal 'nick', pk.name, 'nick should be primary key'
         
     | 
| 
       111 
112 
     | 
    
         
             
              end
         
     | 
| 
       112 
113 
     | 
    
         | 
| 
       113 
114 
     | 
    
         
             
              def test_primary_key_with_no_id
         
     | 
| 
      
 115 
     | 
    
         
            +
                puts "In base_test test_primary_key_with_no_id"
         
     | 
| 
       114 
116 
     | 
    
         
             
                assert_nil Edge.primary_key
         
     | 
| 
       115 
117 
     | 
    
         
             
              end
         
     | 
| 
       116 
118 
     | 
    
         | 
| 
       117 
     | 
    
         
            -
              unless current_adapter?(:PostgreSQLAdapter, :OracleAdapter, :SQLServerAdapter, :IBM_DBAdapter)
         
     | 
| 
      
 119 
     | 
    
         
            +
              unless current_adapter?(:PostgreSQLAdapter, :OracleAdapter, :SQLServerAdapter, :IBM_DBAdapter, :FbAdapter)
         
     | 
| 
       118 
120 
     | 
    
         
             
                def test_limit_with_comma
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
      
 121 
     | 
    
         
            +
            	  puts "In base_test test_limit_with_comma"
         
     | 
| 
      
 122 
     | 
    
         
            +
                  assert_deprecated do
         
     | 
| 
      
 123 
     | 
    
         
            +
                    assert Topic.limit("1,2").to_a
         
     | 
| 
      
 124 
     | 
    
         
            +
                  end
         
     | 
| 
       120 
125 
     | 
    
         
             
                end
         
     | 
| 
       121 
126 
     | 
    
         
             
              end
         
     | 
| 
       122 
127 
     | 
    
         | 
| 
      
 128 
     | 
    
         
            +
              def test_many_mutations
         
     | 
| 
      
 129 
     | 
    
         
            +
                puts "In base_test test_many_mutations"
         
     | 
| 
      
 130 
     | 
    
         
            +
                car = Car.new name: "<3<3<3"
         
     | 
| 
      
 131 
     | 
    
         
            +
                car.engines_count = 0
         
     | 
| 
      
 132 
     | 
    
         
            +
                20_000.times { car.engines_count += 1 }
         
     | 
| 
      
 133 
     | 
    
         
            +
                assert car.save
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
       123 
136 
     | 
    
         
             
              def test_limit_without_comma
         
     | 
| 
      
 137 
     | 
    
         
            +
                puts "In base_test test_limit_without_comma"
         
     | 
| 
       124 
138 
     | 
    
         
             
                assert_equal 1, Topic.limit("1").to_a.length
         
     | 
| 
       125 
139 
     | 
    
         
             
                assert_equal 1, Topic.limit(1).to_a.length
         
     | 
| 
       126 
140 
     | 
    
         
             
              end
         
     | 
| 
       127 
141 
     | 
    
         | 
| 
       128 
142 
     | 
    
         
             
              def test_limit_should_take_value_from_latest_limit
         
     | 
| 
      
 143 
     | 
    
         
            +
                puts "In base_test test_limit_should_take_value_from_latest_limit"
         
     | 
| 
       129 
144 
     | 
    
         
             
                assert_equal 1, Topic.limit(2).limit(1).to_a.length
         
     | 
| 
       130 
145 
     | 
    
         
             
              end
         
     | 
| 
       131 
146 
     | 
    
         | 
| 
       132 
147 
     | 
    
         
             
              def test_invalid_limit
         
     | 
| 
      
 148 
     | 
    
         
            +
                puts "In base_test test_invalid_limit"
         
     | 
| 
       133 
149 
     | 
    
         
             
                assert_raises(ArgumentError) do
         
     | 
| 
       134 
150 
     | 
    
         
             
                  Topic.limit("asdfadf").to_a
         
     | 
| 
       135 
151 
     | 
    
         
             
                end
         
     | 
| 
       136 
152 
     | 
    
         
             
              end
         
     | 
| 
       137 
153 
     | 
    
         | 
| 
       138 
154 
     | 
    
         
             
              def test_limit_should_sanitize_sql_injection_for_limit_without_commas
         
     | 
| 
      
 155 
     | 
    
         
            +
                puts "In base_test test_limit_should_sanitize_sql_injection_for_limit_without_commas"
         
     | 
| 
       139 
156 
     | 
    
         
             
                assert_raises(ArgumentError) do
         
     | 
| 
       140 
157 
     | 
    
         
             
                  Topic.limit("1 select * from schema").to_a
         
     | 
| 
       141 
158 
     | 
    
         
             
                end
         
     | 
| 
       142 
159 
     | 
    
         
             
              end
         
     | 
| 
       143 
160 
     | 
    
         | 
| 
       144 
161 
     | 
    
         
             
              def test_limit_should_sanitize_sql_injection_for_limit_with_commas
         
     | 
| 
       145 
     | 
    
         
            -
                 
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
              unless current_adapter?(:MysqlAdapter, :Mysql2Adapter, :IBM_DBAdapter)
         
     | 
| 
       151 
     | 
    
         
            -
                def test_limit_should_allow_sql_literal
         
     | 
| 
       152 
     | 
    
         
            -
                  assert_equal 1, Topic.limit(Arel.sql('2-1')).to_a.length
         
     | 
| 
      
 162 
     | 
    
         
            +
                puts "In base_test test_limit_should_sanitize_sql_injection_for_limit_with_commas"
         
     | 
| 
      
 163 
     | 
    
         
            +
                assert_deprecated do
         
     | 
| 
      
 164 
     | 
    
         
            +
                  assert_raises(ArgumentError) do
         
     | 
| 
      
 165 
     | 
    
         
            +
                    Topic.limit("1, 7 procedure help()").to_a
         
     | 
| 
      
 166 
     | 
    
         
            +
                  end
         
     | 
| 
       153 
167 
     | 
    
         
             
                end
         
     | 
| 
       154 
168 
     | 
    
         
             
              end
         
     | 
| 
       155 
169 
     | 
    
         | 
| 
       156 
170 
     | 
    
         
             
              def test_select_symbol
         
     | 
| 
      
 171 
     | 
    
         
            +
                puts "In base_test test_select_symbol"
         
     | 
| 
       157 
172 
     | 
    
         
             
                topic_ids = Topic.select(:id).map(&:id).sort
         
     | 
| 
       158 
173 
     | 
    
         
             
                assert_equal Topic.pluck(:id).sort, topic_ids
         
     | 
| 
       159 
174 
     | 
    
         
             
              end
         
     | 
| 
       160 
175 
     | 
    
         | 
| 
       161 
176 
     | 
    
         
             
              def test_table_exists
         
     | 
| 
      
 177 
     | 
    
         
            +
                puts "In base_test test_table_exists"
         
     | 
| 
       162 
178 
     | 
    
         
             
                assert !NonExistentTable.table_exists?
         
     | 
| 
       163 
179 
     | 
    
         
             
                assert Topic.table_exists?
         
     | 
| 
       164 
180 
     | 
    
         
             
              end
         
     | 
| 
       165 
181 
     | 
    
         | 
| 
       166 
182 
     | 
    
         
             
              def test_preserving_date_objects
         
     | 
| 
      
 183 
     | 
    
         
            +
                puts "In base_test test_preserving_date_objects"
         
     | 
| 
       167 
184 
     | 
    
         
             
                # Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
         
     | 
| 
       168 
185 
     | 
    
         
             
                assert_kind_of(
         
     | 
| 
       169 
186 
     | 
    
         
             
                  Date, Topic.find(1).last_read,
         
     | 
| 
         @@ -172,6 +189,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       172 
189 
     | 
    
         
             
              end
         
     | 
| 
       173 
190 
     | 
    
         | 
| 
       174 
191 
     | 
    
         
             
              def test_previously_changed
         
     | 
| 
      
 192 
     | 
    
         
            +
                puts "In base_test test_previously_changed"
         
     | 
| 
       175 
193 
     | 
    
         
             
                topic = Topic.first
         
     | 
| 
       176 
194 
     | 
    
         
             
                topic.title = '<3<3<3'
         
     | 
| 
       177 
195 
     | 
    
         
             
                assert_equal({}, topic.previous_changes)
         
     | 
| 
         @@ -182,6 +200,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       182 
200 
     | 
    
         
             
              end
         
     | 
| 
       183 
201 
     | 
    
         | 
| 
       184 
202 
     | 
    
         
             
              def test_previously_changed_dup
         
     | 
| 
      
 203 
     | 
    
         
            +
                puts "In base_test test_previously_changed_dup"
         
     | 
| 
       185 
204 
     | 
    
         
             
                topic = Topic.first
         
     | 
| 
       186 
205 
     | 
    
         
             
                topic.title = '<3<3<3'
         
     | 
| 
       187 
206 
     | 
    
         
             
                topic.save!
         
     | 
| 
         @@ -197,6 +216,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       197 
216 
     | 
    
         
             
              end
         
     | 
| 
       198 
217 
     | 
    
         | 
| 
       199 
218 
     | 
    
         
             
              def test_preserving_time_objects
         
     | 
| 
      
 219 
     | 
    
         
            +
                puts "In base_test test_preserving_time_objects"
         
     | 
| 
       200 
220 
     | 
    
         
             
                assert_kind_of(
         
     | 
| 
       201 
221 
     | 
    
         
             
                  Time, Topic.find(1).bonus_time,
         
     | 
| 
       202 
222 
     | 
    
         
             
                  "The bonus_time attribute should be of the Time class"
         
     | 
| 
         @@ -208,7 +228,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       208 
228 
     | 
    
         
             
                )
         
     | 
| 
       209 
229 
     | 
    
         | 
| 
       210 
230 
     | 
    
         
             
                # For adapters which support microsecond resolution.
         
     | 
| 
       211 
     | 
    
         
            -
                if  
     | 
| 
      
 231 
     | 
    
         
            +
                if subsecond_precision_supported?
         
     | 
| 
       212 
232 
     | 
    
         
             
                  assert_equal 11, Topic.find(1).written_on.sec
         
     | 
| 
       213 
233 
     | 
    
         
             
                  assert_equal 223300, Topic.find(1).written_on.usec
         
     | 
| 
       214 
234 
     | 
    
         
             
                  assert_equal 9900, Topic.find(2).written_on.usec
         
     | 
| 
         @@ -217,7 +237,8 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       217 
237 
     | 
    
         
             
              end
         
     | 
| 
       218 
238 
     | 
    
         | 
| 
       219 
239 
     | 
    
         
             
              def test_preserving_time_objects_with_local_time_conversion_to_default_timezone_utc
         
     | 
| 
       220 
     | 
    
         
            -
                 
     | 
| 
      
 240 
     | 
    
         
            +
                puts "In base_test test_preserving_time_objects_with_local_time_conversion_to_default_timezone_utc"
         
     | 
| 
      
 241 
     | 
    
         
            +
                with_env_tz eastern_time_zone do
         
     | 
| 
       221 
242 
     | 
    
         
             
                  with_timezone_config default: :utc do
         
     | 
| 
       222 
243 
     | 
    
         
             
                    time = Time.local(2000)
         
     | 
| 
       223 
244 
     | 
    
         
             
                    topic = Topic.create('written_on' => time)
         
     | 
| 
         @@ -230,7 +251,8 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       230 
251 
     | 
    
         
             
              end
         
     | 
| 
       231 
252 
     | 
    
         | 
| 
       232 
253 
     | 
    
         
             
              def test_preserving_time_objects_with_time_with_zone_conversion_to_default_timezone_utc
         
     | 
| 
       233 
     | 
    
         
            -
                 
     | 
| 
      
 254 
     | 
    
         
            +
                puts "In base_test test_preserving_time_objects_with_time_with_zone_conversion_to_default_timezone_utc"
         
     | 
| 
      
 255 
     | 
    
         
            +
                with_env_tz eastern_time_zone do
         
     | 
| 
       234 
256 
     | 
    
         
             
                  with_timezone_config default: :utc do
         
     | 
| 
       235 
257 
     | 
    
         
             
                    Time.use_zone 'Central Time (US & Canada)' do
         
     | 
| 
       236 
258 
     | 
    
         
             
                      time = Time.zone.local(2000)
         
     | 
| 
         @@ -245,7 +267,8 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       245 
267 
     | 
    
         
             
              end
         
     | 
| 
       246 
268 
     | 
    
         | 
| 
       247 
269 
     | 
    
         
             
              def test_preserving_time_objects_with_utc_time_conversion_to_default_timezone_local
         
     | 
| 
       248 
     | 
    
         
            -
                 
     | 
| 
      
 270 
     | 
    
         
            +
                puts "In base_test test_preserving_time_objects_with_utc_time_conversion_to_default_timezone_local"
         
     | 
| 
      
 271 
     | 
    
         
            +
                with_env_tz eastern_time_zone do
         
     | 
| 
       249 
272 
     | 
    
         
             
                  with_timezone_config default: :local do
         
     | 
| 
       250 
273 
     | 
    
         
             
                    time = Time.utc(2000)
         
     | 
| 
       251 
274 
     | 
    
         
             
                    topic = Topic.create('written_on' => time)
         
     | 
| 
         @@ -258,7 +281,8 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       258 
281 
     | 
    
         
             
              end
         
     | 
| 
       259 
282 
     | 
    
         | 
| 
       260 
283 
     | 
    
         
             
              def test_preserving_time_objects_with_time_with_zone_conversion_to_default_timezone_local
         
     | 
| 
       261 
     | 
    
         
            -
                 
     | 
| 
      
 284 
     | 
    
         
            +
                puts "In base_test test_preserving_time_objects_with_time_with_zone_conversion_to_default_timezone_local"
         
     | 
| 
      
 285 
     | 
    
         
            +
                with_env_tz eastern_time_zone do
         
     | 
| 
       262 
286 
     | 
    
         
             
                  with_timezone_config default: :local do
         
     | 
| 
       263 
287 
     | 
    
         
             
                    Time.use_zone 'Central Time (US & Canada)' do
         
     | 
| 
       264 
288 
     | 
    
         
             
                      time = Time.zone.local(2000)
         
     | 
| 
         @@ -272,7 +296,16 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       272 
296 
     | 
    
         
             
                end
         
     | 
| 
       273 
297 
     | 
    
         
             
              end
         
     | 
| 
       274 
298 
     | 
    
         | 
| 
      
 299 
     | 
    
         
            +
              def eastern_time_zone
         
     | 
| 
      
 300 
     | 
    
         
            +
                if Gem.win_platform?
         
     | 
| 
      
 301 
     | 
    
         
            +
                  "EST5EDT"
         
     | 
| 
      
 302 
     | 
    
         
            +
                else
         
     | 
| 
      
 303 
     | 
    
         
            +
                  "America/New_York"
         
     | 
| 
      
 304 
     | 
    
         
            +
                end
         
     | 
| 
      
 305 
     | 
    
         
            +
              end
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
       275 
307 
     | 
    
         
             
              def test_custom_mutator
         
     | 
| 
      
 308 
     | 
    
         
            +
                puts "In base_test test_custom_mutator"
         
     | 
| 
       276 
309 
     | 
    
         
             
                topic = Topic.find(1)
         
     | 
| 
       277 
310 
     | 
    
         
             
                # This mutator is protected in the class definition
         
     | 
| 
       278 
311 
     | 
    
         
             
                topic.send(:approved=, true)
         
     | 
| 
         @@ -280,6 +313,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       280 
313 
     | 
    
         
             
              end
         
     | 
| 
       281 
314 
     | 
    
         | 
| 
       282 
315 
     | 
    
         
             
              def test_initialize_with_attributes
         
     | 
| 
      
 316 
     | 
    
         
            +
                puts "In base_test test_initialize_with_attributes"
         
     | 
| 
       283 
317 
     | 
    
         
             
                topic = Topic.new({
         
     | 
| 
       284 
318 
     | 
    
         
             
                  "title" => "initialized from attributes", "written_on" => "2003-12-12 23:23"
         
     | 
| 
       285 
319 
     | 
    
         
             
                })
         
     | 
| 
         @@ -288,6 +322,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       288 
322 
     | 
    
         
             
              end
         
     | 
| 
       289 
323 
     | 
    
         | 
| 
       290 
324 
     | 
    
         
             
              def test_initialize_with_invalid_attribute
         
     | 
| 
      
 325 
     | 
    
         
            +
                puts "In base_test test_initialize_with_invalid_attribute"
         
     | 
| 
       291 
326 
     | 
    
         
             
                Topic.new({ "title" => "test",
         
     | 
| 
       292 
327 
     | 
    
         
             
                  "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"})
         
     | 
| 
       293 
328 
     | 
    
         
             
              rescue ActiveRecord::MultiparameterAssignmentErrors => ex
         
     | 
| 
         @@ -296,18 +331,21 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       296 
331 
     | 
    
         
             
              end
         
     | 
| 
       297 
332 
     | 
    
         | 
| 
       298 
333 
     | 
    
         
             
              def test_create_after_initialize_without_block
         
     | 
| 
      
 334 
     | 
    
         
            +
                puts "In base_test test_create_after_initialize_without_block"
         
     | 
| 
       299 
335 
     | 
    
         
             
                cb = CustomBulb.create(:name => 'Dude')
         
     | 
| 
       300 
336 
     | 
    
         
             
                assert_equal('Dude', cb.name)
         
     | 
| 
       301 
337 
     | 
    
         
             
                assert_equal(true, cb.frickinawesome)
         
     | 
| 
       302 
338 
     | 
    
         
             
              end
         
     | 
| 
       303 
339 
     | 
    
         | 
| 
       304 
340 
     | 
    
         
             
              def test_create_after_initialize_with_block
         
     | 
| 
      
 341 
     | 
    
         
            +
                puts "In base_test test_create_after_initialize_with_block"
         
     | 
| 
       305 
342 
     | 
    
         
             
                cb = CustomBulb.create {|c| c.name = 'Dude' }
         
     | 
| 
       306 
343 
     | 
    
         
             
                assert_equal('Dude', cb.name)
         
     | 
| 
       307 
344 
     | 
    
         
             
                assert_equal(true, cb.frickinawesome)
         
     | 
| 
       308 
345 
     | 
    
         
             
              end
         
     | 
| 
       309 
346 
     | 
    
         | 
| 
       310 
347 
     | 
    
         
             
              def test_create_after_initialize_with_array_param
         
     | 
| 
      
 348 
     | 
    
         
            +
                puts "In base_test test_create_after_initialize_with_array_param"
         
     | 
| 
       311 
349 
     | 
    
         
             
                cbs = CustomBulb.create([{ name: 'Dude' }, { name: 'Bob' }])
         
     | 
| 
       312 
350 
     | 
    
         
             
                assert_equal 'Dude', cbs[0].name
         
     | 
| 
       313 
351 
     | 
    
         
             
                assert_equal 'Bob', cbs[1].name
         
     | 
| 
         @@ -316,12 +354,14 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       316 
354 
     | 
    
         
             
              end
         
     | 
| 
       317 
355 
     | 
    
         | 
| 
       318 
356 
     | 
    
         
             
              def test_load
         
     | 
| 
      
 357 
     | 
    
         
            +
                puts "In base_test test_load"
         
     | 
| 
       319 
358 
     | 
    
         
             
                topics = Topic.all.merge!(:order => 'id').to_a
         
     | 
| 
       320 
359 
     | 
    
         
             
                assert_equal(5, topics.size)
         
     | 
| 
       321 
360 
     | 
    
         
             
                assert_equal(topics(:first).title, topics.first.title)
         
     | 
| 
       322 
361 
     | 
    
         
             
              end
         
     | 
| 
       323 
362 
     | 
    
         | 
| 
       324 
363 
     | 
    
         
             
              def test_load_with_condition
         
     | 
| 
      
 364 
     | 
    
         
            +
                puts "In base_test test_load_with_condition"
         
     | 
| 
       325 
365 
     | 
    
         
             
                topics = Topic.all.merge!(:where => "author_name = 'Mary'").to_a
         
     | 
| 
       326 
366 
     | 
    
         | 
| 
       327 
367 
     | 
    
         
             
                assert_equal(1, topics.size)
         
     | 
| 
         @@ -331,6 +371,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       331 
371 
     | 
    
         
             
              GUESSED_CLASSES = [Category, Smarts, CreditCard, CreditCard::PinNumber, CreditCard::PinNumber::CvvCode, CreditCard::SubPinNumber, CreditCard::Brand, MasterCreditCard]
         
     | 
| 
       332 
372 
     | 
    
         | 
| 
       333 
373 
     | 
    
         
             
              def test_table_name_guesses
         
     | 
| 
      
 374 
     | 
    
         
            +
                puts "In base_test test_table_name_guesses"
         
     | 
| 
       334 
375 
     | 
    
         
             
                assert_equal "topics", Topic.table_name
         
     | 
| 
       335 
376 
     | 
    
         | 
| 
       336 
377 
     | 
    
         
             
                assert_equal "categories", Category.table_name
         
     | 
| 
         @@ -346,6 +387,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       346 
387 
     | 
    
         
             
              end
         
     | 
| 
       347 
388 
     | 
    
         | 
| 
       348 
389 
     | 
    
         
             
              def test_singular_table_name_guesses
         
     | 
| 
      
 390 
     | 
    
         
            +
                puts "In base_test test_singular_table_name_guesses"
         
     | 
| 
       349 
391 
     | 
    
         
             
                ActiveRecord::Base.pluralize_table_names = false
         
     | 
| 
       350 
392 
     | 
    
         
             
                GUESSED_CLASSES.each(&:reset_table_name)
         
     | 
| 
       351 
393 
     | 
    
         | 
| 
         @@ -363,6 +405,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       363 
405 
     | 
    
         
             
              end
         
     | 
| 
       364 
406 
     | 
    
         | 
| 
       365 
407 
     | 
    
         
             
              def test_table_name_guesses_with_prefixes_and_suffixes
         
     | 
| 
      
 408 
     | 
    
         
            +
                puts "In base_test test_table_name_guesses_with_prefixes_and_suffixes"
         
     | 
| 
       366 
409 
     | 
    
         
             
                ActiveRecord::Base.table_name_prefix = "test_"
         
     | 
| 
       367 
410 
     | 
    
         
             
                Category.reset_table_name
         
     | 
| 
       368 
411 
     | 
    
         
             
                assert_equal "test_categories", Category.table_name
         
     | 
| 
         @@ -382,6 +425,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       382 
425 
     | 
    
         
             
              end
         
     | 
| 
       383 
426 
     | 
    
         | 
| 
       384 
427 
     | 
    
         
             
              def test_singular_table_name_guesses_with_prefixes_and_suffixes
         
     | 
| 
      
 428 
     | 
    
         
            +
                puts "In base_test test_singular_table_name_guesses_with_prefixes_and_suffixes"
         
     | 
| 
       385 
429 
     | 
    
         
             
                ActiveRecord::Base.pluralize_table_names = false
         
     | 
| 
       386 
430 
     | 
    
         | 
| 
       387 
431 
     | 
    
         
             
                ActiveRecord::Base.table_name_prefix = "test_"
         
     | 
| 
         @@ -404,6 +448,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       404 
448 
     | 
    
         
             
              end
         
     | 
| 
       405 
449 
     | 
    
         | 
| 
       406 
450 
     | 
    
         
             
              def test_table_name_guesses_with_inherited_prefixes_and_suffixes
         
     | 
| 
      
 451 
     | 
    
         
            +
                puts "In base_test test_table_name_guesses_with_inherited_prefixes_and_suffixes"
         
     | 
| 
       407 
452 
     | 
    
         
             
                GUESSED_CLASSES.each(&:reset_table_name)
         
     | 
| 
       408 
453 
     | 
    
         | 
| 
       409 
454 
     | 
    
         
             
                CreditCard.table_name_prefix = "test_"
         
     | 
| 
         @@ -433,6 +478,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       433 
478 
     | 
    
         
             
              end
         
     | 
| 
       434 
479 
     | 
    
         | 
| 
       435 
480 
     | 
    
         
             
              def test_singular_table_name_guesses_for_individual_table
         
     | 
| 
      
 481 
     | 
    
         
            +
                puts "In base_test test_singular_table_name_guesses_for_individual_table"
         
     | 
| 
       436 
482 
     | 
    
         
             
                Post.pluralize_table_names = false
         
     | 
| 
       437 
483 
     | 
    
         
             
                Post.reset_table_name
         
     | 
| 
       438 
484 
     | 
    
         
             
                assert_equal "post", Post.table_name
         
     | 
| 
         @@ -442,18 +488,21 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       442 
488 
     | 
    
         
             
                Post.reset_table_name
         
     | 
| 
       443 
489 
     | 
    
         
             
              end
         
     | 
| 
       444 
490 
     | 
    
         | 
| 
       445 
     | 
    
         
            -
              if current_adapter?(: 
     | 
| 
      
 491 
     | 
    
         
            +
              if current_adapter?(:Mysql2Adapter)    
         
     | 
| 
      
 492 
     | 
    
         
            +
                puts "In base_test test_update_all_with_order_and_limit"
         
     | 
| 
       446 
493 
     | 
    
         
             
                def test_update_all_with_order_and_limit
         
     | 
| 
       447 
494 
     | 
    
         
             
                  assert_equal 1, Topic.limit(1).order('id DESC').update_all(:content => 'bulk updated!')
         
     | 
| 
       448 
495 
     | 
    
         
             
                end
         
     | 
| 
       449 
496 
     | 
    
         
             
              end
         
     | 
| 
       450 
497 
     | 
    
         | 
| 
       451 
498 
     | 
    
         
             
              def test_null_fields
         
     | 
| 
      
 499 
     | 
    
         
            +
                puts "In base_test test_null_fields"
         
     | 
| 
       452 
500 
     | 
    
         
             
                assert_nil Topic.find(1).parent_id
         
     | 
| 
       453 
501 
     | 
    
         
             
                assert_nil Topic.create("title" => "Hey you").parent_id
         
     | 
| 
       454 
502 
     | 
    
         
             
              end
         
     | 
| 
       455 
503 
     | 
    
         | 
| 
       456 
504 
     | 
    
         
             
              def test_default_values
         
     | 
| 
      
 505 
     | 
    
         
            +
                puts "In base_test test_default_values"
         
     | 
| 
       457 
506 
     | 
    
         
             
                topic = Topic.new
         
     | 
| 
       458 
507 
     | 
    
         
             
                assert topic.approved?
         
     | 
| 
       459 
508 
     | 
    
         
             
                assert_nil topic.written_on
         
     | 
| 
         @@ -477,17 +526,20 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       477 
526 
     | 
    
         
             
              end
         
     | 
| 
       478 
527 
     | 
    
         | 
| 
       479 
528 
     | 
    
         
             
              # Oracle does not have a TIME datatype.
         
     | 
| 
       480 
     | 
    
         
            -
              unless current_adapter?(:OracleAdapter)
         
     | 
| 
      
 529 
     | 
    
         
            +
              unless current_adapter?(:OracleAdapter,:IBM_DBAdapter)
         
     | 
| 
       481 
530 
     | 
    
         
             
                def test_utc_as_time_zone
         
     | 
| 
      
 531 
     | 
    
         
            +
            	  puts "In base_test test_utc_as_time_zone"
         
     | 
| 
       482 
532 
     | 
    
         
             
                  with_timezone_config default: :utc do
         
     | 
| 
       483 
533 
     | 
    
         
             
                    attributes = { "bonus_time" => "5:42:00AM" }
         
     | 
| 
       484 
534 
     | 
    
         
             
                    topic = Topic.find(1)
         
     | 
| 
       485 
535 
     | 
    
         
             
                    topic.attributes = attributes
         
     | 
| 
       486 
536 
     | 
    
         
             
                    assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time
         
     | 
| 
       487 
537 
     | 
    
         
             
                  end
         
     | 
| 
       488 
     | 
    
         
            -
             
     | 
| 
      
 538 
     | 
    
         
            +
            	end
         
     | 
| 
      
 539 
     | 
    
         
            +
              end
         
     | 
| 
       489 
540 
     | 
    
         | 
| 
       490 
541 
     | 
    
         
             
                def test_utc_as_time_zone_and_new
         
     | 
| 
      
 542 
     | 
    
         
            +
            	  puts "In base_test test_utc_as_time_zone_and_new"
         
     | 
| 
       491 
543 
     | 
    
         
             
                  with_timezone_config default: :utc do
         
     | 
| 
       492 
544 
     | 
    
         
             
                    attributes = { "bonus_time(1i)"=>"2000",
         
     | 
| 
       493 
545 
     | 
    
         
             
                      "bonus_time(2i)"=>"1",
         
     | 
| 
         @@ -502,6 +554,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       502 
554 
     | 
    
         
             
              end
         
     | 
| 
       503 
555 
     | 
    
         | 
| 
       504 
556 
     | 
    
         
             
              def test_default_values_on_empty_strings
         
     | 
| 
      
 557 
     | 
    
         
            +
                puts "In base_test test_default_values_on_empty_strings"
         
     | 
| 
       505 
558 
     | 
    
         
             
                topic = Topic.new
         
     | 
| 
       506 
559 
     | 
    
         
             
                topic.approved  = nil
         
     | 
| 
       507 
560 
     | 
    
         
             
                topic.last_read = nil
         
     | 
| 
         @@ -515,27 +568,34 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       515 
568 
     | 
    
         
             
              end
         
     | 
| 
       516 
569 
     | 
    
         | 
| 
       517 
570 
     | 
    
         
             
              def test_equality
         
     | 
| 
      
 571 
     | 
    
         
            +
                puts "In base_test test_equality"
         
     | 
| 
       518 
572 
     | 
    
         
             
                assert_equal Topic.find(1), Topic.find(2).topic
         
     | 
| 
       519 
573 
     | 
    
         
             
              end
         
     | 
| 
       520 
574 
     | 
    
         | 
| 
       521 
575 
     | 
    
         
             
              def test_find_by_slug
         
     | 
| 
      
 576 
     | 
    
         
            +
                puts "In base_test test_find_by_slug"
         
     | 
| 
       522 
577 
     | 
    
         
             
                assert_equal Topic.find('1-meowmeow'), Topic.find(1)
         
     | 
| 
       523 
578 
     | 
    
         
             
              end
         
     | 
| 
       524 
579 
     | 
    
         | 
| 
       525 
580 
     | 
    
         
             
              def test_find_by_slug_with_array
         
     | 
| 
       526 
     | 
    
         
            -
                 
     | 
| 
      
 581 
     | 
    
         
            +
                puts "In base_test test_find_by_slug_with_array"
         
     | 
| 
      
 582 
     | 
    
         
            +
                assert_equal Topic.find([1, 2]), Topic.find(['1-meowmeow', '2-hello'])
         
     | 
| 
      
 583 
     | 
    
         
            +
                assert_equal 'The Second Topic of the day', Topic.find(['2-hello', '1-meowmeow']).first.title
         
     | 
| 
       527 
584 
     | 
    
         
             
              end
         
     | 
| 
       528 
585 
     | 
    
         | 
| 
       529 
586 
     | 
    
         
             
              def test_find_by_slug_with_range
         
     | 
| 
      
 587 
     | 
    
         
            +
                puts "In base_test test_find_by_slug_with_range"
         
     | 
| 
       530 
588 
     | 
    
         
             
                assert_equal Topic.where(id: '1-meowmeow'..'2-hello'), Topic.where(id: 1..2)
         
     | 
| 
       531 
589 
     | 
    
         
             
              end
         
     | 
| 
       532 
590 
     | 
    
         | 
| 
       533 
591 
     | 
    
         
             
              def test_equality_of_new_records
         
     | 
| 
      
 592 
     | 
    
         
            +
                puts "In base_test test_equality_of_new_records"
         
     | 
| 
       534 
593 
     | 
    
         
             
                assert_not_equal Topic.new, Topic.new
         
     | 
| 
       535 
594 
     | 
    
         
             
                assert_equal false, Topic.new == Topic.new
         
     | 
| 
       536 
595 
     | 
    
         
             
              end
         
     | 
| 
       537 
596 
     | 
    
         | 
| 
       538 
597 
     | 
    
         
             
              def test_equality_of_destroyed_records
         
     | 
| 
      
 598 
     | 
    
         
            +
                puts "In base_test test_equality_of_destroyed_records"
         
     | 
| 
       539 
599 
     | 
    
         
             
                topic_1 = Topic.new(:title => 'test_1')
         
     | 
| 
       540 
600 
     | 
    
         
             
                topic_1.save
         
     | 
| 
       541 
601 
     | 
    
         
             
                topic_2 = Topic.find(topic_1.id)
         
     | 
| 
         @@ -545,12 +605,14 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       545 
605 
     | 
    
         
             
              end
         
     | 
| 
       546 
606 
     | 
    
         | 
| 
       547 
607 
     | 
    
         
             
              def test_equality_with_blank_ids
         
     | 
| 
      
 608 
     | 
    
         
            +
                puts "In base_test test_equality_with_blank_ids"
         
     | 
| 
       548 
609 
     | 
    
         
             
                one = Subscriber.new(:id => '')
         
     | 
| 
       549 
610 
     | 
    
         
             
                two = Subscriber.new(:id => '')
         
     | 
| 
       550 
611 
     | 
    
         
             
                assert_equal one, two
         
     | 
| 
       551 
612 
     | 
    
         
             
              end
         
     | 
| 
       552 
613 
     | 
    
         | 
| 
       553 
614 
     | 
    
         
             
              def test_equality_of_relation_and_collection_proxy
         
     | 
| 
      
 615 
     | 
    
         
            +
                puts "In base_test test_equality_of_relation_and_collection_proxy"
         
     | 
| 
       554 
616 
     | 
    
         
             
                car = Car.create!
         
     | 
| 
       555 
617 
     | 
    
         
             
                car.bulbs.build
         
     | 
| 
       556 
618 
     | 
    
         
             
                car.save
         
     | 
| 
         @@ -560,6 +622,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       560 
622 
     | 
    
         
             
              end
         
     | 
| 
       561 
623 
     | 
    
         | 
| 
       562 
624 
     | 
    
         
             
              def test_equality_of_relation_and_array
         
     | 
| 
      
 625 
     | 
    
         
            +
                puts "In base_test test_equality_of_relation_and_array"
         
     | 
| 
       563 
626 
     | 
    
         
             
                car = Car.create!
         
     | 
| 
       564 
627 
     | 
    
         
             
                car.bulbs.build
         
     | 
| 
       565 
628 
     | 
    
         
             
                car.save
         
     | 
| 
         @@ -568,6 +631,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       568 
631 
     | 
    
         
             
              end
         
     | 
| 
       569 
632 
     | 
    
         | 
| 
       570 
633 
     | 
    
         
             
              def test_equality_of_relation_and_association_relation
         
     | 
| 
      
 634 
     | 
    
         
            +
                puts "In base_test test_equality_of_relation_and_association_relation"
         
     | 
| 
       571 
635 
     | 
    
         
             
                car = Car.create!
         
     | 
| 
       572 
636 
     | 
    
         
             
                car.bulbs.build
         
     | 
| 
       573 
637 
     | 
    
         
             
                car.save
         
     | 
| 
         @@ -577,6 +641,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       577 
641 
     | 
    
         
             
              end
         
     | 
| 
       578 
642 
     | 
    
         | 
| 
       579 
643 
     | 
    
         
             
              def test_equality_of_collection_proxy_and_association_relation
         
     | 
| 
      
 644 
     | 
    
         
            +
                puts "In base_test test_equality_of_collection_proxy_and_association_relation"
         
     | 
| 
       580 
645 
     | 
    
         
             
                car = Car.create!
         
     | 
| 
       581 
646 
     | 
    
         
             
                car.bulbs.build
         
     | 
| 
       582 
647 
     | 
    
         
             
                car.save
         
     | 
| 
         @@ -586,10 +651,12 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       586 
651 
     | 
    
         
             
              end
         
     | 
| 
       587 
652 
     | 
    
         | 
| 
       588 
653 
     | 
    
         
             
              def test_hashing
         
     | 
| 
      
 654 
     | 
    
         
            +
                puts "In base_test test_hashing"
         
     | 
| 
       589 
655 
     | 
    
         
             
                assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ]
         
     | 
| 
       590 
656 
     | 
    
         
             
              end
         
     | 
| 
       591 
657 
     | 
    
         | 
| 
       592 
658 
     | 
    
         
             
              def test_successful_comparison_of_like_class_records
         
     | 
| 
      
 659 
     | 
    
         
            +
                puts "In base_test test_successful_comparison_of_like_class_records"
         
     | 
| 
       593 
660 
     | 
    
         
             
                topic_1 = Topic.create!
         
     | 
| 
       594 
661 
     | 
    
         
             
                topic_2 = Topic.create!
         
     | 
| 
       595 
662 
     | 
    
         | 
| 
         @@ -597,12 +664,14 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       597 
664 
     | 
    
         
             
              end
         
     | 
| 
       598 
665 
     | 
    
         | 
| 
       599 
666 
     | 
    
         
             
              def test_failed_comparison_of_unlike_class_records
         
     | 
| 
      
 667 
     | 
    
         
            +
                puts "In base_test test_failed_comparison_of_unlike_class_records"
         
     | 
| 
       600 
668 
     | 
    
         
             
                assert_raises ArgumentError do
         
     | 
| 
       601 
669 
     | 
    
         
             
                  [ topics(:first), posts(:welcome) ].sort
         
     | 
| 
       602 
670 
     | 
    
         
             
                end
         
     | 
| 
       603 
671 
     | 
    
         
             
              end
         
     | 
| 
       604 
672 
     | 
    
         | 
| 
       605 
673 
     | 
    
         
             
              def test_create_without_prepared_statement
         
     | 
| 
      
 674 
     | 
    
         
            +
                puts "In base_test test_create_without_prepared_statement"
         
     | 
| 
       606 
675 
     | 
    
         
             
                topic = Topic.connection.unprepared_statement do
         
     | 
| 
       607 
676 
     | 
    
         
             
                  Topic.create(:title => 'foo')
         
     | 
| 
       608 
677 
     | 
    
         
             
                end
         
     | 
| 
         @@ -611,6 +680,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       611 
680 
     | 
    
         
             
              end
         
     | 
| 
       612 
681 
     | 
    
         | 
| 
       613 
682 
     | 
    
         
             
              def test_destroy_without_prepared_statement
         
     | 
| 
      
 683 
     | 
    
         
            +
                puts "In base_test test_destroy_without_prepared_statement"
         
     | 
| 
       614 
684 
     | 
    
         
             
                topic = Topic.create(title: 'foo')
         
     | 
| 
       615 
685 
     | 
    
         
             
                Topic.connection.unprepared_statement do
         
     | 
| 
       616 
686 
     | 
    
         
             
                  Topic.find(topic.id).destroy
         
     | 
| 
         @@ -620,12 +690,14 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       620 
690 
     | 
    
         
             
              end
         
     | 
| 
       621 
691 
     | 
    
         | 
| 
       622 
692 
     | 
    
         
             
              def test_comparison_with_different_objects
         
     | 
| 
      
 693 
     | 
    
         
            +
                puts "In base_test test_comparison_with_different_objects"
         
     | 
| 
       623 
694 
     | 
    
         
             
                topic = Topic.create
         
     | 
| 
       624 
695 
     | 
    
         
             
                category = Category.create(:name => "comparison")
         
     | 
| 
       625 
696 
     | 
    
         
             
                assert_nil topic <=> category
         
     | 
| 
       626 
697 
     | 
    
         
             
              end
         
     | 
| 
       627 
698 
     | 
    
         | 
| 
       628 
699 
     | 
    
         
             
              def test_comparison_with_different_objects_in_array
         
     | 
| 
      
 700 
     | 
    
         
            +
                puts "In base_test test_comparison_with_different_objects_in_array"
         
     | 
| 
       629 
701 
     | 
    
         
             
                topic = Topic.create
         
     | 
| 
       630 
702 
     | 
    
         
             
                assert_raises(ArgumentError) do
         
     | 
| 
       631 
703 
     | 
    
         
             
                  [1, topic].sort
         
     | 
| 
         @@ -633,6 +705,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       633 
705 
     | 
    
         
             
              end
         
     | 
| 
       634 
706 
     | 
    
         | 
| 
       635 
707 
     | 
    
         
             
              def test_readonly_attributes
         
     | 
| 
      
 708 
     | 
    
         
            +
                puts "In base_test test_readonly_attributes"
         
     | 
| 
       636 
709 
     | 
    
         
             
                assert_equal Set.new([ 'title' , 'comments_count' ]), ReadonlyTitlePost.readonly_attributes
         
     | 
| 
       637 
710 
     | 
    
         | 
| 
       638 
711 
     | 
    
         
             
                post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable")
         
     | 
| 
         @@ -646,6 +719,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       646 
719 
     | 
    
         
             
              end
         
     | 
| 
       647 
720 
     | 
    
         | 
| 
       648 
721 
     | 
    
         
             
              def test_unicode_column_name
         
     | 
| 
      
 722 
     | 
    
         
            +
                puts "In base_test test_unicode_column_name"
         
     | 
| 
       649 
723 
     | 
    
         
             
                Weird.reset_column_information
         
     | 
| 
       650 
724 
     | 
    
         
             
                weird = Weird.create(:なまえ => 'たこ焼き仮面')
         
     | 
| 
       651 
725 
     | 
    
         
             
                assert_equal 'たこ焼き仮面', weird.なまえ
         
     | 
| 
         @@ -653,6 +727,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       653 
727 
     | 
    
         | 
| 
       654 
728 
     | 
    
         
             
              unless current_adapter?(:PostgreSQLAdapter)
         
     | 
| 
       655 
729 
     | 
    
         
             
                def test_respect_internal_encoding
         
     | 
| 
      
 730 
     | 
    
         
            +
            	  puts "In base_test test_respect_internal_encoding"
         
     | 
| 
       656 
731 
     | 
    
         
             
                  old_default_internal = Encoding.default_internal
         
     | 
| 
       657 
732 
     | 
    
         
             
                  silence_warnings { Encoding.default_internal = "EUC-JP" }
         
     | 
| 
       658 
733 
     | 
    
         | 
| 
         @@ -666,6 +741,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       666 
741 
     | 
    
         
             
              end
         
     | 
| 
       667 
742 
     | 
    
         | 
| 
       668 
743 
     | 
    
         
             
              def test_non_valid_identifier_column_name
         
     | 
| 
      
 744 
     | 
    
         
            +
                puts "In base_test test_non_valid_identifier_column_name"
         
     | 
| 
       669 
745 
     | 
    
         
             
                weird = Weird.create('a$b' => 'value')
         
     | 
| 
       670 
746 
     | 
    
         
             
                weird.reload
         
     | 
| 
       671 
747 
     | 
    
         
             
                assert_equal 'value', weird.send('a$b')
         
     | 
| 
         @@ -678,12 +754,14 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       678 
754 
     | 
    
         
             
              end
         
     | 
| 
       679 
755 
     | 
    
         | 
| 
       680 
756 
     | 
    
         
             
              def test_group_weirds_by_from
         
     | 
| 
      
 757 
     | 
    
         
            +
                puts "In base_test test_group_weirds_by_from"
         
     | 
| 
       681 
758 
     | 
    
         
             
                Weird.create('a$b' => 'value', :from => 'aaron')
         
     | 
| 
       682 
759 
     | 
    
         
             
                count = Weird.group(Weird.arel_table[:from]).count
         
     | 
| 
       683 
760 
     | 
    
         
             
                assert_equal 1, count['aaron']
         
     | 
| 
       684 
761 
     | 
    
         
             
              end
         
     | 
| 
       685 
762 
     | 
    
         | 
| 
       686 
763 
     | 
    
         
             
              def test_attributes_on_dummy_time
         
     | 
| 
      
 764 
     | 
    
         
            +
                puts "In base_test test_attributes_on_dummy_time"
         
     | 
| 
       687 
765 
     | 
    
         
             
                # Oracle does not have a TIME datatype.
         
     | 
| 
       688 
766 
     | 
    
         
             
                return true if current_adapter?(:OracleAdapter)
         
     | 
| 
       689 
767 
     | 
    
         | 
| 
         @@ -698,6 +776,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       698 
776 
     | 
    
         
             
              end
         
     | 
| 
       699 
777 
     | 
    
         | 
| 
       700 
778 
     | 
    
         
             
              def test_attributes_on_dummy_time_with_invalid_time
         
     | 
| 
      
 779 
     | 
    
         
            +
                puts "In base_test test_attributes_on_dummy_time_with_invalid_time"
         
     | 
| 
       701 
780 
     | 
    
         
             
                # Oracle does not have a TIME datatype.
         
     | 
| 
       702 
781 
     | 
    
         
             
                return true if current_adapter?(:OracleAdapter)
         
     | 
| 
       703 
782 
     | 
    
         | 
| 
         @@ -710,6 +789,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       710 
789 
     | 
    
         
             
              end
         
     | 
| 
       711 
790 
     | 
    
         | 
| 
       712 
791 
     | 
    
         
             
              def test_boolean
         
     | 
| 
      
 792 
     | 
    
         
            +
                puts "In base_test test_boolean"
         
     | 
| 
       713 
793 
     | 
    
         
             
                b_nil = Boolean.create({ "value" => nil })
         
     | 
| 
       714 
794 
     | 
    
         
             
                nil_id = b_nil.id
         
     | 
| 
       715 
795 
     | 
    
         
             
                b_false = Boolean.create({ "value" => false })
         
     | 
| 
         @@ -726,6 +806,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       726 
806 
     | 
    
         
             
              end
         
     | 
| 
       727 
807 
     | 
    
         | 
| 
       728 
808 
     | 
    
         
             
              def test_boolean_without_questionmark
         
     | 
| 
      
 809 
     | 
    
         
            +
                puts "In base_test test_boolean_without_questionmark"
         
     | 
| 
       729 
810 
     | 
    
         
             
                b_true = Boolean.create({ "value" => true })
         
     | 
| 
       730 
811 
     | 
    
         
             
                true_id = b_true.id
         
     | 
| 
       731 
812 
     | 
    
         | 
| 
         @@ -736,6 +817,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       736 
817 
     | 
    
         
             
              end
         
     | 
| 
       737 
818 
     | 
    
         | 
| 
       738 
819 
     | 
    
         
             
              def test_boolean_cast_from_string
         
     | 
| 
      
 820 
     | 
    
         
            +
                puts "In base_test test_boolean_cast_from_string"
         
     | 
| 
       739 
821 
     | 
    
         
             
                b_blank = Boolean.create({ "value" => "" })
         
     | 
| 
       740 
822 
     | 
    
         
             
                blank_id = b_blank.id
         
     | 
| 
       741 
823 
     | 
    
         
             
                b_false = Boolean.create({ "value" => "0" })
         
     | 
| 
         @@ -752,11 +834,13 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       752 
834 
     | 
    
         
             
              end
         
     | 
| 
       753 
835 
     | 
    
         | 
| 
       754 
836 
     | 
    
         
             
              def test_new_record_returns_boolean
         
     | 
| 
      
 837 
     | 
    
         
            +
                puts "In base_test test_new_record_returns_boolean"
         
     | 
| 
       755 
838 
     | 
    
         
             
                assert_equal false, Topic.new.persisted?
         
     | 
| 
       756 
839 
     | 
    
         
             
                assert_equal true, Topic.find(1).persisted?
         
     | 
| 
       757 
840 
     | 
    
         
             
              end
         
     | 
| 
       758 
841 
     | 
    
         | 
| 
       759 
842 
     | 
    
         
             
              def test_dup
         
     | 
| 
      
 843 
     | 
    
         
            +
                puts "In base_test test_dup"
         
     | 
| 
       760 
844 
     | 
    
         
             
                topic = Topic.find(1)
         
     | 
| 
       761 
845 
     | 
    
         
             
                duped_topic = nil
         
     | 
| 
       762 
846 
     | 
    
         
             
                assert_nothing_raised { duped_topic = topic.dup }
         
     | 
| 
         @@ -788,6 +872,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       788 
872 
     | 
    
         | 
| 
       789 
873 
     | 
    
         
             
              DeveloperSalary = Struct.new(:amount)
         
     | 
| 
       790 
874 
     | 
    
         
             
              def test_dup_with_aggregate_of_same_name_as_attribute
         
     | 
| 
      
 875 
     | 
    
         
            +
                puts "In base_test test_dup_with_aggregate_of_same_name_as_attribute"
         
     | 
| 
       791 
876 
     | 
    
         
             
                developer_with_aggregate = Class.new(ActiveRecord::Base) do
         
     | 
| 
       792 
877 
     | 
    
         
             
                  self.table_name = 'developers'
         
     | 
| 
       793 
878 
     | 
    
         
             
                  composed_of :salary, :class_name => 'BasicsTest::DeveloperSalary', :mapping => [%w(salary amount)]
         
     | 
| 
         @@ -802,7 +887,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       802 
887 
     | 
    
         
             
                assert_equal dev.salary.amount, dup.salary.amount
         
     | 
| 
       803 
888 
     | 
    
         
             
                assert !dup.persisted?
         
     | 
| 
       804 
889 
     | 
    
         | 
| 
       805 
     | 
    
         
            -
                # test if the attributes have been  
     | 
| 
      
 890 
     | 
    
         
            +
                # test if the attributes have been duped
         
     | 
| 
       806 
891 
     | 
    
         
             
                original_amount = dup.salary.amount
         
     | 
| 
       807 
892 
     | 
    
         
             
                dev.salary.amount = 1
         
     | 
| 
       808 
893 
     | 
    
         
             
                assert_equal original_amount, dup.salary.amount
         
     | 
| 
         @@ -813,21 +898,23 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       813 
898 
     | 
    
         
             
              end
         
     | 
| 
       814 
899 
     | 
    
         | 
| 
       815 
900 
     | 
    
         
             
              def test_dup_does_not_copy_associations
         
     | 
| 
      
 901 
     | 
    
         
            +
                puts "In base_test test_dup_does_not_copy_associations"
         
     | 
| 
       816 
902 
     | 
    
         
             
                author = authors(:david)
         
     | 
| 
       817 
903 
     | 
    
         
             
                assert_not_equal [], author.posts
         
     | 
| 
       818 
     | 
    
         
            -
                author.send(:clear_association_cache)
         
     | 
| 
       819 
904 
     | 
    
         | 
| 
       820 
905 
     | 
    
         
             
                author_dup = author.dup
         
     | 
| 
       821 
906 
     | 
    
         
             
                assert_equal [], author_dup.posts
         
     | 
| 
       822 
907 
     | 
    
         
             
              end
         
     | 
| 
       823 
908 
     | 
    
         | 
| 
       824 
909 
     | 
    
         
             
              def test_clone_preserves_subtype
         
     | 
| 
      
 910 
     | 
    
         
            +
                puts "In base_test test_clone_preserves_subtype"
         
     | 
| 
       825 
911 
     | 
    
         
             
                clone = nil
         
     | 
| 
       826 
912 
     | 
    
         
             
                assert_nothing_raised { clone = Company.find(3).clone }
         
     | 
| 
       827 
913 
     | 
    
         
             
                assert_kind_of Client, clone
         
     | 
| 
       828 
914 
     | 
    
         
             
              end
         
     | 
| 
       829 
915 
     | 
    
         | 
| 
       830 
916 
     | 
    
         
             
              def test_clone_of_new_object_with_defaults
         
     | 
| 
      
 917 
     | 
    
         
            +
                puts "In base_test test_clone_of_new_object_with_defaults"
         
     | 
| 
       831 
918 
     | 
    
         
             
                developer = Developer.new
         
     | 
| 
       832 
919 
     | 
    
         
             
                assert !developer.name_changed?
         
     | 
| 
       833 
920 
     | 
    
         
             
                assert !developer.salary_changed?
         
     | 
| 
         @@ -838,6 +925,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       838 
925 
     | 
    
         
             
              end
         
     | 
| 
       839 
926 
     | 
    
         | 
| 
       840 
927 
     | 
    
         
             
              def test_clone_of_new_object_marks_attributes_as_dirty
         
     | 
| 
      
 928 
     | 
    
         
            +
                puts "In base_test test_clone_of_new_object_marks_attributes_as_dirty"
         
     | 
| 
       841 
929 
     | 
    
         
             
                developer = Developer.new :name => 'Bjorn', :salary => 100000
         
     | 
| 
       842 
930 
     | 
    
         
             
                assert developer.name_changed?
         
     | 
| 
       843 
931 
     | 
    
         
             
                assert developer.salary_changed?
         
     | 
| 
         @@ -848,6 +936,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       848 
936 
     | 
    
         
             
              end
         
     | 
| 
       849 
937 
     | 
    
         | 
| 
       850 
938 
     | 
    
         
             
              def test_clone_of_new_object_marks_as_dirty_only_changed_attributes
         
     | 
| 
      
 939 
     | 
    
         
            +
                puts "In base_test test_clone_of_new_object_marks_as_dirty_only_changed_attributes"
         
     | 
| 
       851 
940 
     | 
    
         
             
                developer = Developer.new :name => 'Bjorn'
         
     | 
| 
       852 
941 
     | 
    
         
             
                assert developer.name_changed?            # obviously
         
     | 
| 
       853 
942 
     | 
    
         
             
                assert !developer.salary_changed?         # attribute has non-nil default value, so treated as not changed
         
     | 
| 
         @@ -858,6 +947,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       858 
947 
     | 
    
         
             
              end
         
     | 
| 
       859 
948 
     | 
    
         | 
| 
       860 
949 
     | 
    
         
             
              def test_dup_of_saved_object_marks_attributes_as_dirty
         
     | 
| 
      
 950 
     | 
    
         
            +
                puts "In base_test test_dup_of_saved_object_marks_attributes_as_dirty"
         
     | 
| 
       861 
951 
     | 
    
         
             
                developer = Developer.create! :name => 'Bjorn', :salary => 100000
         
     | 
| 
       862 
952 
     | 
    
         
             
                assert !developer.name_changed?
         
     | 
| 
       863 
953 
     | 
    
         
             
                assert !developer.salary_changed?
         
     | 
| 
         @@ -868,6 +958,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       868 
958 
     | 
    
         
             
              end
         
     | 
| 
       869 
959 
     | 
    
         | 
| 
       870 
960 
     | 
    
         
             
              def test_dup_of_saved_object_marks_as_dirty_only_changed_attributes
         
     | 
| 
      
 961 
     | 
    
         
            +
                puts "In base_test test_dup_of_saved_object_marks_as_dirty_only_changed_attributes"
         
     | 
| 
       871 
962 
     | 
    
         
             
                developer = Developer.create! :name => 'Bjorn'
         
     | 
| 
       872 
963 
     | 
    
         
             
                assert !developer.name_changed?           # both attributes of saved object should be treated as not changed
         
     | 
| 
       873 
964 
     | 
    
         
             
                assert !developer.salary_changed?
         
     | 
| 
         @@ -878,6 +969,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       878 
969 
     | 
    
         
             
              end
         
     | 
| 
       879 
970 
     | 
    
         | 
| 
       880 
971 
     | 
    
         
             
              def test_bignum
         
     | 
| 
      
 972 
     | 
    
         
            +
                puts "In base_test test_bignum"
         
     | 
| 
       881 
973 
     | 
    
         
             
                company = Company.find(1)
         
     | 
| 
       882 
974 
     | 
    
         
             
                company.rating = 2147483647
         
     | 
| 
       883 
975 
     | 
    
         
             
                company.save
         
     | 
| 
         @@ -888,6 +980,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       888 
980 
     | 
    
         
             
              # TODO: extend defaults tests to other databases!
         
     | 
| 
       889 
981 
     | 
    
         
             
              if current_adapter?(:PostgreSQLAdapter)
         
     | 
| 
       890 
982 
     | 
    
         
             
                def test_default
         
     | 
| 
      
 983 
     | 
    
         
            +
            	  puts "In base_test test_default"
         
     | 
| 
       891 
984 
     | 
    
         
             
                  with_timezone_config default: :local do
         
     | 
| 
       892 
985 
     | 
    
         
             
                    default = Default.new
         
     | 
| 
       893 
986 
     | 
    
         | 
| 
         @@ -901,103 +994,17 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       901 
994 
     | 
    
         
             
                    assert_equal 'a text field', default.char3
         
     | 
| 
       902 
995 
     | 
    
         
             
                  end
         
     | 
| 
       903 
996 
     | 
    
         
             
                end
         
     | 
| 
       904 
     | 
    
         
            -
             
     | 
| 
       905 
     | 
    
         
            -
                class Geometric < ActiveRecord::Base; end
         
     | 
| 
       906 
     | 
    
         
            -
                def test_geometric_content
         
     | 
| 
       907 
     | 
    
         
            -
             
     | 
| 
       908 
     | 
    
         
            -
                  # accepted format notes:
         
     | 
| 
       909 
     | 
    
         
            -
                  # ()'s aren't required
         
     | 
| 
       910 
     | 
    
         
            -
                  # values can be a mix of float or integer
         
     | 
| 
       911 
     | 
    
         
            -
             
     | 
| 
       912 
     | 
    
         
            -
                  g = Geometric.new(
         
     | 
| 
       913 
     | 
    
         
            -
                    :a_point        => '(5.0, 6.1)',
         
     | 
| 
       914 
     | 
    
         
            -
                    #:a_line         => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql
         
     | 
| 
       915 
     | 
    
         
            -
                    :a_line_segment => '(2.0, 3), (5.5, 7.0)',
         
     | 
| 
       916 
     | 
    
         
            -
                    :a_box          => '2.0, 3, 5.5, 7.0',
         
     | 
| 
       917 
     | 
    
         
            -
                    :a_path         => '[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]',  # [ ] is an open path
         
     | 
| 
       918 
     | 
    
         
            -
                    :a_polygon      => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))',
         
     | 
| 
       919 
     | 
    
         
            -
                    :a_circle       => '<(5.3, 10.4), 2>'
         
     | 
| 
       920 
     | 
    
         
            -
                  )
         
     | 
| 
       921 
     | 
    
         
            -
             
     | 
| 
       922 
     | 
    
         
            -
                  assert g.save
         
     | 
| 
       923 
     | 
    
         
            -
             
     | 
| 
       924 
     | 
    
         
            -
                  # Reload and check that we have all the geometric attributes.
         
     | 
| 
       925 
     | 
    
         
            -
                  h = Geometric.find(g.id)
         
     | 
| 
       926 
     | 
    
         
            -
             
     | 
| 
       927 
     | 
    
         
            -
                  assert_equal [5.0, 6.1], h.a_point
         
     | 
| 
       928 
     | 
    
         
            -
                  assert_equal '[(2,3),(5.5,7)]', h.a_line_segment
         
     | 
| 
       929 
     | 
    
         
            -
                  assert_equal '(5.5,7),(2,3)', h.a_box   # reordered to store upper right corner then bottom left corner
         
     | 
| 
       930 
     | 
    
         
            -
                  assert_equal '[(2,3),(5.5,7),(8.5,11)]', h.a_path
         
     | 
| 
       931 
     | 
    
         
            -
                  assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon
         
     | 
| 
       932 
     | 
    
         
            -
                  assert_equal '<(5.3,10.4),2>', h.a_circle
         
     | 
| 
       933 
     | 
    
         
            -
             
     | 
| 
       934 
     | 
    
         
            -
                  # use a geometric function to test for an open path
         
     | 
| 
       935 
     | 
    
         
            -
                  objs = Geometric.find_by_sql ["select isopen(a_path) from geometrics where id = ?", g.id]
         
     | 
| 
       936 
     | 
    
         
            -
             
     | 
| 
       937 
     | 
    
         
            -
                  assert_equal true, objs[0].isopen
         
     | 
| 
       938 
     | 
    
         
            -
             
     | 
| 
       939 
     | 
    
         
            -
                  # test alternate formats when defining the geometric types
         
     | 
| 
       940 
     | 
    
         
            -
             
     | 
| 
       941 
     | 
    
         
            -
                  g = Geometric.new(
         
     | 
| 
       942 
     | 
    
         
            -
                    :a_point        => '5.0, 6.1',
         
     | 
| 
       943 
     | 
    
         
            -
                    #:a_line         => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql
         
     | 
| 
       944 
     | 
    
         
            -
                    :a_line_segment => '((2.0, 3), (5.5, 7.0))',
         
     | 
| 
       945 
     | 
    
         
            -
                    :a_box          => '(2.0, 3), (5.5, 7.0)',
         
     | 
| 
       946 
     | 
    
         
            -
                    :a_path         => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))',  # ( ) is a closed path
         
     | 
| 
       947 
     | 
    
         
            -
                    :a_polygon      => '2.0, 3, 5.5, 7.0, 8.5, 11.0',
         
     | 
| 
       948 
     | 
    
         
            -
                    :a_circle       => '((5.3, 10.4), 2)'
         
     | 
| 
       949 
     | 
    
         
            -
                  )
         
     | 
| 
       950 
     | 
    
         
            -
             
     | 
| 
       951 
     | 
    
         
            -
                  assert g.save
         
     | 
| 
       952 
     | 
    
         
            -
             
     | 
| 
       953 
     | 
    
         
            -
                  # Reload and check that we have all the geometric attributes.
         
     | 
| 
       954 
     | 
    
         
            -
                  h = Geometric.find(g.id)
         
     | 
| 
       955 
     | 
    
         
            -
             
     | 
| 
       956 
     | 
    
         
            -
                  assert_equal [5.0, 6.1], h.a_point
         
     | 
| 
       957 
     | 
    
         
            -
                  assert_equal '[(2,3),(5.5,7)]', h.a_line_segment
         
     | 
| 
       958 
     | 
    
         
            -
                  assert_equal '(5.5,7),(2,3)', h.a_box   # reordered to store upper right corner then bottom left corner
         
     | 
| 
       959 
     | 
    
         
            -
                  assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_path
         
     | 
| 
       960 
     | 
    
         
            -
                  assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon
         
     | 
| 
       961 
     | 
    
         
            -
                  assert_equal '<(5.3,10.4),2>', h.a_circle
         
     | 
| 
       962 
     | 
    
         
            -
             
     | 
| 
       963 
     | 
    
         
            -
                  # use a geometric function to test for an closed path
         
     | 
| 
       964 
     | 
    
         
            -
                  objs = Geometric.find_by_sql ["select isclosed(a_path) from geometrics where id = ?", g.id]
         
     | 
| 
       965 
     | 
    
         
            -
             
     | 
| 
       966 
     | 
    
         
            -
                  assert_equal true, objs[0].isclosed
         
     | 
| 
       967 
     | 
    
         
            -
             
     | 
| 
       968 
     | 
    
         
            -
                  # test native ruby formats when defining the geometric types
         
     | 
| 
       969 
     | 
    
         
            -
                  g = Geometric.new(
         
     | 
| 
       970 
     | 
    
         
            -
                    :a_point        => [5.0, 6.1],
         
     | 
| 
       971 
     | 
    
         
            -
                    #:a_line         => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql
         
     | 
| 
       972 
     | 
    
         
            -
                    :a_line_segment => '((2.0, 3), (5.5, 7.0))',
         
     | 
| 
       973 
     | 
    
         
            -
                    :a_box          => '(2.0, 3), (5.5, 7.0)',
         
     | 
| 
       974 
     | 
    
         
            -
                    :a_path         => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))',  # ( ) is a closed path
         
     | 
| 
       975 
     | 
    
         
            -
                    :a_polygon      => '2.0, 3, 5.5, 7.0, 8.5, 11.0',
         
     | 
| 
       976 
     | 
    
         
            -
                    :a_circle       => '((5.3, 10.4), 2)'
         
     | 
| 
       977 
     | 
    
         
            -
                  )
         
     | 
| 
       978 
     | 
    
         
            -
             
     | 
| 
       979 
     | 
    
         
            -
                  assert g.save
         
     | 
| 
       980 
     | 
    
         
            -
             
     | 
| 
       981 
     | 
    
         
            -
                  # Reload and check that we have all the geometric attributes.
         
     | 
| 
       982 
     | 
    
         
            -
                  h = Geometric.find(g.id)
         
     | 
| 
       983 
     | 
    
         
            -
             
     | 
| 
       984 
     | 
    
         
            -
                  assert_equal [5.0, 6.1], h.a_point
         
     | 
| 
       985 
     | 
    
         
            -
                  assert_equal '[(2,3),(5.5,7)]', h.a_line_segment
         
     | 
| 
       986 
     | 
    
         
            -
                  assert_equal '(5.5,7),(2,3)', h.a_box   # reordered to store upper right corner then bottom left corner
         
     | 
| 
       987 
     | 
    
         
            -
                  assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_path
         
     | 
| 
       988 
     | 
    
         
            -
                  assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon
         
     | 
| 
       989 
     | 
    
         
            -
                  assert_equal '<(5.3,10.4),2>', h.a_circle
         
     | 
| 
       990 
     | 
    
         
            -
                end
         
     | 
| 
       991 
997 
     | 
    
         
             
              end
         
     | 
| 
       992 
998 
     | 
    
         | 
| 
       993 
999 
     | 
    
         
             
              class NumericData < ActiveRecord::Base
         
     | 
| 
       994 
1000 
     | 
    
         
             
                self.table_name = 'numeric_data'
         
     | 
| 
       995 
1001 
     | 
    
         | 
| 
       996 
     | 
    
         
            -
                attribute :my_house_population,  
     | 
| 
       997 
     | 
    
         
            -
                attribute :atoms_in_universe,  
     | 
| 
      
 1002 
     | 
    
         
            +
                attribute :my_house_population, :integer
         
     | 
| 
      
 1003 
     | 
    
         
            +
                attribute :atoms_in_universe, :integer
         
     | 
| 
       998 
1004 
     | 
    
         
             
              end
         
     | 
| 
       999 
1005 
     | 
    
         | 
| 
       1000 
1006 
     | 
    
         
             
              def test_big_decimal_conditions
         
     | 
| 
      
 1007 
     | 
    
         
            +
                puts "In base_test test_big_decimal_conditions"
         
     | 
| 
       1001 
1008 
     | 
    
         
             
                m = NumericData.new(
         
     | 
| 
       1002 
1009 
     | 
    
         
             
                  :bank_balance => 1586.43,
         
     | 
| 
       1003 
1010 
     | 
    
         
             
                  :big_bank_balance => BigDecimal("1000234000567.95"),
         
     | 
| 
         @@ -1009,6 +1016,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1009 
1016 
     | 
    
         
             
              end
         
     | 
| 
       1010 
1017 
     | 
    
         | 
| 
       1011 
1018 
     | 
    
         
             
              def test_numeric_fields
         
     | 
| 
      
 1019 
     | 
    
         
            +
                puts "In base_test test_numeric_fields"
         
     | 
| 
       1012 
1020 
     | 
    
         
             
                m = NumericData.new(
         
     | 
| 
       1013 
1021 
     | 
    
         
             
                  :bank_balance => 1586.43,
         
     | 
| 
       1014 
1022 
     | 
    
         
             
                  :big_bank_balance => BigDecimal("1000234000567.95"),
         
     | 
| 
         @@ -1024,21 +1032,22 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1024 
1032 
     | 
    
         
             
                # to cover 64-bit platforms and test it is a Bignum, but the main thing
         
     | 
| 
       1025 
1033 
     | 
    
         
             
                # is that it's an Integer.
         
     | 
| 
       1026 
1034 
     | 
    
         
             
                unless current_adapter?(:IBM_DBAdapter)
         
     | 
| 
       1027 
     | 
    
         
            -
             
     | 
| 
       1028 
     | 
    
         
            -
             
     | 
| 
       1029 
     | 
    
         
            -
             
     | 
| 
      
 1035 
     | 
    
         
            +
            	assert_kind_of Integer, m1.world_population
         
     | 
| 
      
 1036 
     | 
    
         
            +
                else
         
     | 
| 
      
 1037 
     | 
    
         
            +
            	assert_equal 6000000000, m1.world_population
         
     | 
| 
       1030 
1038 
     | 
    
         | 
| 
       1031 
     | 
    
         
            -
             
     | 
| 
       1032 
     | 
    
         
            -
             
     | 
| 
      
 1039 
     | 
    
         
            +
                assert_kind_of Integer, m1.my_house_population
         
     | 
| 
      
 1040 
     | 
    
         
            +
                assert_equal 3, m1.my_house_population
         
     | 
| 
       1033 
1041 
     | 
    
         | 
| 
       1034 
     | 
    
         
            -
             
     | 
| 
       1035 
     | 
    
         
            -
             
     | 
| 
      
 1042 
     | 
    
         
            +
                assert_kind_of BigDecimal, m1.bank_balance
         
     | 
| 
      
 1043 
     | 
    
         
            +
                assert_equal BigDecimal("1586.43"), m1.bank_balance
         
     | 
| 
       1036 
1044 
     | 
    
         | 
| 
       1037 
     | 
    
         
            -
             
     | 
| 
       1038 
     | 
    
         
            -
             
     | 
| 
      
 1045 
     | 
    
         
            +
                assert_kind_of BigDecimal, m1.big_bank_balance
         
     | 
| 
      
 1046 
     | 
    
         
            +
                assert_equal BigDecimal("1000234000567.95"), m1.big_bank_balance
         
     | 
| 
       1039 
1047 
     | 
    
         
             
              end
         
     | 
| 
       1040 
1048 
     | 
    
         | 
| 
       1041 
1049 
     | 
    
         
             
              def test_numeric_fields_with_scale
         
     | 
| 
      
 1050 
     | 
    
         
            +
                puts "In base_test test_numeric_fields_with_scale"
         
     | 
| 
       1042 
1051 
     | 
    
         
             
                m = NumericData.new(
         
     | 
| 
       1043 
1052 
     | 
    
         
             
                  :bank_balance => 1586.43122334,
         
     | 
| 
       1044 
1053 
     | 
    
         
             
                  :big_bank_balance => BigDecimal("234000567.952344"),
         
     | 
| 
         @@ -1056,11 +1065,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1056 
1065 
     | 
    
         
             
                assert_kind_of Integer, m1.world_population
         
     | 
| 
       1057 
1066 
     | 
    
         
             
                assert_equal 6000000000, m1.world_population
         
     | 
| 
       1058 
1067 
     | 
    
         | 
| 
       1059 
     | 
    
         
            -
                 
     | 
| 
       1060 
     | 
    
         
            -
                  assert_kind_of Fixnum, m1.my_house_population
         
     | 
| 
       1061 
     | 
    
         
            -
                else
         
     | 
| 
       1062 
     | 
    
         
            -
                  assert_kind_of BigDecimal, m1.my_house_population
         
     | 
| 
       1063 
     | 
    
         
            -
                end
         
     | 
| 
      
 1068 
     | 
    
         
            +
                assert_kind_of Integer, m1.my_house_population
         
     | 
| 
       1064 
1069 
     | 
    
         
             
                assert_equal 3, m1.my_house_population
         
     | 
| 
       1065 
1070 
     | 
    
         | 
| 
       1066 
1071 
     | 
    
         
             
                assert_kind_of BigDecimal, m1.bank_balance
         
     | 
| 
         @@ -1071,18 +1076,21 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1071 
1076 
     | 
    
         
             
              end
         
     | 
| 
       1072 
1077 
     | 
    
         | 
| 
       1073 
1078 
     | 
    
         
             
              def test_auto_id
         
     | 
| 
      
 1079 
     | 
    
         
            +
                puts "In base_test test_auto_id"
         
     | 
| 
       1074 
1080 
     | 
    
         
             
                auto = AutoId.new
         
     | 
| 
       1075 
1081 
     | 
    
         
             
                auto.save
         
     | 
| 
       1076 
1082 
     | 
    
         
             
                assert(auto.id > 0)
         
     | 
| 
       1077 
1083 
     | 
    
         
             
              end
         
     | 
| 
       1078 
1084 
     | 
    
         | 
| 
       1079 
1085 
     | 
    
         
             
              def test_sql_injection_via_find
         
     | 
| 
      
 1086 
     | 
    
         
            +
                puts "In base_test test_sql_injection_via_find"
         
     | 
| 
       1080 
1087 
     | 
    
         
             
                assert_raise(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do
         
     | 
| 
       1081 
1088 
     | 
    
         
             
                  Topic.find("123456 OR id > 0")
         
     | 
| 
       1082 
1089 
     | 
    
         
             
                end
         
     | 
| 
       1083 
1090 
     | 
    
         
             
              end
         
     | 
| 
       1084 
1091 
     | 
    
         | 
| 
       1085 
1092 
     | 
    
         
             
              def test_column_name_properly_quoted
         
     | 
| 
      
 1093 
     | 
    
         
            +
                puts "In base_test test_column_name_properly_quoted"
         
     | 
| 
       1086 
1094 
     | 
    
         
             
                col_record = ColumnName.new
         
     | 
| 
       1087 
1095 
     | 
    
         
             
                col_record.references = 40
         
     | 
| 
       1088 
1096 
     | 
    
         
             
                assert col_record.save
         
     | 
| 
         @@ -1093,6 +1101,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1093 
1101 
     | 
    
         
             
              end
         
     | 
| 
       1094 
1102 
     | 
    
         | 
| 
       1095 
1103 
     | 
    
         
             
              def test_quoting_arrays
         
     | 
| 
      
 1104 
     | 
    
         
            +
                puts "In base_test test_quoting_arrays"
         
     | 
| 
       1096 
1105 
     | 
    
         
             
                replies = Reply.all.merge!(:where => [ "id IN (?)", topics(:first).replies.collect(&:id) ]).to_a
         
     | 
| 
       1097 
1106 
     | 
    
         
             
                assert_equal topics(:first).replies.size, replies.size
         
     | 
| 
       1098 
1107 
     | 
    
         | 
| 
         @@ -1101,12 +1110,14 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1101 
1110 
     | 
    
         
             
              end
         
     | 
| 
       1102 
1111 
     | 
    
         | 
| 
       1103 
1112 
     | 
    
         
             
              def test_quote
         
     | 
| 
      
 1113 
     | 
    
         
            +
                puts "In base_test test_quote"
         
     | 
| 
       1104 
1114 
     | 
    
         
             
                author_name = "\\ \001 ' \n \\n \""
         
     | 
| 
       1105 
1115 
     | 
    
         
             
                topic = Topic.create('author_name' => author_name)
         
     | 
| 
       1106 
1116 
     | 
    
         
             
                assert_equal author_name, Topic.find(topic.id).author_name
         
     | 
| 
       1107 
1117 
     | 
    
         
             
              end
         
     | 
| 
       1108 
1118 
     | 
    
         | 
| 
       1109 
1119 
     | 
    
         
             
              def test_toggle_attribute
         
     | 
| 
      
 1120 
     | 
    
         
            +
                puts "In base_test test_toggle_attribute"
         
     | 
| 
       1110 
1121 
     | 
    
         
             
                assert !topics(:first).approved?
         
     | 
| 
       1111 
1122 
     | 
    
         
             
                topics(:first).toggle!(:approved)
         
     | 
| 
       1112 
1123 
     | 
    
         
             
                assert topics(:first).approved?
         
     | 
| 
         @@ -1118,6 +1129,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1118 
1129 
     | 
    
         
             
              end
         
     | 
| 
       1119 
1130 
     | 
    
         | 
| 
       1120 
1131 
     | 
    
         
             
              def test_reload
         
     | 
| 
      
 1132 
     | 
    
         
            +
                puts "In base_test test_reload"
         
     | 
| 
       1121 
1133 
     | 
    
         
             
                t1 = Topic.find(1)
         
     | 
| 
       1122 
1134 
     | 
    
         
             
                t2 = Topic.find(1)
         
     | 
| 
       1123 
1135 
     | 
    
         
             
                t1.title = "something else"
         
     | 
| 
         @@ -1127,63 +1139,77 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1127 
1139 
     | 
    
         
             
              end
         
     | 
| 
       1128 
1140 
     | 
    
         | 
| 
       1129 
1141 
     | 
    
         
             
              def test_reload_with_exclusive_scope
         
     | 
| 
      
 1142 
     | 
    
         
            +
                puts "In base_test test_reload_with_exclusive_scope"
         
     | 
| 
       1130 
1143 
     | 
    
         
             
                dev = DeveloperCalledDavid.first
         
     | 
| 
       1131 
1144 
     | 
    
         
             
                dev.update!(name: "NotDavid" )
         
     | 
| 
       1132 
1145 
     | 
    
         
             
                assert_equal dev, dev.reload
         
     | 
| 
       1133 
1146 
     | 
    
         
             
              end
         
     | 
| 
       1134 
1147 
     | 
    
         | 
| 
       1135 
1148 
     | 
    
         
             
              def test_switching_between_table_name
         
     | 
| 
      
 1149 
     | 
    
         
            +
                puts "In base_test test_switching_between_table_name"
         
     | 
| 
      
 1150 
     | 
    
         
            +
                k = Class.new(Joke)
         
     | 
| 
      
 1151 
     | 
    
         
            +
             
     | 
| 
       1136 
1152 
     | 
    
         
             
                assert_difference("GoodJoke.count") do
         
     | 
| 
       1137 
     | 
    
         
            -
                   
     | 
| 
       1138 
     | 
    
         
            -
                   
     | 
| 
      
 1153 
     | 
    
         
            +
                  k.table_name = "cold_jokes"
         
     | 
| 
      
 1154 
     | 
    
         
            +
                  k.create
         
     | 
| 
       1139 
1155 
     | 
    
         | 
| 
       1140 
     | 
    
         
            -
                   
     | 
| 
       1141 
     | 
    
         
            -
                   
     | 
| 
      
 1156 
     | 
    
         
            +
                  k.table_name = "funny_jokes"
         
     | 
| 
      
 1157 
     | 
    
         
            +
                  k.create
         
     | 
| 
       1142 
1158 
     | 
    
         
             
                end
         
     | 
| 
       1143 
1159 
     | 
    
         
             
              end
         
     | 
| 
       1144 
1160 
     | 
    
         | 
| 
       1145 
1161 
     | 
    
         
             
              def test_clear_cash_when_setting_table_name
         
     | 
| 
       1146 
     | 
    
         
            -
                 
     | 
| 
       1147 
     | 
    
         
            -
                 
     | 
| 
       1148 
     | 
    
         
            -
                before_seq     = Joke.sequence_name
         
     | 
| 
      
 1162 
     | 
    
         
            +
                puts "In base_test test_clear_cash_when_setting_table_name"
         
     | 
| 
      
 1163 
     | 
    
         
            +
                original_table_name = Joke.table_name
         
     | 
| 
       1149 
1164 
     | 
    
         | 
| 
       1150 
1165 
     | 
    
         
             
                Joke.table_name = "funny_jokes"
         
     | 
| 
      
 1166 
     | 
    
         
            +
                before_columns = Joke.columns
         
     | 
| 
      
 1167 
     | 
    
         
            +
                before_seq = Joke.sequence_name
         
     | 
| 
      
 1168 
     | 
    
         
            +
             
     | 
| 
      
 1169 
     | 
    
         
            +
                Joke.table_name = "cold_jokes"
         
     | 
| 
       1151 
1170 
     | 
    
         
             
                after_columns = Joke.columns
         
     | 
| 
       1152 
     | 
    
         
            -
                after_seq 
     | 
| 
      
 1171 
     | 
    
         
            +
                after_seq = Joke.sequence_name
         
     | 
| 
       1153 
1172 
     | 
    
         | 
| 
       1154 
1173 
     | 
    
         
             
                assert_not_equal before_columns, after_columns
         
     | 
| 
       1155 
1174 
     | 
    
         
             
                assert_not_equal before_seq, after_seq unless before_seq.nil? && after_seq.nil?
         
     | 
| 
      
 1175 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 1176 
     | 
    
         
            +
                Joke.table_name = original_table_name
         
     | 
| 
       1156 
1177 
     | 
    
         
             
              end
         
     | 
| 
       1157 
1178 
     | 
    
         | 
| 
       1158 
1179 
     | 
    
         
             
              def test_dont_clear_sequence_name_when_setting_explicitly
         
     | 
| 
       1159 
     | 
    
         
            -
                 
     | 
| 
       1160 
     | 
    
         
            -
                 
     | 
| 
       1161 
     | 
    
         
            -
                 
     | 
| 
      
 1180 
     | 
    
         
            +
                puts "In base_test test_dont_clear_sequence_name_when_setting_explicitly"
         
     | 
| 
      
 1181 
     | 
    
         
            +
                k = Class.new(Joke)
         
     | 
| 
      
 1182 
     | 
    
         
            +
                k.sequence_name = "black_jokes_seq"
         
     | 
| 
      
 1183 
     | 
    
         
            +
                k.table_name = "cold_jokes"
         
     | 
| 
      
 1184 
     | 
    
         
            +
                before_seq = k.sequence_name
         
     | 
| 
       1162 
1185 
     | 
    
         | 
| 
       1163 
     | 
    
         
            -
                 
     | 
| 
       1164 
     | 
    
         
            -
                after_seq 
     | 
| 
      
 1186 
     | 
    
         
            +
                k.table_name = "funny_jokes"
         
     | 
| 
      
 1187 
     | 
    
         
            +
                after_seq = k.sequence_name
         
     | 
| 
       1165 
1188 
     | 
    
         | 
| 
       1166 
1189 
     | 
    
         
             
                assert_equal before_seq, after_seq unless before_seq.nil? && after_seq.nil?
         
     | 
| 
       1167 
     | 
    
         
            -
              ensure
         
     | 
| 
       1168 
     | 
    
         
            -
                Joke.reset_sequence_name
         
     | 
| 
       1169 
1190 
     | 
    
         
             
              end
         
     | 
| 
       1170 
1191 
     | 
    
         | 
| 
       1171 
1192 
     | 
    
         
             
              def test_dont_clear_inheritance_column_when_setting_explicitly
         
     | 
| 
       1172 
     | 
    
         
            -
                 
     | 
| 
       1173 
     | 
    
         
            -
                 
     | 
| 
      
 1193 
     | 
    
         
            +
                puts "In base_test test_dont_clear_inheritance_column_when_setting_explicitly"
         
     | 
| 
      
 1194 
     | 
    
         
            +
                k = Class.new(Joke)
         
     | 
| 
      
 1195 
     | 
    
         
            +
                k.inheritance_column = "my_type"
         
     | 
| 
      
 1196 
     | 
    
         
            +
                before_inherit = k.inheritance_column
         
     | 
| 
       1174 
1197 
     | 
    
         | 
| 
       1175 
     | 
    
         
            -
                 
     | 
| 
       1176 
     | 
    
         
            -
                after_inherit =  
     | 
| 
      
 1198 
     | 
    
         
            +
                k.reset_column_information
         
     | 
| 
      
 1199 
     | 
    
         
            +
                after_inherit = k.inheritance_column
         
     | 
| 
       1177 
1200 
     | 
    
         | 
| 
       1178 
1201 
     | 
    
         
             
                assert_equal before_inherit, after_inherit unless before_inherit.blank? && after_inherit.blank?
         
     | 
| 
       1179 
1202 
     | 
    
         
             
              end
         
     | 
| 
       1180 
1203 
     | 
    
         | 
| 
       1181 
1204 
     | 
    
         
             
              def test_set_table_name_symbol_converted_to_string
         
     | 
| 
       1182 
     | 
    
         
            -
                 
     | 
| 
       1183 
     | 
    
         
            -
                 
     | 
| 
      
 1205 
     | 
    
         
            +
                puts "In base_test test_set_table_name_symbol_converted_to_string"
         
     | 
| 
      
 1206 
     | 
    
         
            +
                k = Class.new(Joke)
         
     | 
| 
      
 1207 
     | 
    
         
            +
                k.table_name = :cold_jokes
         
     | 
| 
      
 1208 
     | 
    
         
            +
                assert_equal 'cold_jokes', k.table_name
         
     | 
| 
       1184 
1209 
     | 
    
         
             
              end
         
     | 
| 
       1185 
1210 
     | 
    
         | 
| 
       1186 
1211 
     | 
    
         
             
              def test_quoted_table_name_after_set_table_name
         
     | 
| 
      
 1212 
     | 
    
         
            +
                puts "In base_test test_quoted_table_name_after_set_table_name"
         
     | 
| 
       1187 
1213 
     | 
    
         
             
                klass = Class.new(ActiveRecord::Base)
         
     | 
| 
       1188 
1214 
     | 
    
         | 
| 
       1189 
1215 
     | 
    
         
             
                klass.table_name = "foo"
         
     | 
| 
         @@ -1196,6 +1222,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1196 
1222 
     | 
    
         
             
              end
         
     | 
| 
       1197 
1223 
     | 
    
         | 
| 
       1198 
1224 
     | 
    
         
             
              def test_set_table_name_with_inheritance
         
     | 
| 
      
 1225 
     | 
    
         
            +
                puts "In base_test test_set_table_name_with_inheritance"
         
     | 
| 
       1199 
1226 
     | 
    
         
             
                k = Class.new( ActiveRecord::Base )
         
     | 
| 
       1200 
1227 
     | 
    
         
             
                def k.name; "Foo"; end
         
     | 
| 
       1201 
1228 
     | 
    
         
             
                def k.table_name; super + "ks"; end
         
     | 
| 
         @@ -1203,6 +1230,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1203 
1230 
     | 
    
         
             
              end
         
     | 
| 
       1204 
1231 
     | 
    
         | 
| 
       1205 
1232 
     | 
    
         
             
              def test_sequence_name_with_abstract_class
         
     | 
| 
      
 1233 
     | 
    
         
            +
                puts "In base_test test_sequence_name_with_abstract_class"
         
     | 
| 
       1206 
1234 
     | 
    
         
             
                ak = Class.new(ActiveRecord::Base)
         
     | 
| 
       1207 
1235 
     | 
    
         
             
                ak.abstract_class = true
         
     | 
| 
       1208 
1236 
     | 
    
         
             
                k = Class.new(ak)
         
     | 
| 
         @@ -1213,6 +1241,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1213 
1241 
     | 
    
         
             
              end
         
     | 
| 
       1214 
1242 
     | 
    
         | 
| 
       1215 
1243 
     | 
    
         
             
              def test_count_with_join
         
     | 
| 
      
 1244 
     | 
    
         
            +
                puts "In base_test test_count_with_join"
         
     | 
| 
       1216 
1245 
     | 
    
         
             
                res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'"
         
     | 
| 
       1217 
1246 
     | 
    
         | 
| 
       1218 
1247 
     | 
    
         
             
                res2 = Post.where("posts.#{QUOTED_TYPE} = 'Post'").joins("LEFT JOIN comments ON posts.id=comments.post_id").count
         
     | 
| 
         @@ -1241,97 +1270,78 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1241 
1270 
     | 
    
         
             
              end
         
     | 
| 
       1242 
1271 
     | 
    
         | 
| 
       1243 
1272 
     | 
    
         
             
              def test_no_limit_offset
         
     | 
| 
      
 1273 
     | 
    
         
            +
                puts "In base_test test_no_limit_offset"
         
     | 
| 
       1244 
1274 
     | 
    
         
             
                assert_nothing_raised do
         
     | 
| 
       1245 
1275 
     | 
    
         
             
                  Developer.all.merge!(:offset => 2).to_a
         
     | 
| 
       1246 
1276 
     | 
    
         
             
                end
         
     | 
| 
       1247 
1277 
     | 
    
         
             
              end
         
     | 
| 
       1248 
1278 
     | 
    
         | 
| 
       1249 
1279 
     | 
    
         
             
              def test_find_last
         
     | 
| 
      
 1280 
     | 
    
         
            +
                puts "In base_test test_find_last"
         
     | 
| 
       1250 
1281 
     | 
    
         
             
                last  = Developer.last
         
     | 
| 
       1251 
1282 
     | 
    
         
             
                assert_equal last, Developer.all.merge!(:order => 'id desc').first
         
     | 
| 
       1252 
1283 
     | 
    
         
             
              end
         
     | 
| 
       1253 
1284 
     | 
    
         | 
| 
       1254 
1285 
     | 
    
         
             
              def test_last
         
     | 
| 
      
 1286 
     | 
    
         
            +
                puts "In base_test test_last"
         
     | 
| 
       1255 
1287 
     | 
    
         
             
                assert_equal Developer.all.merge!(:order => 'id desc').first, Developer.last
         
     | 
| 
       1256 
1288 
     | 
    
         
             
              end
         
     | 
| 
       1257 
1289 
     | 
    
         | 
| 
       1258 
1290 
     | 
    
         
             
              def test_all
         
     | 
| 
      
 1291 
     | 
    
         
            +
                puts "In base_test test_all"
         
     | 
| 
       1259 
1292 
     | 
    
         
             
                developers = Developer.all
         
     | 
| 
       1260 
1293 
     | 
    
         
             
                assert_kind_of ActiveRecord::Relation, developers
         
     | 
| 
       1261 
1294 
     | 
    
         
             
                assert_equal Developer.all, developers
         
     | 
| 
       1262 
1295 
     | 
    
         
             
              end
         
     | 
| 
       1263 
1296 
     | 
    
         | 
| 
       1264 
1297 
     | 
    
         
             
              def test_all_with_conditions
         
     | 
| 
      
 1298 
     | 
    
         
            +
                puts "In base_test test_all_with_conditions"
         
     | 
| 
       1265 
1299 
     | 
    
         
             
                assert_equal Developer.all.merge!(:order => 'id desc').to_a, Developer.order('id desc').to_a
         
     | 
| 
       1266 
1300 
     | 
    
         
             
              end
         
     | 
| 
       1267 
1301 
     | 
    
         | 
| 
       1268 
1302 
     | 
    
         
             
              def test_find_ordered_last
         
     | 
| 
      
 1303 
     | 
    
         
            +
                puts "In base_test test_find_ordered_last"
         
     | 
| 
       1269 
1304 
     | 
    
         
             
                last  = Developer.all.merge!(:order => 'developers.salary ASC').last
         
     | 
| 
       1270 
1305 
     | 
    
         
             
                assert_equal last, Developer.all.merge!(:order => 'developers.salary ASC').to_a.last
         
     | 
| 
       1271 
1306 
     | 
    
         
             
              end
         
     | 
| 
       1272 
1307 
     | 
    
         | 
| 
       1273 
1308 
     | 
    
         
             
              def test_find_reverse_ordered_last
         
     | 
| 
      
 1309 
     | 
    
         
            +
                puts "In base_test test_find_reverse_ordered_last"
         
     | 
| 
       1274 
1310 
     | 
    
         
             
                last  = Developer.all.merge!(:order => 'developers.salary DESC').last
         
     | 
| 
       1275 
1311 
     | 
    
         
             
                assert_equal last, Developer.all.merge!(:order => 'developers.salary DESC').to_a.last
         
     | 
| 
       1276 
1312 
     | 
    
         
             
              end
         
     | 
| 
       1277 
1313 
     | 
    
         | 
| 
       1278 
1314 
     | 
    
         
             
              def test_find_multiple_ordered_last
         
     | 
| 
      
 1315 
     | 
    
         
            +
                puts "In base_test test_find_multiple_ordered_last"
         
     | 
| 
       1279 
1316 
     | 
    
         
             
                last  = Developer.all.merge!(:order => 'developers.name, developers.salary DESC').last
         
     | 
| 
       1280 
1317 
     | 
    
         
             
                assert_equal last, Developer.all.merge!(:order => 'developers.name, developers.salary DESC').to_a.last
         
     | 
| 
       1281 
1318 
     | 
    
         
             
              end
         
     | 
| 
       1282 
1319 
     | 
    
         | 
| 
       1283 
1320 
     | 
    
         
             
              def test_find_keeps_multiple_order_values
         
     | 
| 
      
 1321 
     | 
    
         
            +
                puts "In base_test test_find_keeps_multiple_order_values"
         
     | 
| 
       1284 
1322 
     | 
    
         
             
                combined = Developer.all.merge!(:order => 'developers.name, developers.salary').to_a
         
     | 
| 
       1285 
1323 
     | 
    
         
             
                assert_equal combined, Developer.all.merge!(:order => ['developers.name', 'developers.salary']).to_a
         
     | 
| 
       1286 
1324 
     | 
    
         
             
              end
         
     | 
| 
       1287 
1325 
     | 
    
         | 
| 
       1288 
1326 
     | 
    
         
             
              def test_find_keeps_multiple_group_values
         
     | 
| 
      
 1327 
     | 
    
         
            +
                puts "In base_test test_find_keeps_multiple_group_values"
         
     | 
| 
       1289 
1328 
     | 
    
         
             
                combined = Developer.all.merge!(:group => 'developers.name, developers.salary, developers.id, developers.created_at, developers.updated_at, developers.created_on, developers.updated_on').to_a
         
     | 
| 
       1290 
1329 
     | 
    
         
             
                assert_equal combined, Developer.all.merge!(:group => ['developers.name', 'developers.salary', 'developers.id', 'developers.created_at', 'developers.updated_at', 'developers.created_on', 'developers.updated_on']).to_a
         
     | 
| 
       1291 
1330 
     | 
    
         
             
              end
         
     | 
| 
       1292 
1331 
     | 
    
         | 
| 
       1293 
1332 
     | 
    
         
             
              def test_find_symbol_ordered_last
         
     | 
| 
      
 1333 
     | 
    
         
            +
                puts "In base_test test_find_symbol_ordered_last"
         
     | 
| 
       1294 
1334 
     | 
    
         
             
                last  = Developer.all.merge!(:order => :salary).last
         
     | 
| 
       1295 
1335 
     | 
    
         
             
                assert_equal last, Developer.all.merge!(:order => :salary).to_a.last
         
     | 
| 
       1296 
1336 
     | 
    
         
             
              end
         
     | 
| 
       1297 
1337 
     | 
    
         | 
| 
       1298 
     | 
    
         
            -
              def test_abstract_class
         
     | 
| 
       1299 
     | 
    
         
            -
                assert !ActiveRecord::Base.abstract_class?
         
     | 
| 
       1300 
     | 
    
         
            -
                assert LoosePerson.abstract_class?
         
     | 
| 
       1301 
     | 
    
         
            -
                assert !LooseDescendant.abstract_class?
         
     | 
| 
       1302 
     | 
    
         
            -
              end
         
     | 
| 
       1303 
     | 
    
         
            -
             
     | 
| 
       1304 
1338 
     | 
    
         
             
              def test_abstract_class_table_name
         
     | 
| 
      
 1339 
     | 
    
         
            +
                puts "In base_test test_abstract_class_table_name"
         
     | 
| 
       1305 
1340 
     | 
    
         
             
                assert_nil AbstractCompany.table_name
         
     | 
| 
       1306 
1341 
     | 
    
         
             
              end
         
     | 
| 
       1307 
1342 
     | 
    
         | 
| 
       1308 
     | 
    
         
            -
              def test_descends_from_active_record
         
     | 
| 
       1309 
     | 
    
         
            -
                assert !ActiveRecord::Base.descends_from_active_record?
         
     | 
| 
       1310 
     | 
    
         
            -
             
     | 
| 
       1311 
     | 
    
         
            -
                # Abstract subclass of AR::Base.
         
     | 
| 
       1312 
     | 
    
         
            -
                assert LoosePerson.descends_from_active_record?
         
     | 
| 
       1313 
     | 
    
         
            -
             
     | 
| 
       1314 
     | 
    
         
            -
                # Concrete subclass of an abstract class.
         
     | 
| 
       1315 
     | 
    
         
            -
                assert LooseDescendant.descends_from_active_record?
         
     | 
| 
       1316 
     | 
    
         
            -
             
     | 
| 
       1317 
     | 
    
         
            -
                # Concrete subclass of AR::Base.
         
     | 
| 
       1318 
     | 
    
         
            -
                assert TightPerson.descends_from_active_record?
         
     | 
| 
       1319 
     | 
    
         
            -
             
     | 
| 
       1320 
     | 
    
         
            -
                # Concrete subclass of a concrete class but has no type column.
         
     | 
| 
       1321 
     | 
    
         
            -
                assert TightDescendant.descends_from_active_record?
         
     | 
| 
       1322 
     | 
    
         
            -
             
     | 
| 
       1323 
     | 
    
         
            -
                # Concrete subclass of AR::Base.
         
     | 
| 
       1324 
     | 
    
         
            -
                assert Post.descends_from_active_record?
         
     | 
| 
       1325 
     | 
    
         
            -
             
     | 
| 
       1326 
     | 
    
         
            -
                # Abstract subclass of a concrete class which has a type column.
         
     | 
| 
       1327 
     | 
    
         
            -
                # This is pathological, as you'll never have Sub < Abstract < Concrete.
         
     | 
| 
       1328 
     | 
    
         
            -
                assert !StiPost.descends_from_active_record?
         
     | 
| 
       1329 
     | 
    
         
            -
             
     | 
| 
       1330 
     | 
    
         
            -
                # Concrete subclasses an abstract class which has a type column.
         
     | 
| 
       1331 
     | 
    
         
            -
                assert !SubStiPost.descends_from_active_record?
         
     | 
| 
       1332 
     | 
    
         
            -
              end
         
     | 
| 
       1333 
     | 
    
         
            -
             
     | 
| 
       1334 
1343 
     | 
    
         
             
              def test_find_on_abstract_base_class_doesnt_use_type_condition
         
     | 
| 
      
 1344 
     | 
    
         
            +
                puts "In base_test test_find_on_abstract_base_class_doesnt_use_type_condition"
         
     | 
| 
       1335 
1345 
     | 
    
         
             
                old_class = LooseDescendant
         
     | 
| 
       1336 
1346 
     | 
    
         
             
                Object.send :remove_const, :LooseDescendant
         
     | 
| 
       1337 
1347 
     | 
    
         | 
| 
         @@ -1344,6 +1354,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1344 
1354 
     | 
    
         
             
              end
         
     | 
| 
       1345 
1355 
     | 
    
         | 
| 
       1346 
1356 
     | 
    
         
             
              def test_assert_queries
         
     | 
| 
      
 1357 
     | 
    
         
            +
                puts "In base_test test_assert_queries"
         
     | 
| 
       1347 
1358 
     | 
    
         
             
                query = lambda { ActiveRecord::Base.connection.execute 'select count(*) from developers' }
         
     | 
| 
       1348 
1359 
     | 
    
         
             
                assert_queries(2) { 2.times { query.call } }
         
     | 
| 
       1349 
1360 
     | 
    
         
             
                assert_queries 1, &query
         
     | 
| 
         @@ -1351,6 +1362,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1351 
1362 
     | 
    
         
             
              end
         
     | 
| 
       1352 
1363 
     | 
    
         | 
| 
       1353 
1364 
     | 
    
         
             
              def test_benchmark_with_log_level
         
     | 
| 
      
 1365 
     | 
    
         
            +
                puts "In base_test test_benchmark_with_log_level"
         
     | 
| 
       1354 
1366 
     | 
    
         
             
                original_logger = ActiveRecord::Base.logger
         
     | 
| 
       1355 
1367 
     | 
    
         
             
                log = StringIO.new
         
     | 
| 
       1356 
1368 
     | 
    
         
             
                ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
         
     | 
| 
         @@ -1366,60 +1378,19 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1366 
1378 
     | 
    
         
             
              end
         
     | 
| 
       1367 
1379 
     | 
    
         | 
| 
       1368 
1380 
     | 
    
         
             
              def test_benchmark_with_use_silence
         
     | 
| 
      
 1381 
     | 
    
         
            +
                puts "In base_test test_benchmark_with_use_silence"
         
     | 
| 
       1369 
1382 
     | 
    
         
             
                original_logger = ActiveRecord::Base.logger
         
     | 
| 
       1370 
1383 
     | 
    
         
             
                log = StringIO.new
         
     | 
| 
       1371 
1384 
     | 
    
         
             
                ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
         
     | 
| 
      
 1385 
     | 
    
         
            +
                ActiveRecord::Base.logger.level = Logger::DEBUG
         
     | 
| 
       1372 
1386 
     | 
    
         
             
                ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => false)  { ActiveRecord::Base.logger.debug "Quiet" }
         
     | 
| 
       1373 
1387 
     | 
    
         
             
                assert_match(/Quiet/, log.string)
         
     | 
| 
       1374 
1388 
     | 
    
         
             
              ensure
         
     | 
| 
       1375 
1389 
     | 
    
         
             
                ActiveRecord::Base.logger = original_logger
         
     | 
| 
       1376 
1390 
     | 
    
         
             
              end
         
     | 
| 
       1377 
1391 
     | 
    
         | 
| 
       1378 
     | 
    
         
            -
              def test_compute_type_success
         
     | 
| 
       1379 
     | 
    
         
            -
                assert_equal Author, ActiveRecord::Base.send(:compute_type, 'Author')
         
     | 
| 
       1380 
     | 
    
         
            -
              end
         
     | 
| 
       1381 
     | 
    
         
            -
             
     | 
| 
       1382 
     | 
    
         
            -
              def test_compute_type_nonexistent_constant
         
     | 
| 
       1383 
     | 
    
         
            -
                e = assert_raises NameError do
         
     | 
| 
       1384 
     | 
    
         
            -
                  ActiveRecord::Base.send :compute_type, 'NonexistentModel'
         
     | 
| 
       1385 
     | 
    
         
            -
                end
         
     | 
| 
       1386 
     | 
    
         
            -
                assert_equal 'uninitialized constant ActiveRecord::Base::NonexistentModel', e.message
         
     | 
| 
       1387 
     | 
    
         
            -
                assert_equal 'ActiveRecord::Base::NonexistentModel', e.name
         
     | 
| 
       1388 
     | 
    
         
            -
              end
         
     | 
| 
       1389 
     | 
    
         
            -
             
     | 
| 
       1390 
     | 
    
         
            -
              def test_compute_type_no_method_error
         
     | 
| 
       1391 
     | 
    
         
            -
                ActiveSupport::Dependencies.stubs(:safe_constantize).raises(NoMethodError)
         
     | 
| 
       1392 
     | 
    
         
            -
                assert_raises NoMethodError do
         
     | 
| 
       1393 
     | 
    
         
            -
                  ActiveRecord::Base.send :compute_type, 'InvalidModel'
         
     | 
| 
       1394 
     | 
    
         
            -
                end
         
     | 
| 
       1395 
     | 
    
         
            -
              end
         
     | 
| 
       1396 
     | 
    
         
            -
             
     | 
| 
       1397 
     | 
    
         
            -
              def test_compute_type_on_undefined_method
         
     | 
| 
       1398 
     | 
    
         
            -
                error = nil
         
     | 
| 
       1399 
     | 
    
         
            -
                begin
         
     | 
| 
       1400 
     | 
    
         
            -
                  Class.new(Author) do
         
     | 
| 
       1401 
     | 
    
         
            -
                    alias_method :foo, :bar
         
     | 
| 
       1402 
     | 
    
         
            -
                  end
         
     | 
| 
       1403 
     | 
    
         
            -
                rescue => e
         
     | 
| 
       1404 
     | 
    
         
            -
                  error = e
         
     | 
| 
       1405 
     | 
    
         
            -
                end
         
     | 
| 
       1406 
     | 
    
         
            -
             
     | 
| 
       1407 
     | 
    
         
            -
                ActiveSupport::Dependencies.stubs(:safe_constantize).raises(e)
         
     | 
| 
       1408 
     | 
    
         
            -
             
     | 
| 
       1409 
     | 
    
         
            -
                exception = assert_raises NameError do
         
     | 
| 
       1410 
     | 
    
         
            -
                  ActiveRecord::Base.send :compute_type, 'InvalidModel'
         
     | 
| 
       1411 
     | 
    
         
            -
                end
         
     | 
| 
       1412 
     | 
    
         
            -
                assert_equal error.message, exception.message
         
     | 
| 
       1413 
     | 
    
         
            -
              end
         
     | 
| 
       1414 
     | 
    
         
            -
             
     | 
| 
       1415 
     | 
    
         
            -
              def test_compute_type_argument_error
         
     | 
| 
       1416 
     | 
    
         
            -
                ActiveSupport::Dependencies.stubs(:safe_constantize).raises(ArgumentError)
         
     | 
| 
       1417 
     | 
    
         
            -
                assert_raises ArgumentError do
         
     | 
| 
       1418 
     | 
    
         
            -
                  ActiveRecord::Base.send :compute_type, 'InvalidModel'
         
     | 
| 
       1419 
     | 
    
         
            -
                end
         
     | 
| 
       1420 
     | 
    
         
            -
              end
         
     | 
| 
       1421 
     | 
    
         
            -
             
     | 
| 
       1422 
1392 
     | 
    
         
             
              def test_clear_cache!
         
     | 
| 
      
 1393 
     | 
    
         
            +
                puts "In base_test test_clear_cache"
         
     | 
| 
       1423 
1394 
     | 
    
         
             
                # preheat cache
         
     | 
| 
       1424 
1395 
     | 
    
         
             
                c1 = Post.connection.schema_cache.columns('posts')
         
     | 
| 
       1425 
1396 
     | 
    
         
             
                ActiveRecord::Base.clear_cache!
         
     | 
| 
         @@ -1431,18 +1402,21 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1431 
1402 
     | 
    
         
             
              end
         
     | 
| 
       1432 
1403 
     | 
    
         | 
| 
       1433 
1404 
     | 
    
         
             
              def test_current_scope_is_reset
         
     | 
| 
      
 1405 
     | 
    
         
            +
                puts "In base_test test_current_scope_is_reset"
         
     | 
| 
       1434 
1406 
     | 
    
         
             
                Object.const_set :UnloadablePost, Class.new(ActiveRecord::Base)
         
     | 
| 
       1435 
1407 
     | 
    
         
             
                UnloadablePost.send(:current_scope=, UnloadablePost.all)
         
     | 
| 
       1436 
1408 
     | 
    
         | 
| 
       1437 
1409 
     | 
    
         
             
                UnloadablePost.unloadable
         
     | 
| 
       1438 
     | 
    
         
            -
                 
     | 
| 
      
 1410 
     | 
    
         
            +
                klass = UnloadablePost
         
     | 
| 
      
 1411 
     | 
    
         
            +
                assert_not_nil ActiveRecord::Scoping::ScopeRegistry.value_for(:current_scope, klass)
         
     | 
| 
       1439 
1412 
     | 
    
         
             
                ActiveSupport::Dependencies.remove_unloadable_constants!
         
     | 
| 
       1440 
     | 
    
         
            -
                assert_nil ActiveRecord::Scoping::ScopeRegistry.value_for(:current_scope,  
     | 
| 
      
 1413 
     | 
    
         
            +
                assert_nil ActiveRecord::Scoping::ScopeRegistry.value_for(:current_scope, klass)
         
     | 
| 
       1441 
1414 
     | 
    
         
             
              ensure
         
     | 
| 
       1442 
1415 
     | 
    
         
             
                Object.class_eval{ remove_const :UnloadablePost } if defined?(UnloadablePost)
         
     | 
| 
       1443 
1416 
     | 
    
         
             
              end
         
     | 
| 
       1444 
1417 
     | 
    
         | 
| 
       1445 
1418 
     | 
    
         
             
              def test_marshal_round_trip
         
     | 
| 
      
 1419 
     | 
    
         
            +
                puts "In base_test test_marshal_round_trip"
         
     | 
| 
       1446 
1420 
     | 
    
         
             
                expected = posts(:welcome)
         
     | 
| 
       1447 
1421 
     | 
    
         
             
                marshalled = Marshal.dump(expected)
         
     | 
| 
       1448 
1422 
     | 
    
         
             
                actual   = Marshal.load(marshalled)
         
     | 
| 
         @@ -1451,6 +1425,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1451 
1425 
     | 
    
         
             
              end
         
     | 
| 
       1452 
1426 
     | 
    
         | 
| 
       1453 
1427 
     | 
    
         
             
              def test_marshal_new_record_round_trip
         
     | 
| 
      
 1428 
     | 
    
         
            +
                puts "In base_test test_marshal_new_record_round_trip"
         
     | 
| 
       1454 
1429 
     | 
    
         
             
                marshalled = Marshal.dump(Post.new)
         
     | 
| 
       1455 
1430 
     | 
    
         
             
                post       = Marshal.load(marshalled)
         
     | 
| 
       1456 
1431 
     | 
    
         | 
| 
         @@ -1458,6 +1433,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1458 
1433 
     | 
    
         
             
              end
         
     | 
| 
       1459 
1434 
     | 
    
         | 
| 
       1460 
1435 
     | 
    
         
             
              def test_marshalling_with_associations
         
     | 
| 
      
 1436 
     | 
    
         
            +
                puts "In base_test test_marshalling_with_associations"
         
     | 
| 
       1461 
1437 
     | 
    
         
             
                post = Post.new
         
     | 
| 
       1462 
1438 
     | 
    
         
             
                post.comments.build
         
     | 
| 
       1463 
1439 
     | 
    
         | 
| 
         @@ -1469,6 +1445,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1469 
1445 
     | 
    
         | 
| 
       1470 
1446 
     | 
    
         
             
              if Process.respond_to?(:fork) && !in_memory_db?
         
     | 
| 
       1471 
1447 
     | 
    
         
             
                def test_marshal_between_processes
         
     | 
| 
      
 1448 
     | 
    
         
            +
            	  puts "In base_test test_marshal_between_processes"
         
     | 
| 
       1472 
1449 
     | 
    
         
             
                  # Define a new model to ensure there are no caches
         
     | 
| 
       1473 
1450 
     | 
    
         
             
                  if self.class.const_defined?("Post", false)
         
     | 
| 
       1474 
1451 
     | 
    
         
             
                    flunk "there should be no post constant"
         
     | 
| 
         @@ -1499,6 +1476,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1499 
1476 
     | 
    
         
             
              end
         
     | 
| 
       1500 
1477 
     | 
    
         | 
| 
       1501 
1478 
     | 
    
         
             
              def test_marshalling_new_record_round_trip_with_associations
         
     | 
| 
      
 1479 
     | 
    
         
            +
                puts "In base_test test_marshalling_new_record_round_trip_with_associations"
         
     | 
| 
       1502 
1480 
     | 
    
         
             
                post = Post.new
         
     | 
| 
       1503 
1481 
     | 
    
         
             
                post.comments.build
         
     | 
| 
       1504 
1482 
     | 
    
         | 
| 
         @@ -1508,19 +1486,38 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1508 
1486 
     | 
    
         
             
              end
         
     | 
| 
       1509 
1487 
     | 
    
         | 
| 
       1510 
1488 
     | 
    
         
             
              def test_attribute_names
         
     | 
| 
      
 1489 
     | 
    
         
            +
                puts "In base_test test_attribute_names"
         
     | 
| 
       1511 
1490 
     | 
    
         
             
                assert_equal ["id", "type", "firm_id", "firm_name", "name", "client_of", "rating", "account_id", "description"],
         
     | 
| 
       1512 
1491 
     | 
    
         
             
                             Company.attribute_names
         
     | 
| 
       1513 
1492 
     | 
    
         
             
              end
         
     | 
| 
       1514 
1493 
     | 
    
         | 
| 
      
 1494 
     | 
    
         
            +
              def test_has_attribute
         
     | 
| 
      
 1495 
     | 
    
         
            +
                puts "In base_test test_has_attribute"
         
     | 
| 
      
 1496 
     | 
    
         
            +
                assert Company.has_attribute?('id')
         
     | 
| 
      
 1497 
     | 
    
         
            +
                assert Company.has_attribute?('type')
         
     | 
| 
      
 1498 
     | 
    
         
            +
                assert Company.has_attribute?('name')
         
     | 
| 
      
 1499 
     | 
    
         
            +
                assert_not Company.has_attribute?('lastname')
         
     | 
| 
      
 1500 
     | 
    
         
            +
                assert_not Company.has_attribute?('age')
         
     | 
| 
      
 1501 
     | 
    
         
            +
              end
         
     | 
| 
      
 1502 
     | 
    
         
            +
             
     | 
| 
      
 1503 
     | 
    
         
            +
              def test_has_attribute_with_symbol
         
     | 
| 
      
 1504 
     | 
    
         
            +
                puts "In base_test test_has_attribute_with_symbol"
         
     | 
| 
      
 1505 
     | 
    
         
            +
                assert Company.has_attribute?(:id)
         
     | 
| 
      
 1506 
     | 
    
         
            +
                assert_not Company.has_attribute?(:age)
         
     | 
| 
      
 1507 
     | 
    
         
            +
              end
         
     | 
| 
      
 1508 
     | 
    
         
            +
             
     | 
| 
       1515 
1509 
     | 
    
         
             
              def test_attribute_names_on_table_not_exists
         
     | 
| 
      
 1510 
     | 
    
         
            +
                puts "In base_test test_attribute_names_on_table_not_exists"
         
     | 
| 
       1516 
1511 
     | 
    
         
             
                assert_equal [], NonExistentTable.attribute_names
         
     | 
| 
       1517 
1512 
     | 
    
         
             
              end
         
     | 
| 
       1518 
1513 
     | 
    
         | 
| 
       1519 
1514 
     | 
    
         
             
              def test_attribute_names_on_abstract_class
         
     | 
| 
      
 1515 
     | 
    
         
            +
                puts "In base_test test_attribute_names_on_abstract_class"
         
     | 
| 
       1520 
1516 
     | 
    
         
             
                assert_equal [], AbstractCompany.attribute_names
         
     | 
| 
       1521 
1517 
     | 
    
         
             
              end
         
     | 
| 
       1522 
1518 
     | 
    
         | 
| 
       1523 
1519 
     | 
    
         
             
              def test_touch_should_raise_error_on_a_new_object
         
     | 
| 
      
 1520 
     | 
    
         
            +
                puts "In base_test test_touch_should_raise_error_on_a_new_object"
         
     | 
| 
       1524 
1521 
     | 
    
         
             
                company = Company.new(:rating => 1, :name => "37signals", :firm_name => "37signals")
         
     | 
| 
       1525 
1522 
     | 
    
         
             
                assert_raises(ActiveRecord::ActiveRecordError) do
         
     | 
| 
       1526 
1523 
     | 
    
         
             
                  company.touch :updated_at
         
     | 
| 
         @@ -1528,22 +1525,24 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1528 
1525 
     | 
    
         
             
              end
         
     | 
| 
       1529 
1526 
     | 
    
         | 
| 
       1530 
1527 
     | 
    
         
             
              def test_uniq_delegates_to_scoped
         
     | 
| 
       1531 
     | 
    
         
            -
                 
     | 
| 
       1532 
     | 
    
         
            -
                 
     | 
| 
       1533 
     | 
    
         
            -
             
     | 
| 
      
 1528 
     | 
    
         
            +
                puts "In base_test test_uniq_delegates_to_scoped"
         
     | 
| 
      
 1529 
     | 
    
         
            +
                assert_deprecated do
         
     | 
| 
      
 1530 
     | 
    
         
            +
                  assert_equal Bird.all.distinct, Bird.uniq
         
     | 
| 
      
 1531 
     | 
    
         
            +
                end
         
     | 
| 
       1534 
1532 
     | 
    
         
             
              end
         
     | 
| 
       1535 
1533 
     | 
    
         | 
| 
       1536 
1534 
     | 
    
         
             
              def test_distinct_delegates_to_scoped
         
     | 
| 
       1537 
     | 
    
         
            -
                 
     | 
| 
       1538 
     | 
    
         
            -
                Bird. 
     | 
| 
       1539 
     | 
    
         
            -
                assert_equal scope, Bird.distinct
         
     | 
| 
      
 1535 
     | 
    
         
            +
                puts "In base_test test_distinct_delegates_to_scoped"
         
     | 
| 
      
 1536 
     | 
    
         
            +
                assert_equal Bird.all.distinct, Bird.distinct
         
     | 
| 
       1540 
1537 
     | 
    
         
             
              end
         
     | 
| 
       1541 
1538 
     | 
    
         | 
| 
       1542 
1539 
     | 
    
         
             
              def test_table_name_with_2_abstract_subclasses
         
     | 
| 
      
 1540 
     | 
    
         
            +
                puts "In base_test test_table_name_with_2_abstract_subclasses"
         
     | 
| 
       1543 
1541 
     | 
    
         
             
                assert_equal "photos", Photo.table_name
         
     | 
| 
       1544 
1542 
     | 
    
         
             
              end
         
     | 
| 
       1545 
1543 
     | 
    
         | 
| 
       1546 
1544 
     | 
    
         
             
              def test_column_types_typecast
         
     | 
| 
      
 1545 
     | 
    
         
            +
                puts "In base_test test_column_types_typecast"
         
     | 
| 
       1547 
1546 
     | 
    
         
             
                topic = Topic.first
         
     | 
| 
       1548 
1547 
     | 
    
         
             
                assert_not_equal 't.lo', topic.author_name
         
     | 
| 
       1549 
1548 
     | 
    
         | 
| 
         @@ -1551,7 +1550,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1551 
1550 
     | 
    
         
             
                attrs.delete 'id'
         
     | 
| 
       1552 
1551 
     | 
    
         | 
| 
       1553 
1552 
     | 
    
         
             
                typecast = Class.new(ActiveRecord::Type::Value) {
         
     | 
| 
       1554 
     | 
    
         
            -
                  def  
     | 
| 
      
 1553 
     | 
    
         
            +
                  def cast value
         
     | 
| 
       1555 
1554 
     | 
    
         
             
                    "t.lo"
         
     | 
| 
       1556 
1555 
     | 
    
         
             
                  end
         
     | 
| 
       1557 
1556 
     | 
    
         
             
                }
         
     | 
| 
         @@ -1563,10 +1562,12 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1563 
1562 
     | 
    
         
             
              end
         
     | 
| 
       1564 
1563 
     | 
    
         | 
| 
       1565 
1564 
     | 
    
         
             
              def test_typecasting_aliases
         
     | 
| 
      
 1565 
     | 
    
         
            +
                puts "In base_test test_typecasting_aliases"
         
     | 
| 
       1566 
1566 
     | 
    
         
             
                assert_equal 10, Topic.select('10 as tenderlove').first.tenderlove
         
     | 
| 
       1567 
1567 
     | 
    
         
             
              end
         
     | 
| 
       1568 
1568 
     | 
    
         | 
| 
       1569 
1569 
     | 
    
         
             
              def test_slice
         
     | 
| 
      
 1570 
     | 
    
         
            +
                puts "In base_test test_slice"
         
     | 
| 
       1570 
1571 
     | 
    
         
             
                company = Company.new(:rating => 1, :name => "37signals", :firm_name => "37signals")
         
     | 
| 
       1571 
1572 
     | 
    
         
             
                hash = company.slice(:name, :rating, "arbitrary_method")
         
     | 
| 
       1572 
1573 
     | 
    
         
             
                assert_equal hash[:name], company.name
         
     | 
| 
         @@ -1579,17 +1580,20 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1579 
1580 
     | 
    
         
             
              end
         
     | 
| 
       1580 
1581 
     | 
    
         | 
| 
       1581 
1582 
     | 
    
         
             
              def test_default_values_are_deeply_dupped
         
     | 
| 
      
 1583 
     | 
    
         
            +
                puts "In base_test test_default_values_are_deeply_dupped"
         
     | 
| 
       1582 
1584 
     | 
    
         
             
                company = Company.new
         
     | 
| 
       1583 
1585 
     | 
    
         
             
                company.description << "foo"
         
     | 
| 
       1584 
1586 
     | 
    
         
             
                assert_equal "", Company.new.description
         
     | 
| 
       1585 
1587 
     | 
    
         
             
              end
         
     | 
| 
       1586 
1588 
     | 
    
         | 
| 
       1587 
1589 
     | 
    
         
             
              test "scoped can take a values hash" do
         
     | 
| 
      
 1590 
     | 
    
         
            +
                puts "In base_test scoped can take a values hash"
         
     | 
| 
       1588 
1591 
     | 
    
         
             
                klass = Class.new(ActiveRecord::Base)
         
     | 
| 
       1589 
1592 
     | 
    
         
             
                assert_equal ['foo'], klass.all.merge!(select: 'foo').select_values
         
     | 
| 
       1590 
1593 
     | 
    
         
             
              end
         
     | 
| 
       1591 
1594 
     | 
    
         | 
| 
       1592 
1595 
     | 
    
         
             
              test "connection_handler can be overridden" do
         
     | 
| 
      
 1596 
     | 
    
         
            +
                puts "In base_test connection_handler can be overridden"
         
     | 
| 
       1593 
1597 
     | 
    
         
             
                klass = Class.new(ActiveRecord::Base)
         
     | 
| 
       1594 
1598 
     | 
    
         
             
                orig_handler = klass.connection_handler
         
     | 
| 
       1595 
1599 
     | 
    
         
             
                new_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
         
     | 
| 
         @@ -1606,6 +1610,7 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1606 
1610 
     | 
    
         
             
              end
         
     | 
| 
       1607 
1611 
     | 
    
         | 
| 
       1608 
1612 
     | 
    
         
             
              test "new threads get default the default connection handler" do
         
     | 
| 
      
 1613 
     | 
    
         
            +
                puts "In base_test new threads get default the default connection handler"
         
     | 
| 
       1609 
1614 
     | 
    
         
             
                klass = Class.new(ActiveRecord::Base)
         
     | 
| 
       1610 
1615 
     | 
    
         
             
                orig_handler = klass.connection_handler
         
     | 
| 
       1611 
1616 
     | 
    
         
             
                handler = nil
         
     | 
| 
         @@ -1621,24 +1626,25 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1621 
1626 
     | 
    
         
             
              end
         
     | 
| 
       1622 
1627 
     | 
    
         | 
| 
       1623 
1628 
     | 
    
         
             
              test "changing a connection handler in a main thread does not poison the other threads" do
         
     | 
| 
      
 1629 
     | 
    
         
            +
                puts "In base_test changing a connection handler in a main thread does not poison the other threads"
         
     | 
| 
       1624 
1630 
     | 
    
         
             
                klass = Class.new(ActiveRecord::Base)
         
     | 
| 
       1625 
1631 
     | 
    
         
             
                orig_handler = klass.connection_handler
         
     | 
| 
       1626 
1632 
     | 
    
         
             
                new_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
         
     | 
| 
       1627 
1633 
     | 
    
         
             
                after_handler = nil
         
     | 
| 
       1628 
     | 
    
         
            -
                latch1 =  
     | 
| 
       1629 
     | 
    
         
            -
                latch2 =  
     | 
| 
      
 1634 
     | 
    
         
            +
                latch1 = Concurrent::CountDownLatch.new
         
     | 
| 
      
 1635 
     | 
    
         
            +
                latch2 = Concurrent::CountDownLatch.new
         
     | 
| 
       1630 
1636 
     | 
    
         | 
| 
       1631 
1637 
     | 
    
         
             
                t = Thread.new do
         
     | 
| 
       1632 
1638 
     | 
    
         
             
                  klass.connection_handler = new_handler
         
     | 
| 
       1633 
     | 
    
         
            -
                  latch1. 
     | 
| 
       1634 
     | 
    
         
            -
                  latch2. 
     | 
| 
      
 1639 
     | 
    
         
            +
                  latch1.count_down
         
     | 
| 
      
 1640 
     | 
    
         
            +
                  latch2.wait
         
     | 
| 
       1635 
1641 
     | 
    
         
             
                  after_handler = klass.connection_handler
         
     | 
| 
       1636 
1642 
     | 
    
         
             
                end
         
     | 
| 
       1637 
1643 
     | 
    
         | 
| 
       1638 
     | 
    
         
            -
                latch1. 
     | 
| 
      
 1644 
     | 
    
         
            +
                latch1.wait
         
     | 
| 
       1639 
1645 
     | 
    
         | 
| 
       1640 
1646 
     | 
    
         
             
                klass.connection_handler = orig_handler
         
     | 
| 
       1641 
     | 
    
         
            -
                latch2. 
     | 
| 
      
 1647 
     | 
    
         
            +
                latch2.count_down
         
     | 
| 
       1642 
1648 
     | 
    
         
             
                t.join
         
     | 
| 
       1643 
1649 
     | 
    
         | 
| 
       1644 
1650 
     | 
    
         
             
                assert_equal after_handler, new_handler
         
     | 
| 
         @@ -1649,10 +1655,12 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1649 
1655 
     | 
    
         
             
              # AR::Base objects. If the future has made this irrelevant, feel free to
         
     | 
| 
       1650 
1656 
     | 
    
         
             
              # delete this.
         
     | 
| 
       1651 
1657 
     | 
    
         
             
              test "records without an id have unique hashes" do
         
     | 
| 
      
 1658 
     | 
    
         
            +
                puts "In base_test records without an id have unique hashes"
         
     | 
| 
       1652 
1659 
     | 
    
         
             
                assert_not_equal Post.new.hash, Post.new.hash
         
     | 
| 
       1653 
1660 
     | 
    
         
             
              end
         
     | 
| 
       1654 
1661 
     | 
    
         | 
| 
       1655 
1662 
     | 
    
         
             
              test "resetting column information doesn't remove attribute methods" do
         
     | 
| 
      
 1663 
     | 
    
         
            +
                puts "In base_test changing a connection handler in a main thread does not poison the other threads"
         
     | 
| 
       1656 
1664 
     | 
    
         
             
                topic = topics(:first)
         
     | 
| 
       1657 
1665 
     | 
    
         | 
| 
       1658 
1666 
     | 
    
         
             
                assert_not topic.id_changed?
         
     | 
| 
         @@ -1661,4 +1669,45 @@ class BasicsTest < ActiveRecord::TestCase 
     | 
|
| 
       1661 
1669 
     | 
    
         | 
| 
       1662 
1670 
     | 
    
         
             
                assert_not topic.id_changed?
         
     | 
| 
       1663 
1671 
     | 
    
         
             
              end
         
     | 
| 
      
 1672 
     | 
    
         
            +
             
     | 
| 
      
 1673 
     | 
    
         
            +
              test "ignored columns are not present in columns_hash" do
         
     | 
| 
      
 1674 
     | 
    
         
            +
                puts "In base_test ignored columns are not present in columns_hash"
         
     | 
| 
      
 1675 
     | 
    
         
            +
                cache_columns = Developer.connection.schema_cache.columns_hash(Developer.table_name)
         
     | 
| 
      
 1676 
     | 
    
         
            +
                assert_includes cache_columns.keys, "first_name"
         
     | 
| 
      
 1677 
     | 
    
         
            +
                assert_not_includes Developer.columns_hash.keys, "first_name"
         
     | 
| 
      
 1678 
     | 
    
         
            +
                assert_not_includes SubDeveloper.columns_hash.keys, "first_name"
         
     | 
| 
      
 1679 
     | 
    
         
            +
                assert_not_includes SymbolIgnoredDeveloper.columns_hash.keys, "first_name"
         
     | 
| 
      
 1680 
     | 
    
         
            +
              end
         
     | 
| 
      
 1681 
     | 
    
         
            +
             
     | 
| 
      
 1682 
     | 
    
         
            +
              test "ignored columns have no attribute methods" do
         
     | 
| 
      
 1683 
     | 
    
         
            +
                puts "In base_test ignored columns have no attribute methods"
         
     | 
| 
      
 1684 
     | 
    
         
            +
                refute Developer.new.respond_to?(:first_name)
         
     | 
| 
      
 1685 
     | 
    
         
            +
                refute Developer.new.respond_to?(:first_name=)
         
     | 
| 
      
 1686 
     | 
    
         
            +
                refute Developer.new.respond_to?(:first_name?)
         
     | 
| 
      
 1687 
     | 
    
         
            +
                refute SubDeveloper.new.respond_to?(:first_name)
         
     | 
| 
      
 1688 
     | 
    
         
            +
                refute SubDeveloper.new.respond_to?(:first_name=)
         
     | 
| 
      
 1689 
     | 
    
         
            +
                refute SubDeveloper.new.respond_to?(:first_name?)
         
     | 
| 
      
 1690 
     | 
    
         
            +
                refute SymbolIgnoredDeveloper.new.respond_to?(:first_name)
         
     | 
| 
      
 1691 
     | 
    
         
            +
                refute SymbolIgnoredDeveloper.new.respond_to?(:first_name=)
         
     | 
| 
      
 1692 
     | 
    
         
            +
                refute SymbolIgnoredDeveloper.new.respond_to?(:first_name?)
         
     | 
| 
      
 1693 
     | 
    
         
            +
              end
         
     | 
| 
      
 1694 
     | 
    
         
            +
             
     | 
| 
      
 1695 
     | 
    
         
            +
              test "ignored columns don't prevent explicit declaration of attribute methods" do
         
     | 
| 
      
 1696 
     | 
    
         
            +
                puts "In base_test ignored columns don't prevent explicit declaration of attribute methods"
         
     | 
| 
      
 1697 
     | 
    
         
            +
                assert Developer.new.respond_to?(:last_name)
         
     | 
| 
      
 1698 
     | 
    
         
            +
                assert Developer.new.respond_to?(:last_name=)
         
     | 
| 
      
 1699 
     | 
    
         
            +
                assert Developer.new.respond_to?(:last_name?)
         
     | 
| 
      
 1700 
     | 
    
         
            +
                assert SubDeveloper.new.respond_to?(:last_name)
         
     | 
| 
      
 1701 
     | 
    
         
            +
                assert SubDeveloper.new.respond_to?(:last_name=)
         
     | 
| 
      
 1702 
     | 
    
         
            +
                assert SubDeveloper.new.respond_to?(:last_name?)
         
     | 
| 
      
 1703 
     | 
    
         
            +
                assert SymbolIgnoredDeveloper.new.respond_to?(:last_name)
         
     | 
| 
      
 1704 
     | 
    
         
            +
                assert SymbolIgnoredDeveloper.new.respond_to?(:last_name=)
         
     | 
| 
      
 1705 
     | 
    
         
            +
                assert SymbolIgnoredDeveloper.new.respond_to?(:last_name?)
         
     | 
| 
      
 1706 
     | 
    
         
            +
              end
         
     | 
| 
      
 1707 
     | 
    
         
            +
             
     | 
| 
      
 1708 
     | 
    
         
            +
              test "ignored columns are stored as an array of string" do
         
     | 
| 
      
 1709 
     | 
    
         
            +
                puts "In base_test ignored columns are stored as an array of string"
         
     | 
| 
      
 1710 
     | 
    
         
            +
                assert_equal(%w(first_name last_name), Developer.ignored_columns)
         
     | 
| 
      
 1711 
     | 
    
         
            +
                assert_equal(%w(first_name last_name), SymbolIgnoredDeveloper.ignored_columns)
         
     | 
| 
      
 1712 
     | 
    
         
            +
              end
         
     | 
| 
       1664 
1713 
     | 
    
         
             
            end
         
     |