Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add task foo:install (where foo is plugin) as a shortcutinstall:migra…

…tions and foo:install:assets
  • Loading branch information...
commit 43215de208a6feabdbc5f4ec29551beef4f89885 1 parent 959f857
@drogus drogus authored josevalim committed
View
6 railties/lib/rails/engine.rb
@@ -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
View
24 railties/test/railties/shared_tests.rb
@@ -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 }"
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.