mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Use Rails 3.1 change method in model generator
This commit is contained in:
committed by
Aaron Patterson
parent
40afcade0d
commit
9e64dfad0d
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user