Rick Olson
d5bd679340
Add missing tests ensuring callbacks work with class inheritance. Closes #7339 [sandofsky]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6026 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-01-24 03:04:48 +00:00
Jamis Buck
53737eadd6
add a failing test so we can make it happy again
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5225 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-10-04 15:38:59 +00:00
David Heinemeier Hansson
4c7555aef7
Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's ( closes #1861 , #2477 ) [DHH]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3707 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-28 20:37:21 +00:00
Jeremy Kemper
e19bd169fa
Association validation does not belong in a before_save callback: move it into a validation method. Restores the expected model.valid? == model.save. Add tests for cancelling save by returning false from a before_save callback. Remove assumption that before_destroy's return value indicates whether the record was destroyed.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2434 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-02 02:00:50 +00:00
Scott Barron
83b390bcfc
Returning false in before_destroy should cancel action. Closes #1829 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2381 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-28 00:09:50 +00:00
Jamis Buck
361be5a7dd
Removed the AR::Recursion module--it broke more code than it fixed
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1470 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-21 12:58:27 +00:00
Jamis Buck
e0537acaeb
Added ActiveRecord::Recursion to guard against recursive calls to #save
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1411 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-13 10:52:53 +00:00
Jamis Buck
2c0fa32088
Do not use instantiated fixtures (in general) in tests. Also, support the use of transactional fixtures by setting the AR_TX_FIXTURES environment variable to "yes".
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1399 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-10 14:58:02 +00:00
David Heinemeier Hansson
7edb10fe68
Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@898 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-03-14 00:04:14 +00:00
David Heinemeier Hansson
823554eafe
Added support for associating unsaved objects #402 [Tim Bates]
...
Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates]
Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates]
Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates]
Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@417 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-01-15 17:45:16 +00:00
David Heinemeier Hansson
7ad83b8df2
Added block-style for callbacks #332 [bitsweat]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@296 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-01-01 16:14:15 +00:00