<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 *2.3.0 [Edge]*
 
+* Added view path support for engines [DHH]
+
 * Added that config/routes.rb files in engine plugins are automatically loaded (and reloaded when they change in dev mode) [DHH]
 
 * Added app/[models|controllers|helpers] to the load path for plugins that has an app directory (go engines ;)) [DHH]</diff>
      <filename>railties/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -487,12 +487,8 @@ Run `rake gems:install` to install the missing gems.
     def initialize_routing
       return unless configuration.frameworks.include?(:action_controller)
 
-      ActionController::Routing.controller_paths = configuration.controller_paths + plugin_loader.controller_paths
-
-      ([ configuration.routes_configuration_file ] + plugin_loader.routing_files).each do |routing_file|
-        ActionController::Routing::Routes.add_configuration_file(routing_file)
-      end
-
+      ActionController::Routing.controller_paths += configuration.controller_paths
+      ActionController::Routing::Routes.add_configuration_file(configuration.routes_configuration_file)
       ActionController::Routing::Routes.reload
     end
 </diff>
      <filename>railties/lib/initializer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -71,6 +71,11 @@ module Rails
       File.exist?(routing_file)
     end
 
+
+    def view_path
+      File.join(directory, 'app', 'views')
+    end
+
     def controller_path
       File.join(directory, 'app', 'controllers')
     end
@@ -95,11 +100,7 @@ module Rails
 
       
       def app_paths
-        [ 
-          File.join(directory, 'app', 'models'), 
-          File.join(directory, 'app', 'controllers'),
-          File.join(directory, 'app', 'helpers')
-        ]
+        [ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path ]
       end
       
       def lib_path</diff>
      <filename>railties/lib/rails/plugin.rb</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,8 @@ module Rails
           register_plugin_as_loaded(plugin)
         end
 
+        configure_engines
+
         ensure_all_registered_plugins_are_loaded!
       end
       
@@ -63,19 +65,31 @@ module Rails
         $LOAD_PATH.uniq!
       end
       
-      # Returns an array of all the controller paths found inside engine-type plugins.
-      def controller_paths
-        engines.collect(&amp;:controller_path)
-      end
-      
-      # Returns an array of routing.rb files from all the plugins that include config/routes.rb
-      def routing_files
-        plugins.select(&amp;:routed?).collect(&amp;:routing_file)
-      end
-      
       
       protected
+        def configure_engines
+          if engines.any?
+            add_engine_routing_configurations
+            add_engine_controller_paths
+            add_engine_view_paths
+          end
+        end
       
+        def add_engine_routing_configurations
+          engines.select(&amp;:routed?).collect(&amp;:routing_file).each do |routing_file|
+            ActionController::Routing::Routes.add_configuration_file(routing_file)
+          end
+        end
+        
+        def add_engine_controller_paths
+          ActionController::Routing.controller_paths += engines.collect(&amp;:controller_path)
+        end
+        
+        def add_engine_view_paths
+          # reverse it such that the last engine can overwrite view paths from the first, like with routes
+          ActionController::Base.view_paths += ActionView::PathSet.new(engines.collect(&amp;:view_path).reverse)
+        end
+
         # The locate_plugins method uses each class in config.plugin_locators to
         # find the set of all plugins available to this Rails application.
         def locate_plugins</diff>
      <filename>railties/lib/rails/plugin/loader.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,2 @@
-class EngineController &lt; ActionController::Base
+class EngineController
 end
\ No newline at end of file</diff>
      <filename>railties/test/fixtures/plugins/engines/engine/app/controllers/engine_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,8 @@
 require 'plugin_test_helper'
 
+$:.unshift File.dirname(__FILE__) + &quot;/../../actionpack/lib&quot;
+require 'action_controller'
+
 # Mocks out the configuration
 module Rails
   def self.configuration
@@ -7,149 +10,152 @@ module Rails
   end
 end
 
-uses_mocha &quot;Plugin Loader Tests&quot; do
-
-  class TestPluginLoader &lt; Test::Unit::TestCase
-    ORIGINAL_LOAD_PATH = $LOAD_PATH.dup
-
-    def setup
-      reset_load_path!
+class TestPluginLoader &lt; Test::Unit::TestCase
+  ORIGINAL_LOAD_PATH = $LOAD_PATH.dup
 
-      @configuration     = Rails::Configuration.new
-      @configuration.plugin_paths &lt;&lt; plugin_fixture_root_path
-      @initializer       = Rails::Initializer.new(@configuration)
-      @valid_plugin_path = plugin_fixture_path('default/stubby')
-      @empty_plugin_path = plugin_fixture_path('default/empty')
+  def setup
+    reset_load_path!
 
-      @failure_tip = &quot;It's likely someone has added a new plugin fixture without updating this list&quot;
+    @configuration     = Rails::Configuration.new
+    @configuration.plugin_paths &lt;&lt; plugin_fixture_root_path
+    @initializer       = Rails::Initializer.new(@configuration)
+    @valid_plugin_path = plugin_fixture_path('default/stubby')
+    @empty_plugin_path = plugin_fixture_path('default/empty')
 
-      @loader = Rails::Plugin::Loader.new(@initializer)
-    end
+    @failure_tip = &quot;It's likely someone has added a new plugin fixture without updating this list&quot;
 
-    def test_should_locate_plugins_by_asking_each_locator_specifed_in_configuration_for_its_plugins_result
-      locator_1 = stub(:plugins =&gt; [:a, :b, :c])
-      locator_2 = stub(:plugins =&gt; [:d, :e, :f])
-      locator_class_1 = stub(:new =&gt; locator_1)
-      locator_class_2 = stub(:new =&gt; locator_2)
-      @configuration.plugin_locators = [locator_class_1, locator_class_2]
-      assert_equal [:a, :b, :c, :d, :e, :f], @loader.send(:locate_plugins)
-    end
+    @loader = Rails::Plugin::Loader.new(@initializer)
+  end
 
-    def test_should_memoize_the_result_of_locate_plugins_as_all_plugins
-      plugin_list = [:a, :b, :c]
-      @loader.expects(:locate_plugins).once.returns(plugin_list)
-      assert_equal plugin_list, @loader.all_plugins
-      assert_equal plugin_list, @loader.all_plugins # ensuring that locate_plugins isn't called again
-    end
+  def test_should_locate_plugins_by_asking_each_locator_specifed_in_configuration_for_its_plugins_result
+    locator_1 = stub(:plugins =&gt; [:a, :b, :c])
+    locator_2 = stub(:plugins =&gt; [:d, :e, :f])
+    locator_class_1 = stub(:new =&gt; locator_1)
+    locator_class_2 = stub(:new =&gt; locator_2)
+    @configuration.plugin_locators = [locator_class_1, locator_class_2]
+    assert_equal [:a, :b, :c, :d, :e, :f], @loader.send(:locate_plugins)
+  end
 
-    def test_should_return_empty_array_if_configuration_plugins_is_empty
-      @configuration.plugins = []
-      assert_equal [], @loader.plugins
-    end
+  def test_should_memoize_the_result_of_locate_plugins_as_all_plugins
+    plugin_list = [:a, :b, :c]
+    @loader.expects(:locate_plugins).once.returns(plugin_list)
+    assert_equal plugin_list, @loader.all_plugins
+    assert_equal plugin_list, @loader.all_plugins # ensuring that locate_plugins isn't called again
+  end
 
-    def test_should_find_all_availble_plugins_and_return_as_all_plugins
-      assert_plugins [ :engine, :stubby, :plugin_with_no_lib_dir, :gemlike, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
-    end
+  def test_should_return_empty_array_if_configuration_plugins_is_empty
+    @configuration.plugins = []
+    assert_equal [], @loader.plugins
+  end
 
-    def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_untouched
-      assert_plugins [:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
-    end
+  def test_should_find_all_availble_plugins_and_return_as_all_plugins
+    assert_plugins [ :engine, :stubby, :plugin_with_no_lib_dir, :gemlike, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
+  end
 
-    def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_nil
-      @configuration.plugins = nil
-      assert_plugins [:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
-    end
+  def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_untouched
+    assert_plugins [:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+  end
 
-    def test_should_return_specific_plugins_named_in_config_plugins_array_if_set
-      plugin_names = [:acts_as_chunky_bacon, :stubby]
-      only_load_the_following_plugins! plugin_names
-      assert_plugins plugin_names, @loader.plugins
-    end
+  def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_nil
+    @configuration.plugins = nil
+    assert_plugins [:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+  end
 
-    def test_should_respect_the_order_of_plugins_given_in_configuration
-      plugin_names = [:stubby, :acts_as_chunky_bacon]
-      only_load_the_following_plugins! plugin_names
-      assert_plugins plugin_names, @loader.plugins
-    end
+  def test_should_return_specific_plugins_named_in_config_plugins_array_if_set
+    plugin_names = [:acts_as_chunky_bacon, :stubby]
+    only_load_the_following_plugins! plugin_names
+    assert_plugins plugin_names, @loader.plugins
+  end
 
-    def test_should_load_all_plugins_in_natural_order_when_all_is_used
-      only_load_the_following_plugins! [:all]
-      assert_plugins [:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
-    end
+  def test_should_respect_the_order_of_plugins_given_in_configuration
+    plugin_names = [:stubby, :acts_as_chunky_bacon]
+    only_load_the_following_plugins! plugin_names
+    assert_plugins plugin_names, @loader.plugins
+  end
 
-    def test_should_load_specified_plugins_in_order_and_then_all_remaining_plugins_when_all_is_used
-      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon, :all]
-      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :engine, :gemlike, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
-    end
+  def test_should_load_all_plugins_in_natural_order_when_all_is_used
+    only_load_the_following_plugins! [:all]
+    assert_plugins [:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+  end
 
-    def test_should_be_able_to_specify_loading_of_plugins_loaded_after_all
-      only_load_the_following_plugins!  [:stubby, :all, :acts_as_chunky_bacon]
-      assert_plugins [:stubby, :a, :engine, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
-    end
+  def test_should_load_specified_plugins_in_order_and_then_all_remaining_plugins_when_all_is_used
+    only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon, :all]
+    assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :engine, :gemlike, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
+  end
 
-    def test_should_accept_plugin_names_given_as_strings
-      only_load_the_following_plugins! ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
-      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
-    end
+  def test_should_be_able_to_specify_loading_of_plugins_loaded_after_all
+    only_load_the_following_plugins!  [:stubby, :all, :acts_as_chunky_bacon]
+    assert_plugins [:stubby, :a, :engine, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
+  end
 
-    def test_should_add_plugin_load_paths_to_global_LOAD_PATH_array
-      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
-      stubbed_application_lib_index_in_LOAD_PATHS = 4
-      @loader.stubs(:application_lib_index).returns(stubbed_application_lib_index_in_LOAD_PATHS)
+  def test_should_accept_plugin_names_given_as_strings
+    only_load_the_following_plugins! ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
+    assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
+  end
 
-      @loader.add_plugin_load_paths
+  def test_should_add_plugin_load_paths_to_global_LOAD_PATH_array
+    only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
+    stubbed_application_lib_index_in_LOAD_PATHS = 4
+    @loader.stubs(:application_lib_index).returns(stubbed_application_lib_index_in_LOAD_PATHS)
 
-      assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) &gt;= stubbed_application_lib_index_in_LOAD_PATHS
-      assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) &gt;= stubbed_application_lib_index_in_LOAD_PATHS
-    end
+    @loader.add_plugin_load_paths
 
-    def test_should_add_plugin_load_paths_to_Dependencies_load_paths
-      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
+    assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) &gt;= stubbed_application_lib_index_in_LOAD_PATHS
+    assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) &gt;= stubbed_application_lib_index_in_LOAD_PATHS
+  end
 
-      @loader.add_plugin_load_paths
+  def test_should_add_plugin_load_paths_to_Dependencies_load_paths
+    only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
 
-      assert ActiveSupport::Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
-      assert ActiveSupport::Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
-    end
+    @loader.add_plugin_load_paths
 
+    assert ActiveSupport::Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
+    assert ActiveSupport::Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
+  end
 
-    def test_should_add_engine_load_paths_to_Dependencies_load_paths
-      only_load_the_following_plugins! [:engine]
+  def test_should_add_engine_load_paths_to_Dependencies_load_paths
+    only_load_the_following_plugins! [:engine]
 
-      @loader.add_plugin_load_paths
+    @loader.add_plugin_load_paths
 
-      %w( models controllers helpers ).each do |app_part|
-        assert ActiveSupport::Dependencies.load_paths.include?(
-          File.join(plugin_fixture_path('engines/engine'), 'app', app_part)
-        ), &quot;Couldn't find #{app_part} in load path&quot;
-      end
+    %w( models controllers helpers ).each do |app_part|
+      assert ActiveSupport::Dependencies.load_paths.include?(
+        File.join(plugin_fixture_path('engines/engine'), 'app', app_part)
+      ), &quot;Couldn't find #{app_part} in load path&quot;
     end
+  end
+  
+  def test_engine_controllers_should_have_their_view_path_set_when_loaded
+    only_load_the_following_plugins!([ :engine ])
 
-    def test_should_add_plugin_load_paths_to_Dependencies_load_once_paths
-      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
-
-      @loader.add_plugin_load_paths
+    @loader.send :add_engine_view_paths
+    
+    assert_equal [ File.join(plugin_fixture_path('engines/engine'), 'app', 'views') ], ActionController::Base.view_paths
+  end
 
-      assert ActiveSupport::Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
-      assert ActiveSupport::Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
-    end
+  def test_should_add_plugin_load_paths_to_Dependencies_load_once_paths
+    only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
 
-    def test_should_add_all_load_paths_from_a_plugin_to_LOAD_PATH_array
-      plugin_load_paths = [&quot;a&quot;, &quot;b&quot;]
-      plugin = stub(:load_paths =&gt; plugin_load_paths)
-      @loader.stubs(:plugins).returns([plugin])
+    @loader.add_plugin_load_paths
 
-      @loader.add_plugin_load_paths
+    assert ActiveSupport::Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
+    assert ActiveSupport::Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
+  end
 
-      plugin_load_paths.each { |path| assert $LOAD_PATH.include?(path) }
-    end
+  def test_should_add_all_load_paths_from_a_plugin_to_LOAD_PATH_array
+    plugin_load_paths = [&quot;a&quot;, &quot;b&quot;]
+    plugin = stub(:load_paths =&gt; plugin_load_paths)
+    @loader.stubs(:plugins).returns([plugin])
 
-    private
+    @loader.add_plugin_load_paths
 
-      def reset_load_path!
-        $LOAD_PATH.clear
-        ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH &lt;&lt; path }
-      end
+    plugin_load_paths.each { |path| assert $LOAD_PATH.include?(path) }
   end
 
-end
+
+  private
+    def reset_load_path!
+      $LOAD_PATH.clear
+      ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH &lt;&lt; path }
+    end
+end
\ No newline at end of file</diff>
      <filename>railties/test/plugin_loader_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>229f959d15e451890db60dbb73f8565079977814</id>
    </parent>
  </parents>
  <author>
    <name>David Heinemeier Hansson</name>
    <login>dhh</login>
    <email>david@loudthinking.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/f2ee056873b84f8917e72d87181e1a9f5f653342</url>
  <id>f2ee056873b84f8917e72d87181e1a9f5f653342</id>
  <committed-date>2008-11-27T09:59:24-08:00</committed-date>
  <authored-date>2008-11-27T09:59:24-08:00</authored-date>
  <message>Added view path support for engines [DHH]</message>
  <tree>47c47835a9f34d065b85f3d1d68f9e21e78649f4</tree>
  <committer>
    <name>David Heinemeier Hansson</name>
    <login>dhh</login>
    <email>david@loudthinking.com</email>
  </committer>
</commit>
