aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/persistence_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* `Persistence#delete` should not be affected by scopingRyuta Kamizono2017-07-181-0/+7
| | | | | `self.class.delete` is delegated to `all` and `all` is affected by scoping. It should use `unscoped` to not be affected by that.
* 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
|
* Replace \Z to \zRyuta Kamizono2017-04-241-1/+1
| | | | \Z was a mistake of \z. Replace \Z to \z to prevent newly \Z added.
* Add the touch option to ActiveRecord#increment! and decrement!akihiro172017-01-141-0/+16
| | | | | Supports the `touch` option from update_counters. The default behavior is not to update timestamp columns.
* fixing update_all and delete_all when chained with left_joins. fixes #27192Diego Plentz2016-11-271-0/+22
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Return true if attribute is not changed for update_attributePrathamesh Sonpatki2016-09-231-3/+3
| | | | | | | | | | | | | | - If the attribute is not changed, then update_attribute does not run SQL query, this effectively means that no change was made to the attribute. - This change was made in https://github.com/rails/rails/commit/0fcd4cf5 to avoid a SQL call. - But the change resulted into `nil` being returned when there was no change in the attribute value. - This commit corrects the behavior to return true if there is no change in attribute value. This is same as previous behavior of Rails 4.2 plus benefit of no additional SQL call. - Fixes #26593.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-1/+2
| | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-10/+8
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-9/+9
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-95/+95
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Typos in AR testsAkira Matsuda2016-02-031-1/+1
|
* `ActiveRecord::Base#becomes` should copy the errorsVokhmin Alexey V2015-12-141-1/+20
|
* Fix test failuresSean Griffin2015-11-071-0/+1
| | | | | The previous commit changes the state of the class, and while we are cleaning up the database, I forgot to clean up the class
* Ensure `#reset_column_information` clears child classes as wellSean Griffin2015-11-071-0/+12
| | | | | | | | | | | | | | I've added a redundant test for this under the attributes API as well, as that also causes this bug to manifest through public API (and demonstrates that calling `reset_column_information` on the child classes would be insufficient) Since children of a class should always share a table with their parent, just reloading the schema from the cache should be sufficient here. `reload_schema_from_cache` should probably become public and `# :nodoc:`, but I'd rather avoid the git churn here. Fixes #22057
* Deprecate exception#original_exception in favor of exception#causeYuki Nishijima2015-11-031-1/+2
|
* Make #increment! and #decrement! methods concurency safeBogdan Gusiev2015-10-051-0/+9
|
* Deprecate passing conditions to AR::Relation destroy_all and delete_all methodsWojciech Wnętrzak2015-09-061-1/+1
|
* Fix failing tests caused by #21350Sean Griffin2015-08-241-0/+1
|
* Cause ActiveRecord::Base::reload to also ignore the QueryCache.Shane Hender2015-04-281-0/+27
|
* use Model.reset_column_information to clear table cache connection wide.Kuldeep Aggarwal2015-03-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `widgets` table is being created in `primary_keys_test.rb` for PostgreSQLAdapter, MysqlAdapter, Mysql2Adapter and it makes test to fail earlier. Before: `bundle exec rake mysql2:test` ``` Finished in 127.287669s, 35.5258 runs/s, 97.8885 assertions/s. 1) Error: PersistenceTest::SaveTest#test_save_touch_false: ActiveModel::UnknownAttributeError: unknown attribute 'name' for #<Class:0x0000000a7d6ef0>. /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:36:in `rescue in _assign_attribute' /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:34:in `_assign_attribute' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `each' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `_assign_attributes' /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `_assign_attributes' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:33:in `assign_attributes' /home/kd/projects/kd-rails/activerecord/lib/active_record/core.rb:293:in `initialize' /home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new' /home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new' /home/kd/projects/kd-rails/activerecord/lib/active_record/persistence.rb:50:in `create!' /home/kd/projects/kd-rails/activerecord/test/cases/persistence_test.rb:913:in `test_save_touch_false' 4522 runs, 12460 assertions, 0 failures, 1 errors, 4 skips ``` After: `bundle exec rake mysql2:test` ``` Finished in 135.785086s, 33.3026 runs/s, 91.7774 assertions/s. 4522 runs, 12462 assertions, 0 failures, 0 errors, 4 skips ```
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* add regression test. Closes #18400.Yves Senn2015-03-051-0/+6
|
* Run SQL only if attribute changed for update_attribute methodPrathamesh Sonpatki2015-01-181-0/+10
| | | | | - This is based on https://github.com/rails/rails/issues/18400 but tackling same issue with update_attribute method instead of update method.
* Merge pull request #11898 from prathamesh-sonpatki/patch-updateRafael Mendonça França2015-01-021-2/+4
|\ | | | | | | | | | | | | Changed ActiveRecord::Relation#update behavior so that it will work on Relation objects without giving id Conflicts: activerecord/CHANGELOG.md
| * Allow ActiveRecord::Relation#update to run on result of a relation with ↵Prathamesh Sonpatki2014-12-201-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | callbacks and validations - Right now, there is no method to update multiple records with validations and callbacks. - Changed the behavior of existing `update` method so that when `id` attribute is not given and the method is called on an `Relation` object, it will execute update for every record of the `Relation` and will run validations and callbacks for every record. - Added test case for validating that the callbacks run when `update` is called on a `Relation`. - Changed test_create_columns_not_equal_attributes test from persistence_test to include author_name column on topics table as it it used in before_update callback. - This change introduces performance issues when a large number of records are to be updated because it runs UPDATE query for every record of the result. The `update_all` method can be used in that case if callbacks are not required because it will only run single UPDATE for all the records.
* | Provide :touch option to save() to accommodate saving without updating ↵Dan Olson2014-12-271-0/+31
|/ | | | timestamps. [#18202]
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-2/+2
|
* Build fix when running in isolationArun Agrawal2014-11-141-0/+1
| | | | | `Computer` class needs to be require See #17217 for more details
* Fix mysql/mysql2 failing with FK constraint errorsGodfrey Chan2014-07-051-1/+1
| | | | | | | | | One of the author fixture we have ("david") references an author address by ID. Since we disable FK checks when inserting fixtures, this is all fine until we try to update it, at which point MySQL would complain about the missing row referenced by the `author_address_id`. [Godfrey Chan, Matthew Draper]
* After find-via-reload, the record is not newMatthew Draper2014-07-051-0/+12
|
* `reload` should fully reload attributesSean Griffin2014-06-221-0/+7
| | | | | | `reload` is meant to put a record in the same state it would be if you were to do `Post.find(post.id)`. This means we should fully replace the attributes hash.
* Merge pull request #15593 from sgrif/sg-attributeRafael Mendonça França2014-06-131-9/+4
|\ | | | | Introduce an Attribute object to handle the type casting dance
| * Introduce an Attribute object to handle the type casting danceSean Griffin2014-06-131-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a lot more that can be moved to these, but this felt like a good place to introduce the object. Plans are: - Remove all knowledge of type casting from the columns, beyond a reference to the cast_type - Move type_cast_for_database to these objects - Potentially make them mutable, introduce a state machine, and have dirty checking handled here as well - Move `attribute`, `decorate_attribute`, and anything else that modifies types to mess with this object, not the columns hash - Introduce a collection object to manage these, reduce allocations, and not require serializing the types
* | Update test data which doesn't reflect expected usageSean Griffin2014-06-121-6/+6
|/ | | | | | Topics call `serialize :content`, which means that the values in the database should be YAML encoded, and we would only expect to receive YAML strings to `update_column` and `update_columns`.
* Merge pull request #15503 from sgrif/sg-json-hstore-storageYves Senn2014-06-061-2/+2
|\ | | | | Bring type casting behavior of hstore/json in line with serialized
| * Bring type casting behavior of hstore/json in line with serializedSean Griffin2014-06-041-2/+2
| | | | | | | | | | `@raw_attributes` should not contain the type-cast, mutable version of the value.
* | Merge pull request #14971 from versioncontrol/#14785Yves Senn2014-06-061-0/+9
|\ \ | |/ |/| | | Baseclass becomes! subclass
| * Fix Baseclass becomes! subclass.Edo Balvers2014-05-131-0/+9
| |
* | docs, `instantiate` expects `String` keys. [Rafal Piekarski & Yves Senn]Yves Senn2014-05-201-0/+11
|/ | | | | Closes #15122 Closes #15107
* test, persist inherited class with different table name. Refs #14971.Yves Senn2014-05-071-0/+14
| | | | | This case prevents against regressions. The change was suggested in a recent PR but the all our tests passed.
* Move dup destroyed test to specific file that tests dup logicCarlos Antonio da Silva2014-05-021-9/+2
| | | | | Also change other related test to use existing record rather than creating new one.
* `@destroyed` should always be set to `false` when an object is duped.Kuldeep Aggarwal2014-04-191-0/+16
|
* Change usec to 0 on tests that compare secondsArthur Neves2014-03-121-3/+3
| | | | | Avoid rounding problems with `.usec` method rounding the seconds when the field doesn't persist the `.usec` piece.
* use the new clear_validators! api everywhere to reset validators in testsKuldeep Aggarwal2014-01-281-2/+2
|
* Copy changed_attributes across to newly become'd recordsJonathan del Strother2013-12-271-0/+14
| | | Without this, the original record's values won't get saved, since the partial insertions support (https://github.com/rails/rails/commit/144e8691cbfb8bba77f18cfe68d5e7fd48887f5e) checks for changed values and thinks there are none.
* Raising an error when nil or non-hash is passed to update_attributes.wangjohn2013-06-251-4/+11
|