Commit Graph

46 Commits

Author SHA1 Message Date
Akira Matsuda
4e68765cf6 Unused classes in AS tests 2013-12-19 16:30:16 +09:00
Aaron Patterson
1012c3e969 remove deprecation notices 2013-05-15 09:40:58 -07:00
Aaron Patterson
ba55276434 deprecating string based terminators 2013-05-14 16:03:09 -07:00
Aaron Patterson
9dcecbb080 Merge branch 'master' into normalizecb
* master:
  private callback methods should work
  Update mail to minimum version 2.5.4
2013-05-14 10:48:43 -07:00
Aaron Patterson
f93da579ce private callback methods should work 2013-05-14 10:48:34 -07:00
Aaron Patterson
edf116a91b Merge branch 'master' into normalizecb
* master:
  adding more callback type coverage
2013-05-13 15:42:01 -07:00
Aaron Patterson
099e827f57 adding more callback type coverage 2013-05-13 15:40:39 -07:00
Aaron Patterson
19b9f7ba33 pass the actual filter, not a string 2013-05-13 12:05:22 -07:00
Aaron Patterson
37ca5b0966 add tests for reset_calbacks 2013-05-13 11:44:15 -07:00
Aaron Patterson
1d6ac22462 add test for object conditional with scope 2013-05-08 15:51:45 -07:00
Aaron Patterson
7d89a9f00a adding a class conditional test 2013-05-08 15:23:39 -07:00
Aaron Patterson
ece76f3840 adding tests for lambdas as conditions 2013-05-08 14:35:43 -07:00
Aaron Patterson
1ff1236b07 we need to indicate the type of callback 2013-05-08 11:37:26 -07:00
Aaron Patterson
5d2c3a14a3 adding more tests around callback inconsistencies 2013-05-08 10:31:02 -07:00
Aaron Patterson
d32b329b7e refactor tests for more points 2013-05-08 10:08:37 -07:00
Aaron Patterson
3df92d981b adding test to demonstrate inconsistencies in the AS::Callbacks api 2013-05-08 10:07:19 -07:00
Sean Walbran
9003a422f2 fix issue #10502, do not recompute method name for already-stringified object filter 2013-05-07 13:22:52 -05:00
Vipul A M
469befa7ef Fix typo in test 2013-05-02 09:42:57 +05:30
Ben McRedmond
8e1d3cd490 Fixes skipping object callback filters
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?`.
2013-04-04 16:11:13 -07:00
Dmitriy Kiriyenko
4a9644a0d9 Prevent callback from being set twice.
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.
2012-12-20 11:06:45 +02:00
dfens
ab9140ff02 Cleanup trailing whitespaces 2012-10-12 09:56:39 +02:00
Francesco Rodriguez
c1ce4144d1 AS::Callbacks#run_callbacks remove key argument 2012-05-10 02:21:03 -05:00
Bogdan Gusiev
10bac29b33 AS::Callbacks: deprecate rescuable option 2012-02-22 17:43:13 +02:00
Bogdan Gusiev
4f53091dd1 AS::Callbacks: rip out per_key option. 2012-02-04 13:31:00 +02:00
kennyj
5e59d75536 Fix GH #4344. A defined callback in extended module is called too. 2012-01-24 17:36:30 +09:00
Aaron Patterson
056b8386d0 removing unnecessary requires 2012-01-06 14:43:04 -08:00
Aaron Patterson
b8d8c50785 use AS::TestCase as the base class 2012-01-05 17:12:46 -08:00
José Valim
38ab982cff Log 'Filter chain halted as CALLBACKNAME rendered or redirected' every time a before callback halts. 2011-11-30 09:53:09 +01:00
Arun Agrawal
40e33771e6 Removal require again from tests. 2011-05-22 00:55:12 +05:30
Aaron Pfeifer
9798ee2619 Add better test scenario for around callback return results 2011-03-08 15:01:06 +08:00
Aaron Pfeifer
df615f127e Allow access to a callback event's return result from around callbacks 2011-03-08 15:01:05 +08:00
John Firebaugh
57bc25c5f8 Use run_callbacks; the generated _run_<name>_callbacks method is not a public interface.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-31 19:45:53 -02:00
Neeraj Singh
27d0d4fffd while defining callbacks option :rescuable => true
can be passed. There were no tests for this case.

This patch adds a test for :rescuable => true
option.
2010-12-29 05:32:23 +08:00
Neeraj Singh
bfc986811c Test for after_create callback order in ActiveSupport [#5703 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 23:12:10 +02:00
Neeraj Singh
67a2b5ec1b If certain sections of skip_callback method are commented out then
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>
2010-08-31 17:45:06 +02:00
Neeraj Singh
39a246f545 Final iteration of use better testing methods
[#4652 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 21:31:51 +02:00
Santiago Pastorino and Sebastian Martinez
1e2caa5d52 Added missing requires abstract_unit and activesupport to the loadpath of ts_isolated [#4215 state:committed]
Signed-off-by: wycats <wycats@gmail.com>
2010-03-18 17:50:28 -07:00
Joshua Peek
4419497e40 Make sure AS test env doesn't have duplicate libs in load path 2010-02-15 10:38:39 -06:00
Mikel Lindsaar
2ebea1c02d deOMGifying Railties, Active Support, and Action Pack 2010-01-31 09:46:30 -08:00
Joshua Peek
21e7b84621 Callbacks, DeprecatedCallbacks = NewCallbacks, Callbacks 2009-10-12 22:15:43 -05:00
Jeremy Kemper
af4c2375a2 Remove core ext dependency from test 2009-03-24 23:02:23 -07:00
Joshua Peek
1e45818a62 Allow multiple conditions for callbacks [#1627 state:resolved] 2008-12-28 15:07:17 -06:00
Joshua Peek
6be8251ec8 Simplified and renamed CallbackChain union method to replace_or_append! 2008-08-21 00:51:06 -05:00
Joshua Peek
cf04e62127 Tidy up ActiveSupport::Callbacks::CallbackChain instance API. 2008-04-17 23:30:01 -05:00
Jeremy Kemper
856a4dcf12 Refactor filters to use Active Support callbacks. Closes #11235.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9055 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-18 17:56:05 +00:00
Jeremy Kemper
aae37bb4f7 Extract ActiveSupport::Callbacks from Active Record, test case setup and teardown, and ActionController::Dispatcher. Closes #10727.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8664 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-19 02:44:45 +00:00