1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ensure non timestamped migrations are generated properly.

This commit is contained in:
José Valim 2009-07-13 22:26:58 +02:00
parent 25647f7021
commit a5ab030ae4
2 changed files with 14 additions and 1 deletions

View file

@ -51,7 +51,9 @@ module Rails
end
def current_migration_number(dirname) #:nodoc:
migration_lookup_at(dirname).collect{ |f| f.split("_").first.to_i }.max
migration_lookup_at(dirname).collect do |file|
File.basename(file).split("_").first.to_i
end.max.to_i
end
def next_migration_number(dirname) #:nodoc:

View file

@ -52,6 +52,17 @@ class ModelGeneratorTest < GeneratorsTestCase
end
end
def test_migration_without_timestamps
ActiveRecord::Base.timestamped_migrations = false
run_generator ["account"]
assert_file "db/migrate/001_create_accounts.rb", /class CreateAccounts < ActiveRecord::Migration/
run_generator ["project"]
assert_file "db/migrate/002_create_projects.rb", /class CreateProjects < ActiveRecord::Migration/
ensure
ActiveRecord::Base.timestamped_migrations = true
end
def test_model_with_references_attribute_generates_belongs_to_associations
run_generator ["product", "name:string", "supplier_id:references"]
assert_file "app/models/product.rb", /belongs_to :supplier/