diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-08 18:08:02 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-08 18:08:02 -0200 |
commit | b8e83ce1c57a064cb9506d5ba16cebcf84e0a1e0 (patch) | |
tree | 7b42b37a51624001d2f0233e9df186c43e2ca082 /actionpack/test | |
parent | 9af5f33a1629f16c56137e2b9903bc977455075f (diff) | |
parent | 9a25603d0aa2d3de35ce59fcfe8b90cdfddb78cf (diff) | |
download | rails-b8e83ce1c57a064cb9506d5ba16cebcf84e0a1e0.tar.gz rails-b8e83ce1c57a064cb9506d5ba16cebcf84e0a1e0.tar.bz2 rails-b8e83ce1c57a064cb9506d5ba16cebcf84e0a1e0.zip |
Merge pull request #18404 from claudiob/rebase-14549
Add test case and documentation for skip_before_filter.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 2e08a6af9f..b9fb6be4e3 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -225,6 +225,30 @@ class FilterTest < ActionController::TestCase skip_before_action :clean_up_tmp, if: -> { true } end + class SkipFilterUsingOnlyAndIf < 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 SkipFilterUsingIfAndExcept < ConditionalFilterController + before_action :clean_up_tmp + before_action :ensure_login + + skip_before_action :ensure_login, if: -> { false }, except: :login + skip_before_action :clean_up_tmp, if: -> { true }, except: :login + + def login + render text: 'ok' + end + end + class ClassController < ConditionalFilterController before_action ConditionalClassFilter end @@ -596,6 +620,16 @@ class FilterTest < ActionController::TestCase assert_equal %w( ensure_login ), assigns["ran_filter"] end + def test_if_is_ignored_when_used_with_only + test_process(SkipFilterUsingOnlyAndIf, 'login') + assert_nil assigns['ran_filter'] + end + + def test_except_is_ignored_when_used_with_if + test_process(SkipFilterUsingIfAndExcept, 'login') + assert_equal %w(ensure_login), assigns["ran_filter"] + end + def test_skipping_class_actions test_process(ClassController) assert_equal true, assigns["ran_class_action"] |