diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-13 22:26:58 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-07-13 22:26:58 +0200 |
commit | a5ab030ae4ca7496fc9167c9ffa4717be130b235 (patch) | |
tree | 8563440cc27b86f015ba35a1030a5d1134fa4a67 | |
parent | 25647f70215e38635d16038e71f47730f2717021 (diff) | |
download | rails-a5ab030ae4ca7496fc9167c9ffa4717be130b235.tar.gz rails-a5ab030ae4ca7496fc9167c9ffa4717be130b235.tar.bz2 rails-a5ab030ae4ca7496fc9167c9ffa4717be130b235.zip |
Ensure non timestamped migrations are generated properly.
-rw-r--r-- | railties/lib/generators/migration.rb | 4 | ||||
-rw-r--r-- | railties/test/generators/model_generator_test.rb | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/railties/lib/generators/migration.rb b/railties/lib/generators/migration.rb index 5596cc274c..7014e6deda 100644 --- a/railties/lib/generators/migration.rb +++ b/railties/lib/generators/migration.rb @@ -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: diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index 62e1c5ab9e..85aa2cc145 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -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/ |