Chris@0: # Tests in this file ensure that: Chris@0: # Chris@0: # * plugin views are found Chris@0: # * views in the application take precedence over those in plugins Chris@0: # * views in subsequently loaded plugins take precendence over those in previously loaded plugins Chris@0: # * this works for namespaced views accordingly Chris@0: Chris@0: require File.dirname(__FILE__) + '/../test_helper' Chris@0: Chris@0: class ViewLoadingTest < 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 views should be found Chris@0: Chris@0: def test_WITH_a_view_defined_only_in_a_plugin_IT_should_find_the_view Chris@0: get_action_on_controller :a_view, :alpha_plugin Chris@0: assert_response_body 'alpha_plugin/a_view' Chris@0: end Chris@0: Chris@0: def test_WITH_a_namespaced_view_defined_only_in_a_plugin_IT_should_find_the_view Chris@0: get_action_on_controller :a_view, :alpha_plugin, :namespace Chris@0: assert_response_body 'namespace/alpha_plugin/a_view' Chris@0: end Chris@0: Chris@0: # app takes precedence over plugins Chris@0: Chris@0: def test_WITH_a_view_defined_in_both_app_and_plugin_IT_should_find_the_one_in_app Chris@0: get_action_on_controller :a_view, :app_and_plugin Chris@0: assert_response_body 'app_and_plugin/a_view (from app)' Chris@0: end Chris@0: Chris@0: def test_WITH_a_namespaced_view_defined_in_both_app_and_plugin_IT_should_find_the_one_in_app Chris@0: get_action_on_controller :a_view, :app_and_plugin, :namespace Chris@0: assert_response_body 'namespace/app_and_plugin/a_view (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_a_view_defined_in_two_plugins_IT_should_find_the_latter_of_both Chris@0: get_action_on_controller :a_view, :shared_plugin Chris@0: assert_response_body 'shared_plugin/a_view (from beta_plugin)' Chris@0: end Chris@0: Chris@0: def test_WITH_a_namespaced_view_defined_in_two_plugins_IT_should_find_the_latter_of_both Chris@0: get_action_on_controller :a_view, :shared_plugin, :namespace Chris@0: assert_response_body 'namespace/shared_plugin/a_view (from beta_plugin)' Chris@0: end Chris@0: Chris@0: # layouts loaded from plugins Chris@0: Chris@0: def test_should_be_able_to_load_a_layout_from_a_plugin Chris@0: get_action_on_controller :action_with_layout, :alpha_plugin Chris@0: assert_response_body 'rendered in AlphaPluginController#action_with_layout (with plugin layout)' Chris@0: end Chris@0: Chris@0: end Chris@0: