added custom-name to generator to avoid uninitialized constant error

This commit is contained in:
Bastian Wegge 2016-09-19 22:41:02 +02:00
parent fc8b5efaa8
commit 673b6f7aba
2 changed files with 6 additions and 1 deletions

View File

@ -12,7 +12,7 @@ module ActiveRecord
def copy_aasm_migration
if model_exists?
migration_template "migration_existing.rb", "db/migrate/add_aasm_state_to_#{table_name}.rb"
migration_template "migration_existing.rb", "db/migrate/add_#{column_name}_to_#{table_name}.rb"
else
migration_template "migration.rb", "db/migrate/aasm_create_#{table_name}.rb"
end

View File

@ -36,4 +36,9 @@ describe ActiveRecord::Generators::AASMGenerator, type: :generator do
assert_migration "db/migrate/add_aasm_state_to_jobs.rb"
end
it "add custom aasm_column in existing model" do
run_generator %w(job state)
assert_migration "db/migrate/add_state_to_jobs.rb"
end
end