class YieldingAroundFiltersTest

Public Instance Methods

test_action_order_with_all_action_types() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 1014
def test_action_order_with_all_action_types
  test_process(ControllerWithAllTypesOfFilters, "no_raise")
  assert_equal "before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)", @controller.instance_variable_get(:@ran_filter).join(" ")
end
test_action_order_with_skip_action_method() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 1019
def test_action_order_with_skip_action_method
  test_process(ControllerWithTwoLessFilters, "no_raise")
  assert_equal "before around (before yield) around (after yield)", @controller.instance_variable_get(:@ran_filter).join(" ")
end
test_base() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 964
def test_base
  controller = PostsController
  assert_nothing_raised { test_process(controller, "no_raise") }
  assert_nothing_raised { test_process(controller, "raises_before") }
  assert_nothing_raised { test_process(controller, "raises_after") }
  assert_nothing_raised { test_process(controller, "no_action") }
end
test_first_action_in_multiple_before_action_chain_halts() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 1024
def test_first_action_in_multiple_before_action_chain_halts
  controller = ::FilterTest::TestMultipleFiltersController.new
  response = test_process(controller, "fail_1")
  assert_equal "", response.body
  assert_equal 1, controller.instance_variable_get(:@try)
end
test_last_action_in_multiple_before_action_chain_halts() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 1038
def test_last_action_in_multiple_before_action_chain_halts
  controller = ::FilterTest::TestMultipleFiltersController.new
  response = test_process(controller, "fail_3")
  assert_equal "", response.body
  assert_equal 3, controller.instance_variable_get(:@try)
end
test_nested_actions() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 998
def test_nested_actions
  controller = ControllerWithNestedFilters
  assert_nothing_raised do
    begin
      test_process(controller, "raises_both")
    rescue Before, After
    end
  end
  assert_raise Before do
    begin
      test_process(controller, "raises_both")
    rescue After
    end
  end
end
test_second_action_in_multiple_before_action_chain_halts() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 1031
def test_second_action_in_multiple_before_action_chain_halts
  controller = ::FilterTest::TestMultipleFiltersController.new
  response = test_process(controller, "fail_2")
  assert_equal "", response.body
  assert_equal 2, controller.instance_variable_get(:@try)
end
test_with_class() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 980
def test_with_class
  controller = ControllerWithFilterClass
  assert_nothing_raised { test_process(controller, "no_raise") }
  assert_raise(After) { test_process(controller, "raises_after") }
end
test_with_instance() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 986
def test_with_instance
  controller = ControllerWithFilterInstance
  assert_nothing_raised { test_process(controller, "no_raise") }
  assert_raise(After) { test_process(controller, "raises_after") }
end
test_with_proc() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 992
def test_with_proc
  test_process(ControllerWithProcFilter, "no_raise")
  assert @controller.instance_variable_get(:@before)
  assert @controller.instance_variable_get(:@after)
end
test_with_symbol() click to toggle source
# File actionpack/test/controller/filters_test.rb, line 972
def test_with_symbol
  controller = ControllerWithSymbolAsFilter
  assert_nothing_raised { test_process(controller, "no_raise") }
  assert_raise(Before) { test_process(controller, "raises_before") }
  assert_raise(After) { test_process(controller, "raises_after") }
  assert_nothing_raised { test_process(controller, "no_raise") }
end

Private Instance Methods

test_process(controller, action = "show") click to toggle source
# File actionpack/test/controller/filters_test.rb, line 1046
def test_process(controller, action = "show")
  @controller = controller.is_a?(Class) ? controller.new : controller
  process(action)
end