To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 52 / 52fb1ca187bdbea92b2ca21fb1a15fadb8ae488e.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (2.2 KB)

1
# Tests in this file ensure that:
2
#
3
# * plugin controller actions are found
4
# * actions defined in application controllers take precedence over those in plugins
5
# * actions in controllers in subsequently loaded plugins take precendence over those in previously loaded plugins
6
# * this works for actions in namespaced controllers accordingly
7

    
8
require File.dirname(__FILE__) + '/../test_helper'
9

    
10
class ControllerLoadingTest < ActionController::TestCase
11
  def setup
12
    @request    = ActionController::TestRequest.new
13
    @response   = ActionController::TestResponse.new
14
  end
15

    
16
  # plugin controller actions should be found
17

    
18
	def test_WITH_an_action_defined_only_in_a_plugin_IT_should_use_this_action
19
	  get_action_on_controller :an_action, :alpha_plugin
20
    assert_response_body 'rendered in AlphaPluginController#an_action'
21
  end
22
  
23
	def test_WITH_an_action_defined_only_in_a_namespaced_plugin_controller_IT_should_use_this_action
24
	  get_action_on_controller :an_action, :alpha_plugin, :namespace
25
    assert_response_body 'rendered in Namespace::AlphaPluginController#an_action'
26
  end
27

    
28
  # app takes precedence over plugins
29

    
30
  def test_WITH_an_action_defined_in_both_app_and_plugin_IT_should_use_the_one_in_app
31
	  get_action_on_controller :an_action, :app_and_plugin
32
    assert_response_body 'rendered in AppAndPluginController#an_action (from app)'
33
  end
34
  
35
  def test_WITH_an_action_defined_in_namespaced_controllers_in_both_app_and_plugin_IT_should_use_the_one_in_app
36
	  get_action_on_controller :an_action, :app_and_plugin, :namespace
37
    assert_response_body 'rendered in Namespace::AppAndPluginController#an_action (from app)'
38
  end
39

    
40
  # subsequently loaded plugins take precendence over previously loaded plugins
41

    
42
  def test_WITH_an_action_defined_in_two_plugin_controllers_IT_should_use_the_latter_of_both
43
	  get_action_on_controller :an_action, :shared_plugin
44
    assert_response_body 'rendered in SharedPluginController#an_action (from beta_plugin)'
45
  end
46
  
47
  def test_WITH_an_action_defined_in_two_namespaced_plugin_controllers_IT_should_use_the_latter_of_both
48
	  get_action_on_controller :an_action, :shared_plugin, :namespace
49
    assert_response_body 'rendered in Namespace::SharedPluginController#an_action (from beta_plugin)'
50
  end
51
end