aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Merge pull request #30392 from koic/unify_source_control_keep_file_nameMatthew Draper2017-08-311-0/+0
|\ \ \ | | | | | | | | Unify the internal source control .keep file name
| * | | Unify the internal source control .keep file nameKoichi ITO2017-08-241-0/+0
| |/ /
* | | Fix `can't modify frozen String` error in `DatabaseTasks`yuuji.yaginuma2017-08-302-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this, `db:structure:dump` task raises an error as follwing: ``` can't modify frozen String activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:77:in `run_cmd_error' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:72:in `run_cmd' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:52:in `structure_dump' activerecord/lib/active_record/tasks/database_tasks.rb:219:in `structure_dump' activerecord/lib/active_record/railties/databases.rake:279:in `block (3 levels) in <main>' railties/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' railties/lib/rails/commands/rake/rake_command.rb:20:in `perform' railties/lib/rails/command.rb:48:in `invoke' railties/lib/rails/commands.rb:18:in `<main>' ```
* | | "models/reader" is no longer used in `autosave_association_test.rb`Ryuta Kamizono2017-08-281-1/+0
| | |
* | | Address `test_assign_ids_for_through_a_belongs_to` failureRyuta Kamizono2017-08-281-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | If `:readers` fixture is loaded before the test, it will be failed. Use `firm.developer_ids` instead because we don't have `:contracts` fixture for now. https://travis-ci.org/rails/rails/jobs/268976230#L729
* | | Should be appear deprecation message for every call (#29649)Ryuta Kamizono2017-08-271-0/+1
| | | | | | | | | Context: https://github.com/rails/rails/pull/29619#discussion_r125158589
* | | Omit the default limit for float columns (#28041)Ryuta Kamizono2017-08-272-4/+9
| | |
* | | Prefer to place a table options before `force: :cascade` (#28005)Ryuta Kamizono2017-08-274-9/+9
| | | | | | | | | | | | | | | | | | I was added a table options after `force: :cascade` in #17569 for not touching existing tests (reducing diff). But `force: :cascade` is not an important information. So I prefer to place a table options before `force: :cascade`.
* | | Fix random CI failure due to non-deterministic sorting orderRyuta Kamizono2017-08-261-6/+6
| | | | | | | | | | | | https://travis-ci.org/rails/rails/jobs/268599781#L784
* | | Should work inverse association when eager loadingRyuta Kamizono2017-08-251-0/+6
| | | | | | | | | | | | | | | | | | | | | This regression was caused by caa178c1. The block for `set_inverse_instance` should also be passed to join dependency. Fixes #30402.
* | | Address `test_after_save_callback_with_autosave` failureYasuo Honda2017-08-241-0/+4
| | | | | | | | | | | | | | | | | | | | | when other `AutomaticInverseFindingTests` load `:comments` fixture but does not load `:posts`. Refer #30385 for similar issue
* | | 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