aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-07-26 14:21:30 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:09 +0200
commit43a2aef3165793d9265aea1257063a60766f2226 (patch)
tree15ddf97940fdd7cf94c5db7a0ffb59dad713b5af /railties
parent75f8ac6ea71e4b2337f870b91ac05df98f33a8d2 (diff)
downloadrails-43a2aef3165793d9265aea1257063a60766f2226.tar.gz
rails-43a2aef3165793d9265aea1257063a60766f2226.tar.bz2
rails-43a2aef3165793d9265aea1257063a60766f2226.zip
rake db:copy_migrations task, which copies railties migrations into application's db/migrate directory
Diffstat (limited to 'railties')
-rw-r--r--railties/test/railties/shared_tests.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb
index ce7c55c11c..6aae17c237 100644
--- a/railties/test/railties/shared_tests.rb
+++ b/railties/test/railties/shared_tests.rb
@@ -10,6 +10,55 @@ module RailtiesTest
@app ||= Rails.application
end
+ def test_copying_migrations
+ @plugin.write "db/migrate/1_create_users.rb", <<-RUBY
+ class CreateUsers < ActiveRecord::Migration
+ end
+ RUBY
+
+ @plugin.write "db/migrate/2_add_last_name_to_users.rb", <<-RUBY
+ class AddLastNameToUsers < ActiveRecord::Migration
+ end
+ RUBY
+
+ app_file "db/migrate/1_create_sessions.rb", <<-RUBY
+ class CreateSessions < ActiveRecord::Migration
+ end
+ RUBY
+
+ yaffle = plugin "acts_as_yaffle", "::LEVEL = config.log_level" do |plugin|
+ plugin.write "lib/acts_as_yaffle.rb", "class ActsAsYaffle; end"
+ end
+
+ yaffle.write "db/migrate/1_create_yaffles.rb", <<-RUBY
+ class CreateYaffles < ActiveRecord::Migration
+ end
+ RUBY
+
+ add_to_config "ActiveRecord::Base.timestamped_migrations = false"
+
+ Dir.chdir(app_path) do
+ output = `rake db:copy_migrations FROM=bukkits`
+
+ assert File.exists?("#{app_path}/db/migrate/2_create_users.bukkits.rb")
+ assert File.exists?("#{app_path}/db/migrate/3_add_last_name_to_users.bukkits.rb")
+ assert_match /2_create_users/, output
+ assert_match /3_add_last_name_to_users/, output
+ assert_equal 3, Dir["#{app_path}/db/migrate/*.rb"].length
+
+ output = `rake db:copy_migrations`
+
+ assert File.exists?("#{app_path}/db/migrate/4_create_yaffles.acts_as_yaffle.rb")
+ assert_match /4_create_yaffles/, output
+
+ migrations_count = Dir["#{app_path}/db/migrate/*.rb"].length
+ output = `rake db:copy_migrations`
+
+ assert_equal migrations_count, Dir["#{app_path}/db/migrate/*.rb"].length
+ assert_match /No migrations were copied/, output
+ end
+ end
+
def test_puts_its_lib_directory_on_load_path
boot_rails
require "another"