diff options
author | José Valim <jose.valim@gmail.com> | 2011-04-15 19:17:58 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-04-15 19:17:58 +0200 |
commit | d84b2f37d018621aea99bfe30611ab75a02a291a (patch) | |
tree | 49d0ff343890818bbebec687733fa5aa18497899 /railties/lib | |
parent | 2fe70c180351e87801179e8404d1582d7da25645 (diff) | |
download | rails-d84b2f37d018621aea99bfe30611ab75a02a291a.tar.gz rails-d84b2f37d018621aea99bfe30611ab75a02a291a.tar.bz2 rails-d84b2f37d018621aea99bfe30611ab75a02a291a.zip |
Fix tests.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/engine.rb | 37 | ||||
-rw-r--r-- | railties/lib/rails/tasks/railties.rake | 2 |
2 files changed, 25 insertions, 14 deletions
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! |