From 556d8941905faf50fcc5fcd051d0c0c998ebbd11 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sat, 20 Sep 2008 18:39:20 +0200 Subject: [PATCH] temporary fix for db:migrate:all rake task which broke with rake 0.8.2 --- vendor/plugins/engines/Rakefile | 46 +++++++++++------------ vendor/plugins/engines/tasks/engines.rake | 38 +++++++++---------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/vendor/plugins/engines/Rakefile b/vendor/plugins/engines/Rakefile index 4067f5ef7..cb0f36780 100644 --- a/vendor/plugins/engines/Rakefile +++ b/vendor/plugins/engines/Rakefile @@ -28,13 +28,13 @@ task :cruise do puts "Running all tests in test harness" ['db:migrate', 'test', 'test:plugins'].each do |t| Rake::Task[t].invoke - end + end end task :clean => [:clobber_doc, "test:clean"] namespace :test do - + # Yields a block with STDOUT and STDERR silenced. If you *really* want # to output something, the block is yielded with the original output # streams, i.e. @@ -50,8 +50,8 @@ namespace :test do streams = [STDOUT, STDERR] actual_stdout = STDOUT.dup actual_stderr = STDERR.dup - streams.each do |s| - s.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') + streams.each do |s| + s.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') s.sync = true end yield actual_stdout, actual_stderr @@ -59,30 +59,30 @@ namespace :test do STDOUT.reopen(actual_stdout) STDERR.reopen(actual_stderr) end - + def test_app_dir File.join(File.dirname(__FILE__), 'test_app') end - + def run(cmd) system(cmd) || raise("failed running '#{cmd}'") end - + desc 'Remove the test application' task :clean do FileUtils.rm_r(test_app_dir) if File.exist?(test_app_dir) end - + desc 'Build the test rails application (use RAILS=[edge,] to test against specific version)' task :generate_app do silence do |out, err| - + out.puts "> Creating test application at #{test_app_dir}" if ENV['RAILS'] vendor_dir = File.join(test_app_dir, 'vendor') FileUtils.mkdir_p vendor_dir - + if ENV['RAILS'] == 'edge' out.puts " Cloning rails from GitHub" run "cd #{vendor_dir} && git clone --depth 1 git://github.com/rails/rails.git" @@ -92,7 +92,7 @@ namespace :test do else raise "Couldn't build test application from '#{ENV['RAILS']}'" end - + out.puts " generating rails default directory structure" run "ruby #{File.join(vendor_dir, 'rails', 'railties', 'bin', 'rails')} #{test_app_dir}" else @@ -100,18 +100,18 @@ namespace :test do out.puts " building rails using the 'rails' command (rails version: #{version})" run "rails #{test_app_dir}" end - + # get the database config and schema in place out.puts " writing database.yml" require 'yaml' File.open(File.join(test_app_dir, 'config', 'database.yml'), 'w') do |f| - f.write(%w(development test).inject({}) do |h, env| + f.write(%w(development test).inject({}) do |h, env| h[env] = {"adapter" => "sqlite3", "database" => "engines_#{env}.sqlite3"} ; h end.to_yaml) end end end - + # We can't link the plugin, as it needs to be present for script/generate to find # the plugin generator. # TODO: find and +1/create issue for loading generators from symlinked plugins @@ -125,13 +125,13 @@ namespace :test do FileUtils.cp_r(file, engines_plugin) end end - + def insert_line(line, options) line = line + "\n" target_file = File.join(test_app_dir, options[:into]) lines = File.readlines(target_file) return if lines.include?(line) - + if options[:after] if options[:after].is_a?(String) after_line = options[:after] + "\n" @@ -147,24 +147,24 @@ namespace :test do end File.open(target_file, 'w') { |f| f.write lines.join } end - + def mirror_test_files(src, dest=nil) destination_dir = File.join(*([test_app_dir, dest].compact)) FileUtils.cp_r(File.join(File.dirname(__FILE__), 'test', src), destination_dir) end - + desc 'Update the plugin and tests files in the test application from the plugin' task :mirror_engine_files => [:test_app, :copy_engines_plugin] do puts "> Modifying default config files to load engines plugin" insert_line("require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot')", :into => 'config/environment.rb', :after => "require File.join(File.dirname(__FILE__), 'boot')") - - insert_line('map.from_plugin :test_routing', :into => 'config/routes.rb', + + insert_line('map.from_plugin :test_routing', :into => 'config/routes.rb', :after => /\AActionController::Routing::Routes/) - + insert_line("require 'engines_test_helper'", :into => 'test/test_helper.rb') - + puts "> Mirroring test application files into #{test_app_dir}" mirror_test_files('app') mirror_test_files('lib') @@ -172,7 +172,7 @@ namespace :test do mirror_test_files('unit', 'test') mirror_test_files('functional', 'test') end - + desc 'Prepare the engines test environment' file :test_app do puts "> Recreating test application" diff --git a/vendor/plugins/engines/tasks/engines.rake b/vendor/plugins/engines/tasks/engines.rake index b0a85d1f6..2c56fcd6f 100644 --- a/vendor/plugins/engines/tasks/engines.rake +++ b/vendor/plugins/engines/tasks/engines.rake @@ -5,7 +5,7 @@ unless Rake::TaskManager.methods.include?(:redefine_task) module Rake module TaskManager - + def redefine_task(task_class, args, &block) task_name, deps = resolve_args([args]) task_name = task_class.scope_name(@scope, task_name) @@ -18,7 +18,7 @@ unless Rake::TaskManager.methods.include?(:redefine_task) task.enhance(deps, &block) task end - + end class Task class << self @@ -34,9 +34,9 @@ namespace :db do namespace :migrate do desc 'Migrate database and plugins to current status.' task :all => [ 'db:migrate', 'db:migrate:plugins' ] - + desc 'Migrate plugins to current status.' - task({:plugins => :environment}, :version) do |task, args| + task({:plugins => :environment}) do |task, args| version = args[:version] || ENV['VERSION'] Engines.plugins.each do |plugin| next unless File.exists? plugin.migration_directory @@ -46,7 +46,7 @@ namespace :db do end desc 'Migrate a specified plugin.' - task({:plugin => :environment}, :name, :version) do |task, args| + task({:plugin => :environment}) do |task, args| name = args[:name] || ENV['NAME'] if plugin = Engines.plugins[name] version = args[:version] || ENV['VERSION'] @@ -55,30 +55,30 @@ namespace :db do else puts "Plugin #{name} does not exist." end - end + end end end -namespace :db do +namespace :db do namespace :fixtures do namespace :plugins do - + desc "Load plugin fixtures into the current environment's database." task :load => :environment do require 'active_record/fixtures' ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) - Dir.glob(File.join(RAILS_ROOT, 'vendor', 'plugins', ENV['PLUGIN'] || '**', + Dir.glob(File.join(RAILS_ROOT, 'vendor', 'plugins', ENV['PLUGIN'] || '**', 'test', 'fixtures', '*.yml')).each do |fixture_file| Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) end end - + end end end -# this is just a modification of the original task in railties/lib/tasks/documentation.rake, +# this is just a modification of the original task in railties/lib/tasks/documentation.rake, # because the default task doesn't support subdirectories like /app or # /component. These tasks now include every file under a plugin's code paths (see # Plugin#code_paths). @@ -105,7 +105,7 @@ namespace :doc do files.include("#{plugin_base}/{#{Engines.plugins[plugin].code_paths.join(",")}}/**/*.rb") end if File.exists?("#{plugin_base}/README") - files.include("#{plugin_base}/README") + files.include("#{plugin_base}/README") options << "--main '#{plugin_base}/README'" end files.include("#{plugin_base}/CHANGELOG") if File.exists?("#{plugin_base}/CHANGELOG") @@ -144,25 +144,25 @@ Report any issues on http://dev.rails-engines.org. Thanks! -~===============( ... as you were ... )============================~-} end - + namespace :plugins do desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)" - task :all => [:warn_about_multiple_plugin_testing_with_engines, + task :all => [:warn_about_multiple_plugin_testing_with_engines, :units, :functionals, :integration] - + desc "Run all plugin unit tests" Rake::TestTask.new(:units => :setup_plugin_fixtures) do |t| t.pattern = "vendor/plugins/#{ENV['PLUGIN'] || "**"}/test/unit/**/*_test.rb" t.verbose = true end - + desc "Run all plugin functional tests" Rake::TestTask.new(:functionals => :setup_plugin_fixtures) do |t| t.pattern = "vendor/plugins/#{ENV['PLUGIN'] || "**"}/test/functional/**/*_test.rb" t.verbose = true end - + desc "Integration test engines" Rake::TestTask.new(:integration => :setup_plugin_fixtures) do |t| t.pattern = "vendor/plugins/#{ENV['PLUGIN'] || "**"}/test/integration/**/*_test.rb" @@ -173,8 +173,8 @@ Report any issues on http://dev.rails-engines.org. Thanks! task :setup_plugin_fixtures => :environment do Engines::Testing.setup_plugin_fixtures end - + # Patch the default plugin testing task to have setup_plugin_fixtures as a prerequisite Rake::Task["test:plugins"].prerequisites << "test:plugins:setup_plugin_fixtures" - end + end end \ No newline at end of file