aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/filters_test.rb
diff options
context:
space:
mode:
authorLauro Caetano <laurocaetano1@gmail.com>2014-04-01 14:40:04 -0300
committerclaudiob <claudiob@gmail.com>2015-01-08 09:13:45 -0800
commitae9f803c5dfbc06701de87b804250b591fac2d20 (patch)
tree7afb443641ba7a8e6fa3ce6310d60ccff83fb63b /actionpack/test/controller/filters_test.rb
parent0e8c7ff7f7988e9b0bfae91ca4f27b200f8f6541 (diff)
downloadrails-ae9f803c5dfbc06701de87b804250b591fac2d20.tar.gz
rails-ae9f803c5dfbc06701de87b804250b591fac2d20.tar.bz2
rails-ae9f803c5dfbc06701de87b804250b591fac2d20.zip
Add test case and documentation for skip_before_filter.
Test case for using skip_before_filter with the options :only and :if both present. In this case, the :if option will be ignored and :only will be executed. Closes #14549 (the commit was cherry-picked from there).
Diffstat (limited to 'actionpack/test/controller/filters_test.rb')
-rw-r--r--actionpack/test/controller/filters_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index 2e08a6af9f..c5484e4b71 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -225,6 +225,18 @@ class FilterTest < ActionController::TestCase
skip_before_action :clean_up_tmp, if: -> { true }
end
+ class SkipFilterUsingOnlyAndConditional < ConditionalFilterController
+ before_action :clean_up_tmp
+ before_action :ensure_login
+
+ skip_before_action :ensure_login, only: :login, if: -> { false }
+ skip_before_action :clean_up_tmp, only: :login, if: -> { true }
+
+ def login
+ render text: 'ok'
+ end
+ end
+
class ClassController < ConditionalFilterController
before_action ConditionalClassFilter
end
@@ -596,6 +608,11 @@ class FilterTest < ActionController::TestCase
assert_equal %w( ensure_login ), assigns["ran_filter"]
end
+ def test_if_is_ignored_when_used_with_only
+ test_process(SkipFilterUsingOnlyAndConditional, 'login')
+ assert_nil assigns['ran_filter']
+ end
+
def test_skipping_class_actions
test_process(ClassController)
assert_equal true, assigns["ran_class_action"]