diff options
author | José Valim <jose.valim@gmail.com> | 2011-10-18 10:09:13 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-10-18 10:09:13 -0700 |
commit | 71325bb3084c8e5a8542510c32441f34b2811a92 (patch) | |
tree | d5d4dc4e9aa0305ccfb6d93a825de36d2f240418 | |
parent | 76af2818a6b729955ad799b5346da7ed115440ea (diff) | |
parent | 40d1555091433d827e23e92e9f816e11a2db679b (diff) | |
download | rails-71325bb3084c8e5a8542510c32441f34b2811a92.tar.gz rails-71325bb3084c8e5a8542510c32441f34b2811a92.tar.bz2 rails-71325bb3084c8e5a8542510c32441f34b2811a92.zip |
Merge pull request #3350 from whilefalse/rake_environment_in_engines
Added environment rake task to engines
-rw-r--r-- | railties/lib/rails/tasks/engine.rake | 1 | ||||
-rw-r--r-- | railties/test/railties/shared_tests.rb | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/railties/lib/rails/tasks/engine.rake b/railties/lib/rails/tasks/engine.rake index 2152e811f5..eea8abe7d2 100644 --- a/railties/lib/rails/tasks/engine.rake +++ b/railties/lib/rails/tasks/engine.rake @@ -2,6 +2,7 @@ task "load_app" do namespace :app do load APP_RAKEFILE end + task :environment => "app:environment" if !defined?(ENGINE_PATH) || !ENGINE_PATH ENGINE_PATH = find_engine_path(APP_RAKEFILE) diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb index 21fde49ff7..7653e52d26 100644 --- a/railties/test/railties/shared_tests.rb +++ b/railties/test/railties/shared_tests.rb @@ -21,6 +21,23 @@ module RailtiesTest assert_match "alert()", last_response.body end + def test_rake_environment_can_be_called_in_the_engine_or_plugin + boot_rails + + @plugin.write "Rakefile", <<-RUBY + APP_RAKEFILE = '#{app_path}/Rakefile' + load 'rails/tasks/engine.rake' + task :foo => :environment do + puts "Task ran" + end + RUBY + + Dir.chdir(@plugin.path) do + output = `bundle exec rake foo` + assert_match "Task ran", output + end + end + def test_copying_migrations @plugin.write "db/migrate/1_create_users.rb", <<-RUBY class CreateUsers < ActiveRecord::Migration |