mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add task foo:install (where foo is plugin) as a shortcutinstall:migrations and foo:install:assets
This commit is contained in:
committed by
José Valim
parent
959f8576f2
commit
43215de208
@@ -538,6 +538,12 @@ module Rails
|
||||
next if self.is_a?(Rails::Application)
|
||||
|
||||
namespace railtie_name do
|
||||
desc "Shortcut for running both rake #{railtie_name}:install:migrations and #{railtie_name}:install:assets"
|
||||
task :install do
|
||||
Rake::Task["#{railtie_name}:install:migrations"].invoke
|
||||
Rake::Task["#{railtie_name}:install:assets"].invoke
|
||||
end
|
||||
|
||||
namespace :install do
|
||||
# TODO Add assets copying to this list
|
||||
# TODO Skip this if there is no paths["db/migrate"] for the engine
|
||||
|
||||
@@ -10,6 +10,28 @@ module RailtiesTest
|
||||
@app ||= Rails.application
|
||||
end
|
||||
|
||||
def test_install_migrations_and_assets
|
||||
@plugin.write "public/javascripts/foo.js", "doSomething()"
|
||||
|
||||
@plugin.write "db/migrate/1_create_users.rb", <<-RUBY
|
||||
class CreateUsers < ActiveRecord::Migration
|
||||
end
|
||||
RUBY
|
||||
|
||||
app_file "db/migrate/1_create_sessions.rb", <<-RUBY
|
||||
class CreateSessions < ActiveRecord::Migration
|
||||
end
|
||||
RUBY
|
||||
|
||||
add_to_config "ActiveRecord::Base.timestamped_migrations = false"
|
||||
|
||||
Dir.chdir(app_path) do
|
||||
`rake bukkits:install`
|
||||
assert File.exists?("#{app_path}/db/migrate/2_create_users.rb")
|
||||
assert File.exists?(app_path("public/bukkits/javascripts/foo.js"))
|
||||
end
|
||||
end
|
||||
|
||||
def test_copying_assets
|
||||
@plugin.write "public/javascripts/foo.js", "doSomething()"
|
||||
@plugin.write "public/stylesheets/foo.css", "h1 { font-size: 10000px }"
|
||||
@@ -19,7 +41,9 @@ module RailtiesTest
|
||||
`rake bukkits:install:assets --trace`
|
||||
|
||||
assert File.exists?(app_path("public/bukkits/javascripts/foo.js"))
|
||||
assert_equal "doSomething()\n", File.read(app_path("public/bukkits/javascripts/foo.js"))
|
||||
assert File.exists?(app_path("public/bukkits/stylesheets/foo.css"))
|
||||
assert_equal "h1 { font-size: 10000px }\n", File.read(app_path("public/bukkits/stylesheets/foo.css"))
|
||||
assert File.exists?(app_path("public/bukkits/images/img.png"))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user