aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/callbacks_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Refactor AS::Callbacks halt config and fix the documentationRoque Pinel2015-10-011-2/+2
| | | | | | | | | Move from `AS::Callbacks::CallbackChain.halt_and_display_warning_on_return_false` to `AS::Callbacks.halt_and_display_warning_on_return_false` base on [this discussion](https://github.com/rails/rails/pull/21218#discussion_r39354580) Fix the documentation broken by 0a120a818d413c64ff9867125f0b03788fc306f8
* Fix the AS::Callbacks terminator regression from 4.2.3Roque Pinel2015-09-221-12/+8
| | | | | | Rails 4.2.3 AS::Callbacks will not halt chain if `false` is returned. That is the behavior of specific callbacks like AR::Callbacks and AM::Callbacks.
* Raise ArgumentError if an unrecognised callback is skippedIain Beeston2015-04-031-7/+25
| | | | | | | | | | | | | | At present, if you skip a callback that hasn't been defined, activesupport callbacks silently does nothing. However, it's easy to mistype the name of a callback and mistakenly think that it's being skipped, when it is not. This problem even exists in the current test suite. CallbacksTest::SkipCallbacksTest#test_skip_person attempts to skip callbacks that were never set up. This PR changes `skip_callback` to raise an `ArgumentError` if the specified callback cannot be found.
* Add config to halt callback chain on return falseclaudiob2015-01-021-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This stems from [a comment](rails#17227 (comment)) by @dhh. In summary: * New Rails 5.0 apps will not accept `return false` as a way to halt callback chains, and will not display a deprecation warning. * Existing apps ported to Rails 5.0 will still accept `return false` as a way to halt callback chains, albeit with a deprecation warning. For this purpose, this commit introduces a Rails configuration option: ```ruby config.active_support.halt_callback_chains_on_return_false ``` For new Rails 5.0 apps, this option will be set to `false` by a new initializer `config/initializers/callback_terminator.rb`: ```ruby Rails.application.config.active_support.halt_callback_chains_on_return_false = false ``` For existing apps ported to Rails 5.0, the initializers above will not exist. Even running `rake rails:update` will not create this initializer. Since the default value of `halt_callback_chains_on_return_false` is set to `true`, these apps will still accept `return true` as a way to halt callback chains, displaying a deprecation warning. Developers will be able to switch to the new behavior (and stop the warning) by manually adding the line above to their `config/application.rb`. A gist with the suggested release notes to add to Rails 5.0 after this commit is available at https://gist.github.com/claudiob/614c59409fb7d11f2931
* Throw :abort halts default CallbackChainsclaudiob2015-01-021-5/+34
| | | | | | | | | | | | | | This commit changes arguments and default value of CallbackChain's :terminator option. After this commit, Chains of callbacks defined **without** an explicit `:terminator` option will be halted as soon as a `before_` callback throws `:abort`. Chains of callbacks defined **with** a `:terminator` option will maintain their existing behavior of halting as soon as a `before_` callback matches the terminator's expectation. For instance, ActiveModel's callbacks will still halt the chain when a `before_` callback returns `false`.
* Add test for `:skip_after_callbacks_if_terminated`claudiob2014-12-141-15/+33
| | | | | | | | | | `define_callbacks` from `ActiveSupport::Callbacks` accepts the `:skip_after_callbacks_if_terminated` option since #4866 but the option is not tested anywhere. This commit adds tests and fixes documentation for the option, making it clear that halting a callback chain only stops following `before_` and `around_` callbacks by default.
* Unused classes in AS testsAkira Matsuda2013-12-191-21/+0
|
* remove deprecation noticesAaron Patterson2013-05-151-16/+0
|
* deprecating string based terminatorsAaron Patterson2013-05-141-1/+1
|
* Merge branch 'master' into normalizecbAaron Patterson2013-05-141-1/+2
|\ | | | | | | | | | | * master: private callback methods should work Update mail to minimum version 2.5.4
| * private callback methods should workAaron Patterson2013-05-141-1/+2
| |
* | Merge branch 'master' into normalizecbAaron Patterson2013-05-131-0/+40
|\| | | | | | | | | * master: adding more callback type coverage
| * adding more callback type coverageAaron Patterson2013-05-131-0/+40
| |
* | pass the actual filter, not a stringAaron Patterson2013-05-131-1/+1
|/
* add tests for reset_calbacksAaron Patterson2013-05-131-0/+40
|
* add test for object conditional with scopeAaron Patterson2013-05-081-0/+19
|
* adding a class conditional testAaron Patterson2013-05-081-0/+12
|
* adding tests for lambdas as conditionsAaron Patterson2013-05-081-0/+40
|
* we need to indicate the type of callbackAaron Patterson2013-05-081-2/+2
|
* adding more tests around callback inconsistenciesAaron Patterson2013-05-081-5/+47
|
* refactor tests for more pointsAaron Patterson2013-05-081-4/+5
|
* adding test to demonstrate inconsistencies in the AS::Callbacks apiAaron Patterson2013-05-081-0/+41
|
* fix issue #10502, do not recompute method name for already-stringified ↵Sean Walbran2013-05-071-0/+22
| | | | object filter
* Fix typo in testVipul A M2013-05-021-1/+1
|
* Fixes skipping object callback filtersBen McRedmond2013-04-041-0/+17
| | | | | | | | | | | | | | | This allows you to skip callbacks that are defined by objects, e.g. for `ActionController`: skip_after_filter MySpecialFilter Previously this didn't work due to a bug in how Rails compared callbacks in `Callback#matches?`. When a callback is compiled, if it's an object filter (i.e. not a method, proc, etc.), `Callback` now defines a method on `@klass` that is derived from the class name rather than `@callback_id`. So, when `skip_callback` tries to find the appropriate callback to remove, `Callback` can regenerate the method name for the filter object and return the correct value for `Callback#matches?`.
* Prevent callback from being set twice.Dmitriy Kiriyenko2012-12-201-5/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you add one callack in two separate `set_callback` calls - it is only called once. When you do it in one `set_callback` call - it is called twice. This violates the principle of least astonishment for me. Duplicating callback is usually an error. There is a correct and obvious way to do anything without this "feature". If you want to do before_save :clear_balance, :calculate_tax, :clear_balance or whatever, you should better do before_save :carefully_calculate_tax def carefully_calculate_tax clear_balance calculate_tax clear_balance end And this even opens gates for some advanced refactorings, unlike the first approach. My assumptions are: - Principle of least astonishment is violated, when callbacks are either prevented from duplication, or not. - Duplicating callbacks is usually an error. When it is intentional - it's a smell of a bad design and can be approached without abusing this "feature". My suggestion is: do not allow duplicating callbacks in one callback call, like it is not allowed in separate callbacks call.
* Cleanup trailing whitespacesdfens2012-10-121-1/+1
|
* AS::Callbacks#run_callbacks remove key argumentFrancesco Rodriguez2012-05-101-3/+3
|
* AS::Callbacks: deprecate rescuable optionBogdan Gusiev2012-02-221-8/+1
|
* AS::Callbacks: rip out per_key option.Bogdan Gusiev2012-02-041-7/+23
|
* Fix GH #4344. A defined callback in extended module is called too.kennyj2012-01-241-0/+56
|
* removing unnecessary requiresAaron Patterson2012-01-061-1/+0
|
* use AS::TestCase as the base classAaron Patterson2012-01-051-12/+12
|
* Log 'Filter chain halted as CALLBACKNAME rendered or redirected' every time ↵José Valim2011-11-301-1/+11
| | | | a before callback halts.
* Removal require again from tests.Arun Agrawal2011-05-221-1/+0
|
* Add better test scenario for around callback return resultsAaron Pfeifer2011-03-081-0/+10
|
* Allow access to a callback event's return result from around callbacksAaron Pfeifer2011-03-081-0/+24
|
* Use run_callbacks; the generated _run_<name>_callbacks method is not a ↵John Firebaugh2011-01-311-1/+1
| | | | | | public interface. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* while defining callbacks option :rescuable => trueNeeraj Singh2010-12-291-1/+30
| | | | | | | can be passed. There were no tests for this case. This patch adds a test for :rescuable => true option.
* Test for after_create callback order in ActiveSupport [#5703 state:resolved]Neeraj Singh2010-09-271-0/+23
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* If certain sections of skip_callback method are commented out thenNeeraj Singh2010-08-311-0/+27
| | | | | | | no test was failing. Tests have been added to ensure that commenting out the code within if loop would cause test failure. Signed-off-by: José Valim <jose.valim@gmail.com>
* Final iteration of use better testing methodsNeeraj Singh2010-05-191-1/+1
| | | | | | [#4652 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Added missing requires abstract_unit and activesupport to the loadpath of ↵Santiago Pastorino and Sebastian Martinez2010-03-181-1/+1
| | | | | | ts_isolated [#4215 state:committed] Signed-off-by: wycats <wycats@gmail.com>
* Make sure AS test env doesn't have duplicate libs in load pathJoshua Peek2010-02-151-1/+0
|
* deOMGifying Railties, Active Support, and Action PackMikel Lindsaar2010-01-311-4/+4
|
* Callbacks, DeprecatedCallbacks = NewCallbacks, CallbacksJoshua Peek2009-10-121-146/+486
|
* Remove core ext dependency from testJeremy Kemper2009-03-241-4/+4
|
* Allow multiple conditions for callbacks [#1627 state:resolved]Joshua Peek2008-12-281-1/+41
|
* Simplified and renamed CallbackChain union method to replace_or_append!Joshua Peek2008-08-211-4/+4
|
* Tidy up ActiveSupport::Callbacks::CallbackChain instance API.Joshua Peek2008-04-171-0/+31
|