Changeset 258
- Timestamp:
- 01/31/06 03:54:44 (3 years ago)
- Files:
-
- applications/engines_test/app/controllers/james (deleted)
- applications/engines_test/app/views/james (deleted)
- applications/engines_test/test/unit/load_path_test.rb (modified) (4 diffs)
- applications/engines_test/test/unit/model_and_lib_test.rb (modified) (4 diffs)
- applications/engines_test/vendor/plugins/alpha_engine/app/controllers/admin (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
applications/engines_test/test/unit/load_path_test.rb
r256 r258 3 3 class LoadPathTest < Test::Unit::TestCase 4 4 5 def setup 6 @load_path = $LOAD_PATH.collect { |p| File.expand_path(p) } 7 end 8 9 def load_path_index(dir) 10 @load_path.index(File.expand_path(dir)) 11 end 12 5 13 def test_application_lib_path_comes_before_all_engine_libs 6 app_lib_index = $LOAD_PATH.index(File.join(RAILS_ROOT, 'lib'))14 app_lib_index = load_path_index(File.join(RAILS_ROOT, 'lib')) 7 15 Engines.active.each { |e| 8 engine_index = $LOAD_PATH.index(File.join(e.root, 'lib'))16 engine_index = load_path_index(File.join(e.root, 'lib')) 9 17 assert app_lib_index < engine_index 10 18 } … … 16 24 types = ['app/controllers', 'app/helpers', 'app/models', 'components'] 17 25 types.each do |t| 18 app_index = $LOAD_PATH.index(File.join(RAILS_ROOT, t))26 app_index = load_path_index(File.join(RAILS_ROOT, t)) 19 27 Engines.active.each do |e| 20 engine_index = $LOAD_PATH.index(File.join(e.root, t))28 engine_index = load_path_index(File.join(e.root, t)) 21 29 if !engine_index.nil? 22 30 assert app_index < engine_index … … 28 36 # the engine directories should appear in the proper order based on 29 37 # the order they were started 30 def test_application_app_ libs_come_before_all_engine_app_libs38 def test_application_app_dirs_come_before_all_engine_app_dirs 31 39 engine_indexes = {} 32 40 types = ['app/controllers', 'app/helpers', 'app/models', 'components'] … … 34 42 engine_indexes[e] = [] 35 43 types.each do |t| 36 engine_indexes[e] << $LOAD_PATH.index(File.join(e.root, t)) 44 index = load_path_index(File.join(e.root, t)) 45 engine_indexes[e] << index if !index.nil? 37 46 end 38 47 end 48 49 # get the indexes, in order, of each engine with app dir paths in $LOAD_PATH 50 active_engines_with_paths = [] 51 Engines.active.length.times do |i| 52 active_engines_with_paths << i if !engine_indexes[Engines.active[i]].empty? 53 end 39 54 40 puts engine_indexes.inspect 41 42 Engines.active.length.times do |i| 43 puts "i: #{i} of #{Engines.active.length}" 55 active_engines_with_paths.each do |i| 44 56 engine = Engines.active[i] 45 puts "#{engine}"46 57 next_engine = Engines.active[i+1] 47 if !next_engine.nil? 58 if !next_engine.nil? && # if there is a next engine 59 !engine_indexes[engine].empty? && # if there were any paths for 60 !engine_indexes[next_engine].empty? 48 61 assert engine_indexes[engine].max < engine_indexes[next_engine].min 49 62 end 50 63 end 51 52 64 end 53 65 applications/engines_test/test/unit/model_and_lib_test.rb
r256 r258 3 3 class ModelAndLibTest < Test::Unit::TestCase 4 4 5 # The Account model is only present in the alpha engine 5 6 def test_loading_model_from_engine 6 7 assert_not_nil Account.new … … 8 9 end 9 10 10 # this is a 'negative' test - it would be great if models didn't behave 11 # like this 11 # Banjo model is present in both the alpha and beta engines, but 12 # since the beta engine has higher precidence, it will be loaded rather 13 # than the alpha version 12 14 def test_model_loads_from_last_active_engine 13 15 assert_not_nil Banjo.new … … 16 18 end 17 19 20 # The Clown model is present in the application and the alpha engine, 21 # but since the application should take precidence over ANY engine, 22 # the application version will be loaded 18 23 def test_model_loads_from_application_rather_than_engine 19 24 assert_not_nil Clown.new … … 22 27 end 23 28 29 # The Apple class is only present in the alpha engine, and it should 30 # be loaded from that successfully. 24 31 def test_loading_class_from_engine_lib 25 32 assert_not_nil Apple.new 26 33 end 27 34 35 # The Banana class is present in the application and the alpha engine, 36 # so it should be loaded from the application 28 37 def test_loading_lib_from_application_rather_than_engine 29 38 assert_not_nil Banana.new
