aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Merge pull request #30337 from kamipo/refactor_schema_dumperRyuta Kamizono2017-08-241-4/+0
|\ \ \ | | | | | | | | Refactor `SchemaDumper` to make it possible to adapter specific customization
| * | | Remove deprecated `#migration_keys`Ryuta Kamizono2017-08-221-4/+0
| | | |
* | | | Remove unnecessary fixture loadingRyuta Kamizono2017-08-241-5/+1
| |/ / |/| |
* | | Merge pull request #30365 from yahonda/require_post_before_commentRyuta Kamizono2017-08-231-0/+3
|\ \ \ | | | | | | | | `counter_cache` requires association class before `attr_readonly`
| * | | `counter_cache` requires association class before `attr_readonly`Yasuo Honda2017-08-231-0/+3
| |/ / | | | | | | | | | | | | There were similar pull requests #26370 #27575 fixed by different way by moving `require "models/post"` before `require "models/comment"`
* | | Merge pull request #28991 from yahonda/load_authors_and_author_addressesRyuta Kamizono2017-08-234-4/+4
|\ \ \ | | | | | | | | Load :author_addresses fixture to keep data integrity with :authors
| * | | Load both `:authors` and `:author_addresses` to keep data integrityYasuo Honda2017-08-224-4/+4
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `:authors` has a foreign key to `:author_addresses`. If only `:authors` fixture loaded into the database which supports foreign key and checks the existing data when enabling foreien keys like Oracle, it raises the following error `ORA-02298: cannot validate (ARUNIT.FK_RAILS_94423A17A3) - parent keys not found` It is because there is no parent data exists in `author_addresses` table. Here are how other database with foreign key support works: - MySQL does not check the existing data when enabling foreign key by `foreign_key_checks=1` https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_foreign_key_checks > Setting foreign_key_checks to 1 does not trigger a scan of the existing table data. Therefore, rows added to the table while foreign_key_checks=0 will not be verified for consistency. - PostgreSQL database itself has a feature to check existing data when enabling foreign key and discussed at #27636, which is reverted.
* | | Merge pull request #30360 from gcourtemanche/transaction_timedoutRafael França2017-08-221-0/+6
|\ \ \ | |/ / |/| | Add TransactionTimeout for MySQL error code 1205
| * | Add TransactionTimeout for MySQL error code 1205Gabriel Courtemanche2017-08-221-0/+6
| | |
* | | Automatically guess the inverse associations for STIyui-knk2017-08-221-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord associations automatically guess the inverse associations. But this feature does not work correctly on assoctions for STI. For example, before this commit ``` class Post < ActiveRecord::Base belongs_to :author end class SpecialPost < Post; end class Author < ActiveRecord::Base has_many :posts has_many :special_posts end ``` `author.posts.first.author` works correctly, but `author.special_posts.first.author` does not work correctly.
* | | Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-221-1/+1
|/ /
* | Prevent extra `SET time zone` in `configure_connection` (#28413)Ryuta Kamizono2017-08-211-0/+7
| | | | | | | | | | | | | | | | `SET time zone 'value'` is an alias for `SET timezone TO 'value'`. https://www.postgresql.org/docs/current/static/sql-set.html So if `variables["timezone"]` is specified, it is enough to `SET timezone` once.
* | Fix `can't modify frozen String` error in an AR testKoichi ITO2017-08-191-2/+2
| |
* | Improve `migration/column_attributes_test.rb` (#25286)Ryuta Kamizono2017-08-181-3/+17
| | | | | | | | | | * Test `test_unabstracted_database_dependent_types` for `PostgreSQLAdapter` * Add `test_change_column_with_new_precision_and_scale` for `SQLite3Adapter` * This test case and comment was lost at 28bb02a78fd47527bb7a208d01a4594bb212812c
* | Add deterministic sorting order for `test_taking_with_a_number`Ryuta Kamizono2017-08-181-1/+9
| | | | | | | | | | | | Otherwise random CI failure will be caused. https://travis-ci.org/rails/rails/jobs/265848046#L777
* | Restore the ability that SQL with binds for `insert`, `update`, and `delete` ↵Ryuta Kamizono2017-08-181-0/+32
| | | | | | | | | | | | | | | | (#29944) Since 213796f, it was lost the ability that SQL with binds for `insert`, `update`, and `delete` (like `select_all`). This restores the ability because `insert`, `update`, and `delete` are public API, so it should not be removed without deprecation.
* | Add test cases that class level `destroy`, `delete`, and `update` are ↵Ryuta Kamizono2017-08-181-3/+33
| | | | | | | | | | | | | | affected by scoping (#29997) I tried to change the expectation in #29976, but it is expected behavior at least for now. So I added the test cases to prevent anyone change the expectation.
* | Add test cases for `where.not` with polymorphic associationRyuta Kamizono2017-08-181-0/+19
| | | | | | | | | | | | | | | | | | | | | | `where.not` with multiple conditions is still unexpected behavior. But `where.not` with only polymorphic association has already been fixed in 213796fb. Closes #14161. Closes #16983. Closes #17010. Closes #26207.
* | Move `test_index_is_created_for_both_timestamps` to ↵Yasuo Honda2017-08-171-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `TimestampsWithoutTransactionTest` This commit addresses these failures when the backend RDBMS executes implicit commit for DDL like MySQL and Oracle. ```ruby $ ARCONN=mysql2 bin/test test/cases/integration_test.rb test/cases/timestamp_test.rb --seed 58225 -n '/^(?:TimestampTest#(?:test_index_is_created_for_both_timestamps)|IntegrationTest#(?:test_cache_key_for_newer_updated_at|test_cache_key_format_for_existing_record_with_updated_at|test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format))$/' -v Using mysql2 Run options: --seed 58225 -n "/^(?:TimestampTest#(?:test_index_is_created_for_both_timestamps)|IntegrationTest#(?:test_cache_key_for_newer_updated_at|test_cache_key_format_for_existing_record_with_updated_at|test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format))$/" -v TimestampTest#test_index_is_created_for_both_timestamps = 0.19 s = . IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at = 0.05 s = F IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format = 0.02 s = F IntegrationTest#test_cache_key_for_newer_updated_at = 0.01 s = F Finished in 0.272880s, 14.6585 runs/s, 14.6585 assertions/s. 1) Failure: IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:111]: --- expected +++ actual @@ -1 +1 @@ -"developers/1-20170717135609430848" +"developers/1-20170817135609283207" 2) Failure: IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:116]: --- expected +++ actual @@ -1 +1 @@ -"cached_developers/1-20170717135609" +"cached_developers/1-20170817135609" 3) Failure: IntegrationTest#test_cache_key_for_newer_updated_at [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:147]: --- expected +++ actual @@ -1 +1 @@ -"developers/1-20170717145609430848" +"developers/1-20170817135609283207" 4 runs, 4 assertions, 3 failures, 0 errors, 0 skips $ ``` `ActiveRecord::TestCase::TimestampTest#test_index_is_created_for_both_timestamps` calls`ActiveRecord::TestCase::TimestampTest#setup` which updates `updated_at` column value. ```ruby @developer = Developer.first ... snip ... @developer.update_columns(updated_at: Time.now.prev_month) ``` This transaction expected to be rolled back, but if the backend RDBMS like MySQL perfomes implicit commit when DDL executed, this transacion is committed by `create table` statement inside `ActiveRecord::TestCase::TimestampTest#test_index_is_created_for_both_timestamps`. It causes these failures above which expect `update_at` column value are not changed(rollbacked).
* | Merge pull request #30048 from yahonda/regexp_aware_schema_dumper_prefix_suffixRafael França2017-08-161-0/+25
|\ \ | | | | | | Allow `table_name_prefix` and `table_name_suffix` have `$`
| * | Allow `table_name_prefix` and `table_name_suffix` have `$`Yasuo Honda2017-08-041-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign. * MySQL 5.7 https://dev.mysql.com/doc/refman/5.7/en/identifiers.html > Permitted characters in unquoted identifiers: > ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) * PostgreSQL 9.6 https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html > SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard. Address #30044 [Yasuo Honda & Ryuta Kamizono]
* | | Merge pull request #30210 from koic/fix_rubocop_offensesMatthew Draper2017-08-161-1/+1
|\ \ \ | | | | | | | | Fix RuboCop offenses
| * | | Fix RuboCop offensesKoichi ITO2017-08-161-1/+1
| | | | | | | | | | | | | | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.
* | | | Fix test "_before_type_cast" for enum (#29004)Ryuta Kamizono2017-08-161-6/+8
|/ / / | | | | | | Since c51f9b61 changed the "_before_type_cast" expectation for enum.
* | | Through scope should not be affected by scopingRyuta Kamizono2017-08-151-0/+19
| | | | | | | | | | | | | | | | | | Follow up of #29834. Fixes #30266.
* | | Merge pull request #30169 from awortham/awortham/awortham/fix-sql-distinct-bugRafael Mendonça França2017-08-141-0/+26
|\ \ \ | | | | | | | | | | | | Ensure sum honors distinct on has_many through
| * | | Ensure sum honors distinct on has_many throughAaron Wortham2017-08-141-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | When using a has_many through relation and then summing an attribute the distinct was not being used. This will ensure that when summing an attribute, the number is only used once when distinct has been used.
* | | | Merge pull request #30215 from untidy-hair/clarify-abstract-or-not-in-testsRafael França2017-08-143-8/+18
|\ \ \ \ | | | | | | | | | | Clarify base_class tests on abstract STI vs concrete STI
| * | | | Clarify base_class tests on abstract STI vs concrete STIYukio Mizuta2017-08-123-8/+18
| | | | |
* | | | | Merge pull request #30073 from yalab/fixture_binary_helperRafael França2017-08-142-1/+6
|\ \ \ \ \ | | | | | | | | | | | | Add `binary` helper method to fixtures.
| * | | | | Add `binary` helper method to fixtures.yalab2017-08-122-1/+6
| | |_|/ / | |/| | |
* | | | | Merge pull request #27609 from kamipo/fix_association_primary_keyRafael França2017-08-142-17/+14
|\ \ \ \ \ | | | | | | | | | | | | Fix `reflection.association_primary_key` for `has_many` association
| * | | | | Fix `reflection.association_primary_key` for `has_many` associationsRyuta Kamizono2017-08-132-17/+14
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is incorrect to treat `options[:primary_key]` as `association_primary_key` if `has_many` associations because the `:primary_key` means the column on the owner record, not on the association record. It will break `ids_reader` and `ids_writer`. ```ruby people(:david).essay_ids # => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David' ``` Fixes #14439.
* | | | | Merge pull request #30229 from kamipo/allow_serialize_with_custom_coderRafael França2017-08-142-2/+50
|\ \ \ \ \ | | | | | | | | | | | | Allow `serialize` with a custom coder on `json` and `array` columns
| * | | | | Allow `serialize` with a custom coder on `json` and `array` columnsRyuta Kamizono2017-08-132-2/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already have a test case for `serialize` with a custom coder in `PostgresqlHstoreTest`. https://github.com/rails/rails/blob/v5.1.3/activerecord/test/cases/adapters/postgresql/hstore_test.rb#L316-L335
* | | | | | Merge pull request #30214 from kirs/uniqueness-scope-validatorRafael França2017-08-141-0/+7
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | | Check :scope input in Uniqueness validator
| * | | | | Check :scope input in Uniqueness validatorKir Shatrov2017-08-131-0/+7
| | |/ / / | |/| | |
* | | | | Fix CI failure due to reference type mismatchRyuta Kamizono2017-08-142-12/+18
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | `Firm.id` is a bigint if mysql2 adapter is used, but `firm_id` is an integer. It will cause an out of range error. https://travis-ci.org/rails/rails/jobs/264112814#L776 https://travis-ci.org/rails/rails/jobs/264112835#L919
* | | | Merge pull request #30228 from kamipo/fix_random_ci_failureMatthew Draper2017-08-131-2/+4
|\ \ \ \ | | | | | | | | | | Fix random CI failure due to non-deterministic sorting order
| * | | | Fix random CI failure due to non-deterministic sorting orderRyuta Kamizono2017-08-131-2/+4
| |/ / / | | | | | | | | | | | | https://travis-ci.org/rails/rails/jobs/263617099#L769-L775
* | | | Merge pull request #30079 from ↵Matthew Draper2017-08-132-11/+11
|\ \ \ \ | |/ / / |/| | | | | | | | | | | kamipo/move_test_not_compatible_with_serialize_macro Move `test_not_compatible_with_serialize_macro` to `JSONSharedTestCases`
| * | | Move `test_not_compatible_with_serialize_macro` to `JSONSharedTestCases`Ryuta Kamizono2017-08-112-11/+11
| | | | | | | | | | | | | | | | Because `JSONSharedTestCases` is also used for `Mysql2JSONTest`.
* | | | Merge pull request #30126 from ↵Rafael França2017-08-111-0/+14
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | chopraanmol1/support_for_has_many_and_has_one_for_where_relation Fixed query building when relation is passed for has one or has many association in where
| * | | | Currently if relation object are passed to where condition for has one or ↵chopraanmol12017-08-081-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | has many association wrong set of primary key and foreign key are selected. Changed code to use 'join' primary key and foreign key over 'association' primary key and foreign key.
* | | | | Merge pull request #30103 from yahonda/has_one_associations_failuresRafael França2017-08-111-1/+1
|\ \ \ \ \ | | | | | | | | | | | | Add `:authors` to address random failures at HasOneAssociationsTest
| * | | | | Add `:authors` fixture to address two random failures at HasOneAssociationsTestYasuo Honda2017-08-061-1/+1
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * sqlite3 - 2 failures ```ruby $ ARCONN=sqlite3 bin/test test/cases/associations/has_one_associations_test.rb test/cases/view_test.rb --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose Using sqlite3 Run options: --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose ViewWithoutPrimaryKeyTest#test_attributes = 0.02 s = . HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace = 0.12 s = F HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy = 0.01 s = F Finished in 0.162504s, 18.4610 runs/s, 18.4610 assertions/s. 1) Failure: HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace [/home/yahonda/git/rails/activerecord/test/cases/associations/has_one_associations_test.rb:725]: Expected true to be nil or false 2) Failure: HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy [/home/yahonda/git/rails/activerecord/test/cases/associations/has_one_associations_test.rb:715]: Expected true to be nil or false 3 runs, 3 assertions, 2 failures, 0 errors, 0 skips ``` * mysql2 - 1 failure ``` $ ARCONN=mysql2 bin/test test/cases/associations/has_one_associations_test.rb test/cases/view_test.rb --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose Using mysql2 Run options: --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose ViewWithoutPrimaryKeyTest#test_attributes = 0.07 s = . HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace = 0.27 s = F HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy = 0.02 s = . Finished in 0.362779s, 8.2695 runs/s, 8.2695 assertions/s. 1) Failure: HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace [/home/yahonda/git/rails/activerecord/test/cases/associations/has_one_associations_test.rb:725]: Expected true to be nil or false 3 runs, 3 assertions, 1 failures, 0 errors, 0 skips ``` * postgresql - 0 failures ```ruby $ ARCONN=postgresql bin/test test/cases/associations/has_one_associations_test.rb test/cases/view_test.rb --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose Using postgresql Run options: --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose ViewWithoutPrimaryKeyTest#test_attributes = 0.06 s = . HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy = 0.22 s = . HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace = 0.02 s = . Finished in 0.311217s, 9.6396 runs/s, 9.6396 assertions/s. 3 runs, 3 assertions, 0 failures, 0 errors, 0 skips ```
* | | | | Merge pull request #29720 from gaurish/ar_find_error_message_improvementRafael França2017-08-112-3/+5
|\ \ \ \ \ | | | | | | | | | | | | Return Not found Ids in ActiveRecord::NotFound
| * | | | | Return Not found Ids in ActiveRecord::NotFoundGaurish Sharma2017-07-292-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This builds on top of 15e2da656f41af0124f7577858536f3b65462ad5. now it also returns exact Ids which were not found which will be debugging simple.
* | | | | | Specify `table.name` only when `scope.table` and `table` are different (#29058)Ryuta Kamizono2017-08-111-0/+1
| |_|/ / / |/| | | | | | | | | Fixes #29045.
* | | | | Merge pull request #30152 from bogdanvlviv/fix_random_ci_failureMatthew Draper2017-08-101-1/+1
|\ \ \ \ \ | | | | | | | | | | | | Fix random CI failure due to non-deterministic sorting order