Skip to content

Commit

Permalink
Add task foo:install (where foo is plugin) as a shortcutinstall:migra…
Browse files Browse the repository at this point in the history
…tions and foo:install:assets
  • Loading branch information
drogus authored and josevalim committed Oct 14, 2010
1 parent 959f857 commit 43215de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions railties/lib/rails/engine.rb
Expand Up @@ -538,6 +538,12 @@ def load_seed
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
Expand Down
24 changes: 24 additions & 0 deletions railties/test/railties/shared_tests.rb
Expand Up @@ -10,6 +10,28 @@ def app
@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 }"
Expand All @@ -19,7 +41,9 @@ def test_copying_assets
`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
Expand Down

0 comments on commit 43215de

Please sign in to comment.