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 / c4 / c4b62ae1f4f01307776331aad68b547e24878c12.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (1.57 KB)

1
require File.dirname(__FILE__) + '/../test_helper'
2

    
3
class ModelAndLibTest < Test::Unit::TestCase
4

    
5
 	def test_WITH_a_model_defined_only_in_a_plugin_IT_should_load_the_model
6
 	  assert_equal 'AlphaPluginModel (from alpha_plugin)', AlphaPluginModel.report_location
7
  end
8
  
9
  def test_WITH_a_model_defined_only_in_a_plugin_lib_dir_IT_should_load_the_model
10
 	  assert_equal 'AlphaPluginLibModel (from alpha_plugin)', AlphaPluginLibModel.report_location
11
  end
12

    
13
  # app takes precedence over plugins
14
	
15
	def test_WITH_a_model_defined_in_both_app_and_plugin_IT_should_load_the_one_in_app
16
 	  assert_equal 'AppAndPluginModel (from app)',	AppAndPluginModel.report_location  
17
 	  assert_raises(NoMethodError) { AppAndPluginLibModel.defined_only_in_alpha_engine_version }
18
  end
19
	
20
	def test_WITH_a_model_defined_in_both_app_and_plugin_lib_dirs_IT_should_load_the_one_in_app
21
 	  assert_equal 'AppAndPluginLibModel (from lib)', AppAndPluginLibModel.report_location
22
 	  assert_raises(NoMethodError) { AppAndPluginLibModel.defined_only_in_alpha_engine_version }
23
  end
24

    
25
  # subsequently loaded plugins take precendence over previously loaded plugins
26
	
27
  # TODO
28
  #
29
  # this does work when we rely on $LOAD_PATH while it won't work when we use
30
  # Dependency constant autoloading. This somewhat confusing difference has
31
  # been there since at least Rails 1.2.x. See http://www.ruby-forum.com/topic/134529
32
  
33
  def test_WITH_a_model_defined_in_two_plugins_IT_should_load_the_latter_of_both
34
    require 'shared_plugin_model'
35
    assert_equal SharedPluginModel.report_location, 'SharedPluginModel (from beta_plugin)'
36
  end
37
end