diff options
author | José Valim <jose.valim@gmail.com> | 2010-12-09 16:09:47 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-12-09 16:09:51 +0100 |
commit | cc48192248f107c61294f72459fd027d45403ba5 (patch) | |
tree | c52148424f4cdbd07f1c244603aa1bffe3b30a62 /railties/lib | |
parent | d3f7e565d1a6ee15605971c3f3fea6e756a1ff99 (diff) | |
parent | 7b9f634e15bfc3f92f4ac7e18537443a55306c10 (diff) | |
download | rails-cc48192248f107c61294f72459fd027d45403ba5.tar.gz rails-cc48192248f107c61294f72459fd027d45403ba5.tar.bz2 rails-cc48192248f107c61294f72459fd027d45403ba5.zip |
Merge remote branch 'drogus/dummy_tasks'
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/lib')
7 files changed, 26 insertions, 15 deletions
diff --git a/railties/lib/rails/application/railties.rb b/railties/lib/rails/application/railties.rb index c1d2de571f..4fc5e92837 100644 --- a/railties/lib/rails/application/railties.rb +++ b/railties/lib/rails/application/railties.rb @@ -8,14 +8,6 @@ module Rails @all.each(&block) if block @all end - - def railties - @railties ||= ::Rails::Railtie.subclasses.map(&:instance) - end - - def engines - @engines ||= ::Rails::Engine.subclasses.map(&:instance) - end end end end diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 338565247f..46363d7921 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -18,8 +18,7 @@ when 'generate', 'destroy', 'plugin' require APP_PATH Rails.application.require_environment! - if defined?(ENGINE_PATH) - engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH } + if defined?(ENGINE_PATH) && engine = Rails::Engine.find(ENGINE_PATH) Rails.application = engine end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 85fa4424c4..b188fdfca1 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -371,6 +371,11 @@ module Rails end end end + + # Finds engine with given path + def find(path) + Rails::Engine::Railties.engines.find { |r| File.expand_path(r.root.to_s) == File.expand_path(path.to_s) } + end end delegate :middleware, :root, :paths, :to => :config diff --git a/railties/lib/rails/engine/railties.rb b/railties/lib/rails/engine/railties.rb index e91bdbf1e5..d5ecd2e48d 100644 --- a/railties/lib/rails/engine/railties.rb +++ b/railties/lib/rails/engine/railties.rb @@ -18,6 +18,16 @@ module Rails Plugin.all(plugin_names, @config.paths["vendor/plugins"].existent) end end + + def self.railties + @railties ||= ::Rails::Railtie.subclasses.map(&:instance) + end + + def self.engines + @engines ||= ::Rails::Engine.subclasses.map(&:instance) + end + + delegate :railties, :engines, :to => "self.class" end end end diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile index 12350309bf..25292f59ad 100755 --- a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile @@ -14,3 +14,11 @@ Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('README.rdoc') rdoc.rdoc_files.include('lib/**/*.rb') end + +<% if full? && !options[:skip_active_record] -%> +namespace :app do + ENGINE_PATH = File.expand_path("..", __FILE__) + load File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__) +end +<% end -%> + diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb b/railties/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb index d06fe7cbd0..dd4d2da4eb 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +++ b/railties/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb @@ -1,7 +1,9 @@ require 'test_helper' class NavigationTest < ActionDispatch::IntegrationTest +<% unless options[:skip_active_record] -%> fixtures :all +<% end -%> # Replace this with your real tests. test "the truth" do diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb index 7b61047e77..791b901593 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb @@ -6,10 +6,5 @@ require "rails/test_help" Rails.backtrace_cleaner.remove_silencers! -<% if full? && !options[:skip_active_record] -%> -# Run any available migration from application -ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__) -<% end -%> - # Load support files Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } |