update migration generator test to rely on config table name

should we do this though? i can see an argument where we actually keep the test as is because the default `table_name` is still `key_values` and we're trying to maintain original usage expectations with this PR
This commit is contained in:
Sarah Aladetan 2019-12-09 12:39:35 -08:00
Родитель d939c8ac0b
Коммит e8acbedb52
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -17,24 +17,25 @@ class GithubDSActiveRecordGeneratorTest < Rails::Generators::TestCase
else
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
table_name = "key_values"
assert_migration "db/migrate/create_key_values_table.rb", <<-EOM
class CreateKeyValuesTable < ActiveRecord::Migration#{migration_version}
def self.up
create_table :key_values do |t|
create_table :#{table_name} do |t|
t.string :key, :null => false
t.binary :value, :null => false
t.datetime :expires_at, :null => true
t.timestamps :null => false
end
add_index :key_values, :key, :unique => true
add_index :key_values, :expires_at
add_index :#{table_name}, :key, :unique => true
add_index :#{table_name}, :expires_at
change_column :key_values, :id, "bigint(20) NOT NULL AUTO_INCREMENT"
change_column :#{table_name}, :id, "bigint(20) NOT NULL AUTO_INCREMENT"
end
def self.down
drop_table :key_values
drop_table :#{table_name}
end
end
EOM