Don't stomp on test/fixtures, when dumping the database to YAML

Tweak the manage_fixtures plugin to use the dump/fixtures instead of test/fixtures directory.
This commit is contained in:
Jacques Distler 2007-09-23 01:50:40 -05:00
parent 1259e16a4a
commit 06d96349e4

View file

@ -1,6 +1,6 @@
def write_yaml_fixtures_to_file(sql, fixture_name)
i = "000"
File.open("#{RAILS_ROOT}/test/fixtures/#{fixture_name}.yml", 'w' ) do |file|
File.open("#{RAILS_ROOT}/dump/fixtures/#{fixture_name}.yml", 'w' ) do |file|
data = ActiveRecord::Base.connection.select_all(sql)
file.write data.inject({}) { |hash, record|
hash["#{fixture_name}_#{i.succ!}"] = record
@ -10,7 +10,7 @@ def write_yaml_fixtures_to_file(sql, fixture_name)
end
def import_table_fixture(table)
filename = File.join(RAILS_ROOT,'test','fixtures',table + '.yml')
filename = File.join(RAILS_ROOT,'dump','fixtures',table + '.yml')
success = Hash.new
records = YAML::load( File.open(filename))
@ -43,7 +43,7 @@ def import_table_fixture(table)
end
def import_model_fixture(model)
filename = File.join(RAILS_ROOT,'test','fixtures',model.tableize + '.yml')
filename = File.join(RAILS_ROOT,'dump','fixtures',model.tableize + '.yml')
success = Hash.new
records = YAML::load( File.open(filename))
@model = Class.const_get(model)