mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove misleading test: around_action return false
When an `around_action` does not `yield`, then the corresponding action is
*never* executed and the `after_` actions are *never* invoked.
The value returned by the `around_action` does not have any impact on this:
an `around_action` can "return" `true`, `false`, or `"pizza"`, but as long
as `yield` is not invoked, the corresponding action and after callbacks are
not executed.
The test suite for `ActionController::Callbacks` currently includes separate
tests to distinguish the cases in which a non-yielding `around_actions` returns
`true` or `false`.
In my opinion, having such tests is misleading, giving the impression that the
returned value might have some sort of impact, while it does not. At least
that's the impression I got when I read those tests.
For completeness, the tests were introduced 7 years ago by @NZKoz in e80fabb
.
This commit is contained in:
parent
1b9dca54fd
commit
8dfa585db2
1 changed files with 1 additions and 19 deletions
|
@ -504,7 +504,6 @@ class FilterTest < ActionController::TestCase
|
|||
|
||||
def non_yielding_action
|
||||
@filters << "it didn't yield"
|
||||
@filter_return_value
|
||||
end
|
||||
|
||||
def action_three
|
||||
|
@ -528,32 +527,15 @@ class FilterTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_non_yielding_around_actions_not_returning_false_do_not_raise
|
||||
def test_non_yielding_around_actions_do_not_raise
|
||||
controller = NonYieldingAroundFilterController.new
|
||||
controller.instance_variable_set "@filter_return_value", true
|
||||
assert_nothing_raised do
|
||||
test_process(controller, "index")
|
||||
end
|
||||
end
|
||||
|
||||
def test_non_yielding_around_actions_returning_false_do_not_raise
|
||||
controller = NonYieldingAroundFilterController.new
|
||||
controller.instance_variable_set "@filter_return_value", false
|
||||
assert_nothing_raised do
|
||||
test_process(controller, "index")
|
||||
end
|
||||
end
|
||||
|
||||
def test_after_actions_are_not_run_if_around_action_returns_false
|
||||
controller = NonYieldingAroundFilterController.new
|
||||
controller.instance_variable_set "@filter_return_value", false
|
||||
test_process(controller, "index")
|
||||
assert_equal ["filter_one", "it didn't yield"], controller.assigns['filters']
|
||||
end
|
||||
|
||||
def test_after_actions_are_not_run_if_around_action_does_not_yield
|
||||
controller = NonYieldingAroundFilterController.new
|
||||
controller.instance_variable_set "@filter_return_value", true
|
||||
test_process(controller, "index")
|
||||
assert_equal ["filter_one", "it didn't yield"], controller.assigns['filters']
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue