aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/callbacks_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-211-1/+1
| | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-2/+2
|
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-2/+2
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Rails 6 requires Ruby 2.3+Jeremy Daer2018-02-171-2/+1
|
* Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-1/+1
| | | | Follow up of #31390.
* Remove deprecated `:if` and `:unless` string filter for callbacksRafael Mendonça França2017-10-231-15/+7
|
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* 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
|
* Remove deprecated behavior that halts callbacks when the return is falseRafael Mendonça França2017-02-071-28/+2
|
* Deprecate passing string to `:if` and `:unless` conditional options on ↵Ryuta Kamizono2017-02-041-4/+17
| | | | `set_callback` and `skip_callback`
* Remove deprecated passing string to define callbackRyuta Kamizono2017-02-041-31/+5
| | | | And raise `ArgumentError` when passing string to define callback.
* Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-1/+1
| | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-3/+3
|
* Support double-yield inside an around callbackMatthew Draper2016-12-151-15/+68
| | | | | | | It's questionable whether this is a good thing -- it forces any later/ inner callback to handle multiple invocations, along with the actual wrapped action. But it worked prior to 871ca21f6a1d65c0ec78cb5a9641411e2210460b, so we shouldn't break it unintentionally.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-3/+3
|
* Tighten the backtrace pollution from passing through callbacksMatthew Draper2016-09-301-1/+72
| | | | | | | | | | Callbacks are everywhere, so it's better if we can avoid making a mess of the backtrace just because we've passed through a callback hook. I'm making no effort to the before/after invocations: those only affect backtraces while they're running. The calls that matter are the ones that remain on the call stack after run_callbacks yields: around callbacks, and internal book-keeping around the before/afters.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-9/+9
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-4/+0
|
* applies remaining conventions across the projectXavier Noria2016-08-061-2/+0
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-39/+39
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-6/+6
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Deprecate passing string to define callback.yui-knk2015-12-161-4/+14
|
* 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?`.