aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* add mysql and sqlite3 default testkenjiszk2018-09-011-3/+5
| | | | [Gannon McGibbon + Kenji Suzuki]
* Ensure casting by boolean attribute when queryingRyuta Kamizono2018-05-291-43/+0
| | | | | | | | | | | `QueryAttribute#value_for_database` calls only `type.serialize`, and `Boolean#serialize` is a no-op unlike other attribute types. It caused the issue #32624. Whether or not `serialize` will invoke `cast` is undefined in our test cases, but it actually does not work properly unless it does so for now. Fixes #32624.
* Fix typo in ActiveRecord test method nameTakayoshi Nishida2018-05-021-1/+1
|
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-5/+5
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Autocorrect `refute` RuboCop violationsDaniel Colson2018-04-031-1/+1
| | | | | | 73e7aab behaved as expected on codeship, failing the build with exactly these RuboCop violations. Hopefully `rubocop -a` will have been enough to get a passing build!
* Properly escape column name embedded into regexpAndreas Bühmann2018-02-221-1/+1
| | | | | | | | | SQLServerAdapter (gem `activerecord-sqlserver-adapter`) uses square brackets for quoting column names (e.g. `[id]`). Those brackets must not be misinterpreted in regular expressions. Failure: Expected /SELECT [developers].[id].* FROM developers/ to match "SELECT [developers].[id], [developers].[name], [developers].[salary], [developers].[firm_id], [developers].[mentor_id], [developers].[created_at], [developers].[updated_at], [developers].[created_on], [developers].[updated_on] FROM developers".
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-31/+31
|
* Change refute to assert_notDaniel Colson2018-01-251-1/+1
|
* Use respond_to test helpersDaniel Colson2018-01-251-22/+22
|
* Make `sql_type` of primary key in SQLite to comparable with an integer (#28008)Ryuta Kamizono2017-12-261-1/+1
| | | | | Originally I tried to add `assert_equal pk.sql_type, ref.sql_type`. But the assert failed even though the same type due to `sql_type` of primary key in SQLite is upper case. Prefer lower case like other types.
* Using table name qualified column names unless having SELECT list explicitlyRyuta Kamizono2017-12-181-3/+7
| | | | | | Previously table name qualified `*` is used in that case. If it is not qualified with a table name, an ambiguous column name error will occur when using JOINs.
* Convert protected_environments to an array of stringsbogdanvlviv2017-12-121-0/+12
| | | | | | | These changes prevent ignoring environments name of which is a `Symbol` ``` config.active_record.protected_environments = ['staging', :production] ```
* Merge pull request #31403 from Edouard-chin/fix-quoted-columnnameRafael França2017-12-121-0/+8
|\ | | | | Quote colum_names when building select:
| * Quote colum_names when building select:Edouard CHIN2017-12-111-0/+8
| | | | | | | | | | | | | | | | - #30980 introcuded a change to not use `Arel.star` when model have ignored columns, a query used to look like `SELECT *. FROM developers` whereas now it would like `SELECT column1, column2 FROM developers` - If a column has the same name has a reserved database specific keyword (such as key, where ...) then the query would fail because the names aren't quoted - Quoting almost always happen unless we use a `from` clause in the query https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1052 - This PR cast all columns name to symbols in order for the quoting logic to be picked up https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1054-L1055 - A reproduction script can be found here https://gist.github.com/Edouard-chin/f56d464a0adcb76962afc1a9134a1536
* | Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-1/+1
|/ | | | Follow up of #31390.
* SQLite3 valid integer value should be 8 bytes (64-bit signed integer) (#28379)Ryuta Kamizono2017-12-031-5/+3
| | | | | | | | | | | | | | | This is a regression since Rails 4.2. SQLite3 integer is stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. Assuming default valid value as 4 bytes caused that actual valid value in INTEGER storage class cannot be stored and existing value cannot be found. https://www.sqlite.org/datatype3.html We should allow valid value in INTEGER storage class in SQLite3 to fix the regression. Fixes #22594.
* Allow test_ignored_columns_not_included_in_SELECT column names caseYasuo Honda2017-11-151-1/+1
| | | | | | | | | | | insensitive i.e. Oracle database identifier is UPPERCASE unlike other databases. ```ruby (byebug) query = Developer.all.to_sql "SELECT \"DEVELOPERS\".\"ID\", \"DEVELOPERS\".\"NAME\", \"DEVELOPERS\".\"SALARY\", \"DEVELOPERS\".\"FIRM_ID\", \"DEVELOPERS\".\"MENTOR_ID\", \"DEVELOPERS\".\"CREATED_AT\", \"DEVELOPERS\".\"UPDATED_AT\", \"DEVELOPERS\".\"CREATED_ON\", \"DEVELOPERS\".\"UPDATED_ON\" FROM \"DEVELOPERS\"" ```
* Do not use `Arel.star` when `ignored_columns`Jon Moss2017-11-131-0/+21
| | | | | | | If there are any ignored columns, we will now list out all columns we want to be returned from the database. Includes a regression test.
* Convert ignored_columns to a list of stringAltech2017-10-201-0/+12
|
* Test `ignored_columns` value is inheritable by subclassesRyuta Kamizono2017-10-191-0/+7
|
* Fix CI failure due to reference type mismatchRyuta Kamizono2017-08-141-2/+9
| | | | | | | | `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
* Remove duplicated assertion in `test_count_with_join`Ryuta Kamizono2017-07-241-16/+2
| | | | | The queries both `res2` and `res3` are completely the same. And also, `assert_nothing_raised` is covered by following assertion.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Merge pull request #26634 from kamipo/extract_numeric_dataRafael França2017-05-311-74/+0
|\ | | | | Extract `NumericData` model for tests
| * Extract `NumericDataTest` to `test/cases/numeric_data_test.rb`Ryuta Kamizono2016-12-221-68/+0
| | | | | | | | | | To ease to find the numeric data tests, extract `NumericDataTest` to `test/cases/numeric_data_test.rb` dedicated file.
| * Extract `NumericData` model for testsRyuta Kamizono2016-09-271-7/+1
| | | | | | | | Currently `NumericData` model is defined some places.
* | Restore `fixtures :author_addresses`Ryuta Kamizono2017-04-271-1/+1
| | | | | | | | | | This change reverted in eac6f369 but it is needed for data integrity. See #25328.
* | Revert "Merge pull request #27636 from ↵Rafael Mendonça França2017-04-261-1/+1
| | | | | | | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privilege-take-2" This reverts commit c1faca6333abe4b938b98fedc8d1f47b88209ecf, reversing changes made to 8c658a0ecc7f2b5fc015d424baf9edf6f3eb2b0b. See https://github.com/rails/rails/pull/27636#issuecomment-297534129
* | Merge pull request #28161 from bogdanvlviv/add_test_attributesRafael França2017-04-181-0/+11
|\ \ | | | | | | Add test for method `#attributes`
| * | Add test for method `#attributes`bogdanvlviv2017-02-251-0/+11
| | | | | | | | | | | | | | | | | | ActiveRecord::AttributeMethods#attributes Extracted from https://github.com/rails/rails/pull/28159
* | | Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2017-03-261-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | privileges (take 2) Re-create https://github.com/rails/rails/pull/21233 eeac6151a5 was reverted (127509c071b4) because it breaks tests. ---------------- ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* | `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-071-0/+7
| | | | | | | | | | | | | | | | Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
* | Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* | Merge pull request #21233 from ↵Rafael França2017-01-031-1/+1
|\ \ | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
| * | Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | privileges ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* | | Merge pull request #27335 from kamipo/remove_duplicated_model_definitionSean Griffin2017-01-031-10/+1
|\ \ \ | | | | | | | | Remove duplicated model class definitions in `test/cases/base_test.rb`
| * | | Remove duplicated model class definitions in `test/cases/base_test.rb`Ryuta Kamizono2016-12-121-10/+1
| |/ /
* | | Remove deprecated `#uniq`, `#uniq!`, and `#uniq_value`Ryuta Kamizono2016-12-301-6/+0
| | |
* | | Remove deprecated support to query using commas on LIMITRafael Mendonça França2016-12-291-12/+2
| | |
* | | "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-1/+1
|/ /
* | allow ActiveRecord::Core#slice to use array argCohen Carlisle2016-10-311-0/+10
| |
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-14/+14
|/
* improve error message when include assertions failMichael Grosser2016-09-161-1/+1
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Add three new rubocop rulesRafael Mendonça França2016-08-161-3/+3
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Pass along original attribute to save later recursionAaron Patterson2016-08-141-0/+7
| | | | Fixes #26122
* Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-1/+2
| | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+1
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-12/+10
|