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

Use Rails 3.1 change method in model generator

This commit is contained in:
Prem Sichanugrist 2011-01-01 01:15:42 +07:00 committed by Aaron Patterson
parent 40afcade0d
commit 9e64dfad0d
2 changed files with 3 additions and 11 deletions

View file

@ -1,5 +1,5 @@
class <%= migration_class_name %> < ActiveRecord::Migration
def up
def change
create_table :<%= table_name %> do |t|
<% for attribute in attributes -%>
t.<%= attribute.type %> :<%= attribute.name %>
@ -13,8 +13,4 @@ class <%= migration_class_name %> < ActiveRecord::Migration
add_index :<%= table_name %>, :<%= attribute.name %>_id
<% end -%>
end
def down
drop_table :<%= table_name %>
end
end

View file

@ -99,15 +99,11 @@ class ModelGeneratorTest < Rails::Generators::TestCase
run_generator ["product", "name:string", "supplier_id:integer"]
assert_migration "db/migrate/create_products.rb" do |m|
assert_method :up, m do |up|
assert_method :change, m do |up|
assert_match /create_table :products/, up
assert_match /t\.string :name/, up
assert_match /t\.integer :supplier_id/, up
end
assert_method :down, m do |down|
assert_match /drop_table :products/, down
end
end
end
@ -141,7 +137,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase
run_generator ["account", "--no-timestamps"]
assert_migration "db/migrate/create_accounts.rb" do |m|
assert_method :up, m do |up|
assert_method :change, m do |up|
assert_no_match /t.timestamps/, up
end
end