annotate vendor/plugins/engines/test/unit/model_and_lib_test.rb @ 904:0a8317a50fa0
redmine-1.1
Close obsolete branch redmine-1.1
author |
Chris Cannam |
date |
Fri, 14 Jan 2011 12:53:21 +0000 |
parents |
513646585e45 |
children |
|
rev |
line source |
Chris@0
|
1 require File.dirname(__FILE__) + '/../test_helper'
|
Chris@0
|
2
|
Chris@0
|
3 class ModelAndLibTest < Test::Unit::TestCase
|
Chris@0
|
4
|
Chris@0
|
5 def test_WITH_a_model_defined_only_in_a_plugin_IT_should_load_the_model
|
Chris@0
|
6 assert_equal 'AlphaPluginModel (from alpha_plugin)', AlphaPluginModel.report_location
|
Chris@0
|
7 end
|
Chris@0
|
8
|
Chris@0
|
9 def test_WITH_a_model_defined_only_in_a_plugin_lib_dir_IT_should_load_the_model
|
Chris@0
|
10 assert_equal 'AlphaPluginLibModel (from alpha_plugin)', AlphaPluginLibModel.report_location
|
Chris@0
|
11 end
|
Chris@0
|
12
|
Chris@0
|
13 # app takes precedence over plugins
|
Chris@0
|
14
|
Chris@0
|
15 def test_WITH_a_model_defined_in_both_app_and_plugin_IT_should_load_the_one_in_app
|
Chris@0
|
16 assert_equal 'AppAndPluginModel (from app)', AppAndPluginModel.report_location
|
Chris@0
|
17 assert_raises(NoMethodError) { AppAndPluginLibModel.defined_only_in_alpha_engine_version }
|
Chris@0
|
18 end
|
Chris@0
|
19
|
Chris@0
|
20 def test_WITH_a_model_defined_in_both_app_and_plugin_lib_dirs_IT_should_load_the_one_in_app
|
Chris@0
|
21 assert_equal 'AppAndPluginLibModel (from lib)', AppAndPluginLibModel.report_location
|
Chris@0
|
22 assert_raises(NoMethodError) { AppAndPluginLibModel.defined_only_in_alpha_engine_version }
|
Chris@0
|
23 end
|
Chris@0
|
24
|
Chris@0
|
25 # subsequently loaded plugins take precendence over previously loaded plugins
|
Chris@0
|
26
|
Chris@0
|
27 # TODO
|
Chris@0
|
28 #
|
Chris@0
|
29 # this does work when we rely on $LOAD_PATH while it won't work when we use
|
Chris@0
|
30 # Dependency constant autoloading. This somewhat confusing difference has
|
Chris@0
|
31 # been there since at least Rails 1.2.x. See http://www.ruby-forum.com/topic/134529
|
Chris@0
|
32
|
Chris@0
|
33 def test_WITH_a_model_defined_in_two_plugins_IT_should_load_the_latter_of_both
|
Chris@0
|
34 require 'shared_plugin_model'
|
Chris@0
|
35 assert_equal SharedPluginModel.report_location, 'SharedPluginModel (from beta_plugin)'
|
Chris@0
|
36 end
|
Chris@0
|
37 end |