diff options
author | Nicholas Jakobsen <nicholas.jakobsen@gmail.com> | 2013-08-07 12:43:22 -0700 |
---|---|---|
committer | Nicholas Jakobsen <nicholas.jakobsen@gmail.com> | 2013-08-10 09:13:20 -0700 |
commit | 55cbb85fb7b7f4eaaa681e2a74cc8aca225097b7 (patch) | |
tree | 525a17d52ba95935cfcf852a2ed7153dd62ce264 /actionpack/test | |
parent | 806bc2add8a0807ca45fb0945856bec89a321fc8 (diff) | |
download | rails-55cbb85fb7b7f4eaaa681e2a74cc8aca225097b7.tar.gz rails-55cbb85fb7b7f4eaaa681e2a74cc8aca225097b7.tar.bz2 rails-55cbb85fb7b7f4eaaa681e2a74cc8aca225097b7.zip |
Execute conditional procs on controller filters only for current action.
:only and :except options for controller filters are now added before
:if and :unless. This prevents running :if and :unless procs when not
on the specified. Closes #11786.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 4c82625e8e..3b5d7ef446 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -208,6 +208,10 @@ class FilterTest < ActionController::TestCase before_filter(ConditionalClassFilter, :ensure_login, Proc.new {|c| c.instance_variable_set(:"@ran_proc_filter1", true)}, :except => :show_without_filter) { |c| c.instance_variable_set(:"@ran_proc_filter2", true)} end + class OnlyConditionalOptionsFilter < ConditionalFilterController + before_filter :ensure_login, :only => :index, :if => Proc.new {|c| c.instance_variable_set(:"@ran_conditional_index_proc", true) } + end + class ConditionalOptionsFilter < ConditionalFilterController before_filter :ensure_login, :if => Proc.new { |c| true } before_filter :clean_up_tmp, :if => Proc.new { |c| false } @@ -649,6 +653,11 @@ class FilterTest < ActionController::TestCase assert !assigns["ran_class_filter"] end + def test_running_only_condition_and_conditional_options + test_process(OnlyConditionalOptionsFilter, "show") + assert_not assigns["ran_conditional_index_proc"] + end + def test_running_before_and_after_condition_filters test_process(BeforeAndAfterConditionController) assert_equal %w( ensure_login clean_up_tmp), assigns["ran_filter"] |