aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
Commit message (Collapse)AuthorAgeFilesLines
* use correct method in batches testyuuji.yaginuma2015-03-291-2/+3
|
* Partially merge #17650Sean Griffin2015-03-265-14/+14
|\ | | | | | | | | Merges 1d8d5a74b81b8aab1f5e6d233d509a92525ed4e1. The pull request as a whole is quite large, and I'm reviewing the smaller pieces individually.
| * PostgreSQL, Fix OID based type casts in C for primitive types.Lars Kanis2015-03-255-14/+14
| | | | | | | | | | | | | | | | | | | | The type map was introduced in aafee23, but wasn't properly filled. This mainly adjusts many locations, that expected strings instead of integers or boolean. add_pg_decoders is moved after setup of the StatementPool, because execute_and_clear could potentially make use of it.
* | Add `config.active_record.warn_on_records_fetched_greater_than` optionJason Nochlin2015-03-251-0/+28
|/ | | | | | | | | When set to an integer, a warning will be logged whenever a result set larger than the specified size is returned by a query. Fixes #16463 The warning is outputed a module which is prepended in an initializer, so there will be no performance impact if `config.active_record.warn_on_records_fetched_greater_than` is not set.
* Merge pull request #19503 from jasoncodes/no-psqlrcYves Senn2015-03-251-2/+2
| | | | Avoid loading user's psqlrc when loading test structure
* Merge pull request #19452 from ↵Carlos Antonio da Silva2015-03-241-0/+11
|\ | | | | | | | | | | pinglamb/fix-referencing-wrong-alias-when-joining-tables-of-has-many-through-association Fix referencing wrong aliases while joining tables of has many through association
| * Fix referencing wrong aliases while joining tables of has many throughpinglamb2015-03-221-0/+11
| | | | | | | | | | | | | | | | | | | | | | association While joining table of has_many :through association, ActiveRecord will use the actual table name instead of through-join alias. It results with a wrong SQL and exception is raised. This only happens when calculation methods like #count is called. This issue is affecting Rails 4.1.x and 4.2.x as well.
* | Merge pull request #19493 from larskanis/add_infinity_testYves Senn2015-03-241-0/+9
|\ \ | | | | | | PostgreSQL, Add test case for "Infinity" string assignment to float columns
| * | PostgreSQL, Add test case for "Infinity" string assignment to float columns.Lars Kanis2015-03-221-0/+9
| |/ | | | | | | This is implemented in Type::Float, but not tested, so far.
* | remove old unavailable link with relevant fixGaurav Sharma2015-03-232-3/+1
| |
* | Make sure to persist a newly-nil serialized valueMatthew Draper2015-03-231-0/+10
|/ | | | | | | The subtype will (quite reasonably) ignore the possibility that it has `changed_in_place?` by becoming nil. Fixes #19467
* Delegate limit to subtypewallerjake2015-03-211-0/+5
| | | | | | | | | | As described here https://github.com/rails/rails/issues/19420. When using the Postgres BigInt[] field type the big int value was not being translated into schema.rb. This caused the field to become just a regular integer field when building off of schema.rb. This fix will address this by delegating the limit from the subtype to the Array type. https://github.com/rails/rails/issues/19420
* Revert "Merge pull request #19404 from dmathieu/remove_rack_env"Jeremy Kemper2015-03-201-0/+34
| | | | | | | Preserving RACK_ENV behavior. This reverts commit 7bdc7635b885e473f6a577264fd8efad1c02174f, reversing changes made to 45786be516e13d55a1fca9a4abaddd5781209103.
* Don't cast nil to string in pg enumsSean Griffin2015-03-191-0/+8
| | | | Fixes #19389.
* don't fallback to RACK_ENV when RAILS_ENV is not presentDamien Mathieu2015-03-191-34/+0
|
* Improve test for leaky scope chaineileencodes2015-03-181-1/+7
| | | | | | | | | | | | | | | | This is a better test for 51660f0. It is testing that the SQL is the same before and after the previously leaky scope is called. Before if `hotel.drink_designers` was called first then `hotel.recipes` would incorrectly get the scope applied. We want to be sure that the polymorphic hm:t association is not leaking into or affecting the SQL for the hm:t association on `Hotel`. The reason I couldn't do this before was because there was an issue with the SQL getting cached and wanted to resolve that later and then fix the test to be better. Because of the caching, this test requires that `Hotel.reflect_on_association(:recipes).clear_association_scope_cache` be called after the first call to `hotel.recipes` to clear the assocation scope chain and not interfere with the rest of the test.
* Merge pull request #19348 from Empact/null-scopeYves Senn2015-03-181-0/+12
|\ | | | | | | | | | | | | Reuse the CollectionAssociation#reader proxy cache if the foreign key is present from the start. Conflicts: activerecord/CHANGELOG.md
| * Reuse the CollectionAssociation#reader proxy cache if the foreign key is ↵Ben Woosley2015-03-151-0/+12
| | | | | | | | | | | | | | | | | | | | present from the start. When a new record has the necessary information prior to save, we can avoid busting the cache. We could simply clear the @proxy on #reset or #reset_scope, but that would clear the cache more often than necessary.
* | Add config.active_record.dump_schemas.Ryan Wallace2015-03-171-6/+39
| | | | | | | | | | | | | | Fixes db:structure:dump when using schema_search_path and PostgreSQL extensions. Closes #17157.
* | Remove unused variable in activerecord reflection_test.Juanito Fatas2015-03-171-1/+1
| |
* | Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-1649-79/+115
|/ | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Fix leaky chain on polymorphic associationeileencodes2015-03-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there was a polymorphic hm:t association with a scope AND second non-scoped hm:t association on a model the polymorphic scope would leak through into the call for the non-polymorhic hm:t association. This would only break if `hotel.drink_designers` was called before `hotel.recipes`. If `hotel.recipes` was called first there would be no problem with the SQL. Before (employable_type should not be here): ``` SELECT COUNT(*) FROM "drink_designers" INNER JOIN "chefs" ON "drink_designers"."id" = "chefs"."employable_id" INNER JOIN "departments" ON "chefs"."department_id" = "departments"."id" WHERE "departments"."hotel_id" = ? AND "chefs"."employable_type" = ? [["hotel_id", 1], ["employable_type", "DrinkDesigner"]] ``` After: ``` SELECT COUNT(*) FROM "recipes" INNER JOIN "chefs" ON "recipes"."chef_id" = "chefs"."id" INNER JOIN "departments" ON "chefs"."department_id" = "departments"."id" WHERE "departments"."hotel_id" = ? [["hotel_id", 1]] ``` From the SQL you can see that `employable_type` was leaking through when calling recipes. The solution is to dup the chain of the polymorphic association so it doesn't get cached. Additionally, this follows `scope_chain` which dup's the `source_reflection`'s `scope_chain`. This required another model/table/relationship because the leak only happens on a hm:t polymorphic that's called before another hm:t on the same model. I am specifically testing the SQL here instead of the number of records becasue the test could pass if there was 1 drink designer recipe for the drink designer chef even though the `employable_type` was leaking through. This needs to specifically check that `employable_type` is not in the SQL statement.
* Fix before_commit when updating a record on the callbackArthur Neves2015-03-141-0/+22
|
* pg, `disable_referential_integrity` only catches AR errors.Yves Senn2015-03-111-1/+23
| | | | This change was prompted by 598b841.
* Fix json_testpalkan2015-03-111-0/+1
|
* Add YAML compatibility for objects from Rails 4.2Sean Griffin2015-03-101-26/+18
| | | | | | | | | | | As of Ruby 2.2, Psych can handle any object which is marshallable. This was not true on previous versions of Ruby, so our delegator types had to provide their own implementation of `init_with` and `encode_with`. Unfortunately, this doesn't match up with what Psych will do today. Since by the time we hit this layer, the objects will have already been created, I think it makes the most sense to just grab the current type from the class.
* Attempt to provide backwards compatible YAML deserializationSean Griffin2015-03-101-0/+43
| | | | | | | | | | | | | | | | | | I should have done this in the first place. We are now serializing an explicit version so we can make more careful changes in the future. This will load Active Record objects which were serialized in Rails 4.1. There will be bugs, as YAML serialization was at least partially broken back then. There will also be edge cases that we might not be able to handle, especially if the type of a column has changed. In addition, we're passing this as `from_database`, since that is required for serialized columns at minimum. All other types were serializing the cast value. At a glance, there should be no types for which this is a problem. Finally, dirty checking information will be lost on records serialized in 4.1, so no columns will be marked as changed.
* Fix intermittent test failuresSean Griffin2015-03-091-0/+1
| | | | | | | | | | The table is being modified in tests, without reloading the column information on the appropriate class. This is leading to incorrect column information in many cases. The failures fixed by this commit can be replicated with: ARCONN=postgresql ruby -Itest test/cases/adapters/postgresql/hstore_test.rb --seed 21574
* Fix intermittent test failuresSean Griffin2015-03-091-0/+1
| | | | | | | | | | | The default value of `"pg_arrays"."tags"` is being changed to `[]` in one test, but the column information on the model isn't reset after it's changed back. As such, we think the default value is `[]` when in the database it's actually `nil`. That means any test which was assigning `[]` to a new record would have that key skipped with partial writes, as it hasn't changed from the default. However since the *actual* default value is `nil`, we get back values that the test doesn't expect, and it fails.
* Merge pull request #18200 from brainopia/rollback_frozen_recordsArthur Nogueira Neves2015-03-071-0/+18
|\ | | | | Fix rollback of frozen records
| * Fix transaction state for unsynced records when entering transactionbrainopia2015-03-041-0/+9
| |
| * Fix rollback of frozen recordsbrainopia2015-03-041-0/+9
| |
* | Merge pull request #19221 from matthewd/random-testsMatthew Draper2015-03-061-5/+0
|\ \ | | | | | | Run all our tests in random order
| * | Revert "Leave all our tests as order_dependent! for now"Matthew Draper2015-03-061-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2f52f969885b2834198de0045748436a4651a94e. Conflicts: actionmailer/test/abstract_unit.rb actionview/test/abstract_unit.rb activemodel/test/cases/helper.rb activerecord/test/cases/helper.rb activesupport/test/abstract_unit.rb railties/test/abstract_unit.rb
* | | tests, sequences are derived from the base class.Yves Senn2015-03-061-7/+10
| | | | | | | | | | | | | | | Using a subclass to check the sequence name does not work in that case. The sequence name will be calucalted based on the base class.
* | | Revert ":cut: remove unnecessary rescue Exceptions"Yves Senn2015-03-062-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit ff18049ca6f27deb7e7f955478e1464f8d756332. This broke the AR build for every adapter: 1) Error: AssociationCallbacksTest#test_dont_add_if_before_callback_raises_exception: Exception: You can't add a post 2) Failure: QueryCacheTest#test_query_cache_doesnt_leak_cached_results_of_rolled_back_queries [/Users/senny/Projects/rails/activerecord/test/cases/query_cache_test.rb:235]: Expected: 1 Actual: 0 I'm reverting to get the build green again.
* | | replace `repair_validations` with a disposable subclass.Yves Senn2015-03-061-32/+33
| | |
* | | tests, remove side effects on `Joke` during `base_test.rb`.Yves Senn2015-03-061-23/+28
| | | | | | | | | | | | prompted by #19221.
* | | :cut: remove unnecessary rescue ExceptionsAaron Patterson2015-03-052-2/+2
| | |
* | | remove unnecessary rescueAaron Patterson2015-03-051-2/+0
|/ /
* | add ActiveRecord::Enum testcase about multiple enums declaring at a timekeepcosmos2015-03-051-0/+14
| |
* | add regression test. Closes #18400.Yves Senn2015-03-051-0/+6
| |
* | Remove duplicated testRyuta Kamizono2015-03-041-20/+0
| | | | | | | | | | `PostgresqlLargeKeysTest` is duplicated `PrimaryKeyBigSerialTest` in `primary_keys_test.rb`.
* | Correctly dump `serial` and `bigserial`Ryuta Kamizono2015-03-041-0/+60
|/
* Merge pull request #19176 from imajes/masterYves Senn2015-03-031-0/+16
|\ | | | | Fixes reference for schema_format to AR::Base from AS::Base
| * Fixes reference for schema_format to AR::Base from AS::BaseJames Cox2015-03-031-0/+16
| |
* | Remove unused lineRyuta Kamizono2015-03-031-1/+0
| |
* | Merge pull request #19177 from gregmolnar/fixturesRafael Mendonça França2015-03-021-1/+1
|\ \ | |/ |/| Added testcase for #18742
| * test reset_pk_sequence with multi connectionGreg Molnar2015-03-011-1/+1
| |
* | tests, favor `drop_table` and `:if_exists` over raw SQL.Yves Senn2015-03-022-2/+2
| | | | | | | | | | We've replaced most querues using DROP TABLE in our tests already. This patch replaces the last couple calls.