mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
dfdb9f738e
Signed-off-by: Joshua Peek <josh@joshpeek.com>
32 lines
1 KiB
Ruby
32 lines
1 KiB
Ruby
require 'generators/generator_test_helper'
|
|
|
|
class RailsModelGeneratorTest < GeneratorTestCase
|
|
|
|
def test_model_generates_resources
|
|
run_generator('model', %w(Product name:string))
|
|
|
|
assert_generated_model_for :product
|
|
assert_generated_fixtures_for :products
|
|
assert_generated_migration :create_products
|
|
end
|
|
|
|
def test_model_skip_migration_skips_migration
|
|
run_generator('model', %w(Product name:string --skip-migration))
|
|
|
|
assert_generated_model_for :product
|
|
assert_generated_fixtures_for :products
|
|
assert_skipped_migration :create_products
|
|
end
|
|
|
|
def test_model_with_attributes_generates_resources_with_attributes
|
|
run_generator('model', %w(Product name:string supplier_id:integer created_at:timestamp))
|
|
|
|
assert_generated_model_for :product
|
|
assert_generated_fixtures_for :products
|
|
assert_generated_migration :create_products do |t|
|
|
assert_generated_column t, :name, :string
|
|
assert_generated_column t, :supplier_id, :integer
|
|
assert_generated_column t, :created_at, :timestamp
|
|
end
|
|
end
|
|
end
|