annotate .svn/pristine/f7/f767b8d14c7249c0fabe9ba271f45b37cfcab811.svn-base @ 1478:5ca1f4a47171 bibplugin_db_migrations

Close obsolete branch bibplugin_db_migrations
author Chris Cannam
date Fri, 30 Nov 2012 14:40:50 +0000
parents cbb26bc654de
children
rev   line source
Chris@909 1 # Tests in this file ensure that:
Chris@909 2 #
Chris@909 3 # * plugin views are found
Chris@909 4 # * views in the application take precedence over those in plugins
Chris@909 5 # * views in subsequently loaded plugins take precendence over those in previously loaded plugins
Chris@909 6 # * this works for namespaced views accordingly
Chris@909 7
Chris@909 8 require File.dirname(__FILE__) + '/../test_helper'
Chris@909 9
Chris@909 10 class ViewLoadingTest < ActionController::TestCase
Chris@909 11 def setup
Chris@909 12 @request = ActionController::TestRequest.new
Chris@909 13 @response = ActionController::TestResponse.new
Chris@909 14 end
Chris@909 15
Chris@909 16 # plugin views should be found
Chris@909 17
Chris@909 18 def test_WITH_a_view_defined_only_in_a_plugin_IT_should_find_the_view
Chris@909 19 get_action_on_controller :a_view, :alpha_plugin
Chris@909 20 assert_response_body 'alpha_plugin/a_view'
Chris@909 21 end
Chris@909 22
Chris@909 23 def test_WITH_a_namespaced_view_defined_only_in_a_plugin_IT_should_find_the_view
Chris@909 24 get_action_on_controller :a_view, :alpha_plugin, :namespace
Chris@909 25 assert_response_body 'namespace/alpha_plugin/a_view'
Chris@909 26 end
Chris@909 27
Chris@909 28 # app takes precedence over plugins
Chris@909 29
Chris@909 30 def test_WITH_a_view_defined_in_both_app_and_plugin_IT_should_find_the_one_in_app
Chris@909 31 get_action_on_controller :a_view, :app_and_plugin
Chris@909 32 assert_response_body 'app_and_plugin/a_view (from app)'
Chris@909 33 end
Chris@909 34
Chris@909 35 def test_WITH_a_namespaced_view_defined_in_both_app_and_plugin_IT_should_find_the_one_in_app
Chris@909 36 get_action_on_controller :a_view, :app_and_plugin, :namespace
Chris@909 37 assert_response_body 'namespace/app_and_plugin/a_view (from app)'
Chris@909 38 end
Chris@909 39
Chris@909 40 # subsequently loaded plugins take precendence over previously loaded plugins
Chris@909 41
Chris@909 42 def test_WITH_a_view_defined_in_two_plugins_IT_should_find_the_latter_of_both
Chris@909 43 get_action_on_controller :a_view, :shared_plugin
Chris@909 44 assert_response_body 'shared_plugin/a_view (from beta_plugin)'
Chris@909 45 end
Chris@909 46
Chris@909 47 def test_WITH_a_namespaced_view_defined_in_two_plugins_IT_should_find_the_latter_of_both
Chris@909 48 get_action_on_controller :a_view, :shared_plugin, :namespace
Chris@909 49 assert_response_body 'namespace/shared_plugin/a_view (from beta_plugin)'
Chris@909 50 end
Chris@909 51
Chris@909 52 # layouts loaded from plugins
Chris@909 53
Chris@909 54 def test_should_be_able_to_load_a_layout_from_a_plugin
Chris@909 55 get_action_on_controller :action_with_layout, :alpha_plugin
Chris@909 56 assert_response_body 'rendered in AlphaPluginController#action_with_layout (with plugin layout)'
Chris@909 57 end
Chris@909 58
Chris@909 59 end
Chris@909 60