Chris@0: # Tests in this file ensure that: Chris@0: # Chris@0: # * plugin controller actions are found Chris@0: # * actions defined in application controllers take precedence over those in plugins Chris@0: # * actions in controllers in subsequently loaded plugins take precendence over those in previously loaded plugins Chris@0: # * this works for actions in namespaced controllers accordingly Chris@0: Chris@0: require File.dirname(__FILE__) + '/../test_helper' Chris@0: Chris@0: class ControllerLoadingTest < ActionController::TestCase Chris@0: def setup Chris@0: @request = ActionController::TestRequest.new Chris@0: @response = ActionController::TestResponse.new Chris@0: end Chris@0: Chris@0: # plugin controller actions should be found Chris@0: Chris@0: def test_WITH_an_action_defined_only_in_a_plugin_IT_should_use_this_action Chris@0: get_action_on_controller :an_action, :alpha_plugin Chris@0: assert_response_body 'rendered in AlphaPluginController#an_action' Chris@0: end Chris@0: Chris@0: def test_WITH_an_action_defined_only_in_a_namespaced_plugin_controller_IT_should_use_this_action Chris@0: get_action_on_controller :an_action, :alpha_plugin, :namespace Chris@0: assert_response_body 'rendered in Namespace::AlphaPluginController#an_action' Chris@0: end Chris@0: Chris@0: # app takes precedence over plugins Chris@0: Chris@0: def test_WITH_an_action_defined_in_both_app_and_plugin_IT_should_use_the_one_in_app Chris@0: get_action_on_controller :an_action, :app_and_plugin Chris@0: assert_response_body 'rendered in AppAndPluginController#an_action (from app)' Chris@0: end Chris@0: Chris@0: def test_WITH_an_action_defined_in_namespaced_controllers_in_both_app_and_plugin_IT_should_use_the_one_in_app Chris@0: get_action_on_controller :an_action, :app_and_plugin, :namespace Chris@0: assert_response_body 'rendered in Namespace::AppAndPluginController#an_action (from app)' Chris@0: end Chris@0: Chris@0: # subsequently loaded plugins take precendence over previously loaded plugins Chris@0: Chris@0: def test_WITH_an_action_defined_in_two_plugin_controllers_IT_should_use_the_latter_of_both Chris@0: get_action_on_controller :an_action, :shared_plugin Chris@0: assert_response_body 'rendered in SharedPluginController#an_action (from beta_plugin)' Chris@0: end Chris@0: Chris@0: def test_WITH_an_action_defined_in_two_namespaced_plugin_controllers_IT_should_use_the_latter_of_both Chris@0: get_action_on_controller :an_action, :shared_plugin, :namespace Chris@0: assert_response_body 'rendered in Namespace::SharedPluginController#an_action (from beta_plugin)' Chris@0: end Chris@0: end