From d84b2f37d018621aea99bfe30611ab75a02a291a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Apr 2011 19:17:58 +0200 Subject: Fix tests. --- railties/lib/rails/engine.rb | 37 ++++++++++++++++++++++------------ railties/lib/rails/tasks/railties.rake | 2 +- 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index e201aa591d..cbf09790ab 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -542,27 +542,30 @@ module Rails rake_tasks do next if self.is_a?(Rails::Application) + next unless has_migrations? or has_public? namespace railtie_name do - desc "Shortcut for running both rake #{railtie_name}:install:migrations and #{railtie_name}:install:assets" + desc "Shortcut for copying migrations and assets from #{railtie_name}" task :install do - Rake::Task["#{railtie_name}:install:migrations"].invoke - Rake::Task["#{railtie_name}:install:assets"].invoke + Rake::Task["#{railtie_name}:install:migrations"].invoke if has_migrations? + Rake::Task["#{railtie_name}:install:public"].invoke if has_public? end namespace :install do - # TODO Add assets copying to this list - # TODO Skip this if there is no paths["db/migrate"] for the engine - desc "Copy migrations from #{railtie_name} to application" - task :migrations do - ENV["FROM"] = railtie_name - Rake::Task["railties:install:migrations"].invoke + if has_migrations? + desc "Copy migrations from #{railtie_name} to application" + task :migrations do + ENV["FROM"] = railtie_name + Rake::Task["railties:install:migrations"].invoke + end end - desc "Copy assets from #{railtie_name} to application" - task :assets do - ENV["FROM"] = railtie_name - Rake::Task["railties:install:assets"].invoke + if has_public? + desc "Copy public from #{railtie_name} to application" + task :public do + ENV["FROM"] = railtie_name + Rake::Task["railties:install:public"].invoke + end end end end @@ -578,6 +581,14 @@ module Rails defined?(@routes) end + def has_migrations? + paths["db/migrate"].first.present? + end + + def has_public? + paths["public"].first.present? + end + def find_root_with_flag(flag, default=nil) root_path = self.class.called_from diff --git a/railties/lib/rails/tasks/railties.rake b/railties/lib/rails/tasks/railties.rake index 16703879cf..7d2170dd30 100644 --- a/railties/lib/rails/tasks/railties.rake +++ b/railties/lib/rails/tasks/railties.rake @@ -1,7 +1,7 @@ namespace :railties do namespace :install do # desc "Copies missing assets from Railties (e.g. plugins, engines). You can specify Railties to use with FROM=railtie1,railtie2" - task :assets => :rails_env do + task :public => :rails_env do require 'rails/generators/base' Rails.application.initialize! -- cgit v1.2.3