aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/transactions_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-5/+5
|
* improve error message when include assertions failMichael Grosser2016-09-161-2/+2
| | | | | | 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
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-3/+4
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-8/+8
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-19/+19
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-44/+44
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Allow add_to_transaction with null transactionEmanuel Evans2015-12-281-0/+5
| | | | Fixes https://github.com/rails/rails/issues/22819
* Removed mocha from Active Record Part 2Ronak Jangir2015-09-161-6/+10
|
* Fix state being carried over from previous transactionRoque Pinel2015-07-201-0/+7
| | | | | | | | | | | | | | | This clears the transaction record state when the transaction finishes with a `:committed` status. Considering the following example where `name` is a required attribute. Before we had `new_record?` returning `true` for a persisted record: ```ruby author = Author.create! name: 'foo' author.name = nil author.save # => false author.new_record? # => true ```
* Silence deprecation warning from force reloadPrem Sichanugrist2015-07-161-2/+2
| | | | | | | | | | | | We deprecate the support for passing an argument to force reload in 6eae366d0d2e5d5211eeaf955f56bd1dc6836758. That led to several deprecation warning when running Active Record test suite. This commit silence the warnings by properly calling `#reload` on the association proxy or on the association object instead. However, there are several places that `ActiveSupport::Deprecation.silence` are used as those tests actually tests the force reload functionality and will be removed once `master` is targeted next minor release (5.1).
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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 transaction state for unsynced records when entering transactionbrainopia2015-03-041-0/+9
|
* Fix rollback of frozen recordsbrainopia2015-03-041-0/+9
|
* prefer `drop_table if_exists: true` over raw SQL.Yves Senn2015-02-181-1/+1
| | | | | | | /cc @yahonda This makes it easier for third party adapters to run our tests, even if that database does not support IF EXISTS.
* Whitespace fixes from #18349Sean Griffin2015-01-051-2/+1
|
* Merge pull request #18349 from jdelStrother/primarykeylessSean Griffin2015-01-051-0/+22
|\ | | | | Fix rollback of primarykey-less tables
| * Fix rollback of primarykey-less tablesJonathan del Strother2015-01-051-0/+22
| | | | | | If you have a table without a primary key, and an `after_commit` callback on that table (ie `has_transactional_callbacks?` returns true), then trying to rollback a transaction involving that record would result in “ActiveModel::MissingAttributeError: can't write unknown attribute ``”
* | can't kill thread with in-memory db. fixes `rake test:sqlite3_mem`.Yves Senn2015-01-051-0/+2
| |
* | Remove Thread hack for Ruby 1.9claudiob2015-01-041-23/+18
|/ | | | | | | | The hack so skip a Thread test for Ruby 1.9 can be removed now that Rails requires Ruby >= 2.0. Conflicts: activerecord/test/cases/transactions_test.rb
* Deprecate `false` as the way to halt AR callbacksclaudiob2015-01-021-1/+11
| | | | | | | | | | Before this commit, returning `false` in an ActiveRecord `before_` callback such as `before_create` would halt the callback chain. After this commit, the behavior is deprecated: will still work until the next release of Rails but will also display a deprecation warning. The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
* Merge branch 'brainopia-remember_frozen_state_in_transaction'Sean Griffin2014-12-261-0/+15
|\
| * Propagate frozen state during transaction changesbrainopia2014-12-261-0/+14
|/
* skip test to get `sqlite3_mem` suite passing.Yves Senn2014-12-031-1/+1
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-3/+3
|
* Build fix when running in isolationArun Agrawal2014-11-141-0/+1
| | | | | `Computer` class needs to be require See #17217 for more details
* Roll back open transactions when the running thread is killed.Chris Hanks2014-08-221-0/+31
|
* Use *_transaction methods in TransactionManagerArthur Neves2014-08-151-0/+24
| | | | | | Use `commit_transaction`/`rollback_transaction` on `within_new_transaction` method, so they make sure they `pop` the transaction from the stack before calling the methods `commit`/`rollback`.
* Cleanup Transaction inheritance.Arthur Neves2014-08-051-2/+2
| | | | | | | | | Transaction class doesnt need to encapsulate the transaction state using inheritance. This removes all Transaction subclasses, and let the Transaction object controls different actions based on its own state. Basically the only actions would behave differently are `being`,`commit`,`rollback` as they could act in a savepoint or in a real transaction.
* Remove being/number methods from transaction classArthur Neves2014-07-311-2/+2
|
* savepoint_name should return nil for non-savepoint transactionsArthur Neves2014-07-281-0/+20
| | | | Also add test to assets the savepoint name
* Clear transaction state if callback raise rollbackArthur Neves2014-05-151-0/+13
|
* Reverts "Fix bugs with changed attributes tracking when transaction gets ↵Arthur Neves2014-05-091-42/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | rollback" We are reverting these commits, because there are other caveats related to dirty attributes not being restored when a transaction is rollback. For instance, nested transactions cannot proper restore the dirty attributes state after a rollback. At the moment, the dirty attributes are scoped by the transaction. When we call `.save` on a record, the dirty attributes will be reset even if the transaction gets rollback. [related #13166] [related #15018] [related #15016] [closes #15019] This reverts commits * bab48f0a3d53a08bc23ea0887219e8deb963c3d9 * b0fa7cf3ff8432cc2eef3682b34763b7f8c93cc8. * 73fb39b6faa9de593ae75ad4e3b8e065ea0e53af * 37c238927fbed059de3f26a90d8923fb377568a5. * 8d8d4f1560264cd1c74364d67fa0501f6dd2c4fa Revert "Merge pull request #13166 from bogdan/transaction-magic"
* Keep track of dirty attrs after after rollback.Arthur Neves2014-05-071-18/+4
| | | | [related #13166]
* Merge pull request #13166 from bogdan/transaction-magicRafael Mendonça França2014-05-071-0/+56
|\ | | | | | | [Regression 3.2 -> 4.0] Fix bugs with changed attributes tracking when transaction gets rollback
| * Fix bugs with changed attributes tracking when transaction gets rollbackBogdan Gusiev2013-12-041-0/+56
| |
* | AR .persisted? throws SystemStackError for an unsaved model with achrisfinne2014-03-271-0/+6
| | | | | | | | custom primary_key that didn't save due to validation error
* | Restore ActiveRecord states after a rollback for models w/o callbacksGodfrey Chan2014-01-181-0/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression (#13744) that was caused by 67d8bb9. In 67d8bb9, we introduced lazy rollback for records, such that the record's internal states and attributes are not restored immediately after a transaction rollback, but deferred until they are first accessed. This optimization is only performed when the model does not have any transactional callbacks (e.g. `after_commit` and `after_create`). Unfortunately, the models used to test the affected codepaths all comes with some sort of transactional callbacks. Therefore this codepath remains largely untested until now and as a result there are a few issues in the implementation that remains hidden until now. First, the `sync_with_transaction_state` (or more accurately, `update_attributes_from_transaction_state`) would perform the synchronization prematurely before a transaction is finalized (i.e. comitted or rolled back). As a result, when the actuall rollback happens, the record will incorrectly assumes that its internal states match the transaction state, and neglect to perform the restore. Second, `update_attributes_from_transaction_state` calls `committed!` in some cases. This in turns checks for the `destroyed?` state which also requires synchronization with the transaction stae, which causes an infnite recurrsion. This fix works by deferring the synchronization until the transaction has been finalized (addressing the first point), and also unrolled the `committed!` and `rolledback!` logic in-place (addressing the second point). It should be noted that the primary purpose of the `committed!` and `rolledback!` methods are to trigger the relevant transactional callbacks. Since this code path is only entered when there are no transactional callbacks on the model, this shouldn't be necessary. By unrolling the method calls, the intention here (to restore the states when necessary) becomes more clear.
* Ensure that a column added in a test is being removed after allAkira Matsuda2013-11-131-0/+7
|
* Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-14/+14
| | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.
* Assert presence of "frozen" in error message, not the full MRI message.Federico Ravasio2013-10-081-1/+3
| | | | | | | | | | Related to all the other issues regarding message independent assertions to make Rails compatible with other Ruby implementations other than MRI. The best way here would be to have a specific error raised when modifying frozen objects, like FrozenObjectError or something. But since Ruby doesn't provide such a thing, we must limit the assertion to the lowest common denominator, which is word "frozen".
* change the savepoint interface to allow passing the name.Yves Senn2013-09-301-0/+30
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-08-171-5/+0
|\ | | | | | | | | | | | | | | Conflicts: actionview/README.rdoc activerecord/lib/active_record/migration.rb guides/source/development_dependencies_install.md guides/source/getting_started.md
| * Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-5/+0
| | | | | | | | | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* | Fix indentationRafael Mendonça França2013-08-061-3/+2
| |
* | asakusa.rb hack night!Aaron Patterson + Akira Matsuda2013-08-061-0/+3
|/ | | | Fix in-memory tests
* fix order dependent testNeeraj Singh2013-07-281-0/+5
| | | | | `ReflectionTest` uses column information in tests and those tests break if tests are run in random order.
* #4566: Remove extra decrement of transaction levelPaul Nikitochkin2013-07-141-0/+14
| | | | | | | | | | | | `rollback_active_record_state!` tries to restore model state on `Exception` by invoking `restore_transaction_record_state` it decrement deep level by `1`. After restoring it ensure that states to be cleared and level decremented by invoking `clear_transaction_record_state`, which cause the bug: because state already reduced in `restore_transaction_record_state`. Removed double derement of transaction level and removed duplicated code which clear transaction state for top level.
* close our connection when we are doneAaron Patterson2013-07-081-13/+11
|
* Remove deprecated `transaction_joinable=`Arun Agrawal2013-07-031-9/+0
| | | | | in favor of `begin_transaction` with `:joinable` option.