public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make plugins initialize also from rails/init.rb to ensure consistency with gems 
used as plugins

[#272 state:resolved]
Jacek Becela (author)
Wed May 28 12:30:44 -0700 2008
technoweenie (committer)
Sun Jun 08 10:05:45 -0700 2008
commit  86a042ddd9dba8f62e7328c7258a798aef73d57f
tree    bedcafcbc1a37ba1ea6d50956febf32bc2611d92
parent  b336ce9e062e4de0d20aa359b08e86fe83b6dd89
...
74
75
76
77
 
78
79
80
 
 
 
 
 
 
 
 
81
82
83
...
74
75
76
 
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
0
@@ -74,10 +74,18 @@ module Rails
0
         File.join(directory, 'lib')
0
       end
0
 
0
-      def init_path
0
+      def classic_init_path
0
         File.join(directory, 'init.rb')
0
       end
0
 
0
+      def gem_init_path
0
+        File.join(directory, 'rails', 'init.rb')
0
+      end
0
+
0
+      def init_path
0
+        File.file?(gem_init_path) ? gem_init_path : classic_init_path
0
+      end
0
+
0
       def has_lib_directory?
0
         File.directory?(lib_path)
0
       end
...
173
174
175
176
 
177
178
179
...
181
182
183
184
 
185
186
187
...
189
190
191
192
 
193
194
195
...
173
174
175
 
176
177
178
179
...
181
182
183
 
184
185
186
187
...
189
190
191
 
192
193
194
195
0
@@ -173,7 +173,7 @@ uses_mocha "Initializer plugin loading tests" do
0
     def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
0
       failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
0
       load_plugins!
0
-      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
0
+      assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
0
     end
0
 
0
     def test_all_plugins_loaded_when_all_is_used
0
@@ -181,7 +181,7 @@ uses_mocha "Initializer plugin loading tests" do
0
       only_load_the_following_plugins! plugin_names
0
       load_plugins!
0
       failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
0
-      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip
0
+      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :gemlike, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip
0
     end
0
 
0
     def test_all_plugins_loaded_after_all
0
@@ -189,7 +189,7 @@ uses_mocha "Initializer plugin loading tests" do
0
       only_load_the_following_plugins! plugin_names
0
       load_plugins!
0
       failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
0
-      assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @initializer.loaded_plugins, failure_tip
0
+      assert_plugins [:stubby, :a, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @initializer.loaded_plugins, failure_tip
0
     end
0
 
0
     def test_plugin_names_may_be_strings
...
48
49
50
51
 
52
53
54
55
 
56
57
58
59
60
 
61
62
63
...
74
75
76
77
 
78
79
80
81
82
 
83
84
85
86
87
 
88
89
90
...
48
49
50
 
51
52
53
54
 
55
56
57
58
59
 
60
61
62
63
...
74
75
76
 
77
78
79
80
81
 
82
83
84
85
86
 
87
88
89
90
0
@@ -48,16 +48,16 @@ uses_mocha "Plugin Loader Tests" do
0
     end
0
 
0
     def test_should_find_all_availble_plugins_and_return_as_all_plugins
0
-      assert_plugins [:stubby, :plugin_with_no_lib_dir, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
0
+      assert_plugins [:stubby, :plugin_with_no_lib_dir, :gemlike, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
0
     end
0
 
0
     def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_untouched
0
-      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
0
+      assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
0
     end
0
 
0
     def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_nil
0
       @configuration.plugins = nil
0
-      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
0
+      assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
0
     end
0
 
0
     def test_should_return_specific_plugins_named_in_config_plugins_array_if_set
0
@@ -74,17 +74,17 @@ uses_mocha "Plugin Loader Tests" do
0
 
0
     def test_should_load_all_plugins_in_natural_order_when_all_is_used
0
       only_load_the_following_plugins! [:all]
0
-      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
0
+      assert_plugins [:a, :acts_as_chunky_bacon, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
0
     end
0
 
0
     def test_should_load_specified_plugins_in_order_and_then_all_remaining_plugins_when_all_is_used
0
       only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon, :all]
0
-      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
0
+      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :gemlike, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
0
     end
0
 
0
     def test_should_be_able_to_specify_loading_of_plugins_loaded_after_all
0
       only_load_the_following_plugins!  [:stubby, :all, :acts_as_chunky_bacon]
0
-      assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
0
+      assert_plugins [:stubby, :a, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
0
     end
0
 
0
     def test_should_accept_plugin_names_given_as_strings
...
47
48
49
50
 
51
52
53
54
55
 
56
57
58
...
47
48
49
 
50
51
52
53
54
 
55
56
57
58
0
@@ -47,12 +47,12 @@ uses_mocha "Plugin Locator Tests" do
0
     end
0
   
0
     def test_should_return_all_plugins_found_under_the_set_plugin_paths
0
-      assert_equal ["a", "acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
0
+      assert_equal ["a", "acts_as_chunky_bacon", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
0
     end
0
   
0
     def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration
0
       @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")]
0
-      assert_equal ["acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
0
+      assert_equal ["acts_as_chunky_bacon", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
0
     
0
       @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")]
0
       assert_equal ["a"], @locator.plugins.map(&:name)
...
5
6
7
8
9
10
 
 
 
 
11
12
13
...
70
71
72
73
 
 
 
 
 
 
 
 
74
75
76
...
5
6
7
 
 
 
8
9
10
11
12
13
14
...
71
72
73
 
74
75
76
77
78
79
80
81
82
83
84
0
@@ -5,9 +5,10 @@ uses_mocha "Plugin Tests" do
0
   class PluginTest < Test::Unit::TestCase
0
 
0
     def setup
0
-      @initializer       = Rails::Initializer.new(Rails::Configuration.new)
0
-      @valid_plugin_path = plugin_fixture_path('default/stubby')
0
-      @empty_plugin_path = plugin_fixture_path('default/empty')    
0
+      @initializer         = Rails::Initializer.new(Rails::Configuration.new)
0
+      @valid_plugin_path   = plugin_fixture_path('default/stubby')
0
+      @empty_plugin_path   = plugin_fixture_path('default/empty')
0
+      @gemlike_plugin_path = plugin_fixture_path('default/gemlike')
0
     end
0
 
0
     def test_should_determine_plugin_name_from_the_directory_of_the_plugin
0
@@ -70,7 +71,14 @@ uses_mocha "Plugin Tests" do
0
         plugin.stubs(:evaluate_init_rb)
0
         plugin.send(:load, @initializer)
0
       end
0
-    
0
+
0
+      # This path is fine so nothing is raised
0
+      assert_nothing_raised do
0
+        plugin = plugin_for(@gemlike_plugin_path)
0
+        plugin.stubs(:evaluate_init_rb)
0
+        plugin.send(:load, @initializer)
0
+      end
0
+
0
       # This is an empty path so it raises
0
       assert_raises(LoadError) do
0
         plugin = plugin_for(@empty_plugin_path)

Comments