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:
parent
25647f7021
commit
a5ab030ae4
2 changed files with 14 additions and 1 deletions
|
@ -51,7 +51,9 @@ module Rails
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_migration_number(dirname) #:nodoc:
|
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
|
end
|
||||||
|
|
||||||
def next_migration_number(dirname) #:nodoc:
|
def next_migration_number(dirname) #:nodoc:
|
||||||
|
|
|
@ -52,6 +52,17 @@ class ModelGeneratorTest < GeneratorsTestCase
|
||||||
end
|
end
|
||||||
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
|
def test_model_with_references_attribute_generates_belongs_to_associations
|
||||||
run_generator ["product", "name:string", "supplier_id:references"]
|
run_generator ["product", "name:string", "supplier_id:references"]
|
||||||
assert_file "app/models/product.rb", /belongs_to :supplier/
|
assert_file "app/models/product.rb", /belongs_to :supplier/
|
||||||
|
|
Loading…
Reference in a new issue