Manage_Fixtures
Make sure manage_fixtures plugin doesn't mess with fixtures in test/fixtures. Also, a slightly more elegant version of the REXML version test.
This commit is contained in:
parent
38ae064b8a
commit
f101ee9a21
|
@ -3,9 +3,9 @@
|
||||||
####
|
####
|
||||||
|
|
||||||
# Make sure we are using the latest rexml
|
# Make sure we are using the latest rexml
|
||||||
system_rexml_version = `ruby -r 'rexml/rexml' -e 'p REXML::VERSION'`.split('.').collect {|n| n.to_i}
|
rexml_versions = ['', 'vendor/plugins/rexml/lib/'].collect { |v|
|
||||||
bundled_rexml_version = `ruby -r 'vendor/plugins/rexml/lib/rexml/rexml' -e 'p REXML::VERSION'`.split('.').collect {|n| n.to_i}
|
`ruby -r #{v + 'rexml/rexml'} -e 'p REXML::VERSION'`.split('.').collect {|n| n.to_i} }
|
||||||
$:.unshift('vendor/plugins/rexml/lib') if (system_rexml_version <=> bundled_rexml_version) == -1
|
$:.unshift('vendor/plugins/rexml/lib') if (rexml_versions[0] <=> rexml_versions[1]) == -1
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), 'boot')
|
require File.join(File.dirname(__FILE__), 'boot')
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace :db do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'use rake db:fixtures:export_for_tables TABLES=foos[,bars,lands] Create YAML test fixtures for a specific table(s) from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
desc 'use rake db:fixtures:export_for_tables TABLES=foos[,bars,lands] Create YAML dump fixtures for a specific table(s) from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
||||||
namespace :db do
|
namespace :db do
|
||||||
namespace :fixtures do
|
namespace :fixtures do
|
||||||
task :export_for_tables => :environment do
|
task :export_for_tables => :environment do
|
||||||
|
@ -24,7 +24,7 @@ namespace :db do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
desc ' Create YAML test fixtures from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
desc ' Create YAML dump fixtures from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
||||||
namespace :db do
|
namespace :db do
|
||||||
namespace :fixtures do
|
namespace :fixtures do
|
||||||
task :export_all => :environment do
|
task :export_all => :environment do
|
||||||
|
@ -33,7 +33,7 @@ namespace :db do
|
||||||
ActiveRecord::Base.establish_connection
|
ActiveRecord::Base.establish_connection
|
||||||
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
|
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
|
||||||
i = "000"
|
i = "000"
|
||||||
File.open("#{RAILS_ROOT}/test/fixtures/#{table_name}.yml", 'w' ) do |file|
|
File.open("#{RAILS_ROOT}/dump/fixtures/#{table_name}.yml", 'w' ) do |file|
|
||||||
write_yaml_fixtures_to_file(sql % table_name, table_name)
|
write_yaml_fixtures_to_file(sql % table_name, table_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ namespace :db do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'use rake db:fixtures:import_for_models MODELS=Foo[,Bar,Land] to import the YAML test fixtures for a specific models from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
desc 'use rake db:fixtures:import_for_models MODELS=Foo[,Bar,Land] to import the YAML dump fixtures for a specific models from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
||||||
namespace :db do
|
namespace :db do
|
||||||
namespace :fixtures do
|
namespace :fixtures do
|
||||||
task :import_for_models => :environment do
|
task :import_for_models => :environment do
|
||||||
|
@ -55,7 +55,7 @@ namespace :db do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
desc 'use rake db:fixtures:import_for_tables TABLES=foos[,bars,lands] to import the YAML test fixtures for a specific tables from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
desc 'use rake db:fixtures:import_for_tables TABLES=foos[,bars,lands] to import the YAML dump fixtures for a specific tables from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
||||||
namespace :db do
|
namespace :db do
|
||||||
namespace :fixtures do
|
namespace :fixtures do
|
||||||
task :import_for_tables => :environment do
|
task :import_for_tables => :environment do
|
||||||
|
@ -68,13 +68,13 @@ namespace :db do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'use rake db:fixtures:import_all to import all YAML test fixtures for all of the tables from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
desc 'use rake db:fixtures:import_all to import all YAML dump fixtures for all of the tables from data in an existing database. Defaults to development database. Set RAILS_ENV to override. '
|
||||||
namespace :db do
|
namespace :db do
|
||||||
namespace :fixtures do
|
namespace :fixtures do
|
||||||
task :import_all => :environment do
|
task :import_all => :environment do
|
||||||
ActiveRecord::Base.establish_connection
|
ActiveRecord::Base.establish_connection
|
||||||
Dir.glob(File.join(RAILS_ROOT,'test','fixtures',"*.yml")).each do |f|
|
Dir.glob(File.join(RAILS_ROOT,'dump','fixtures',"*.yml")).each do |f|
|
||||||
table_name = f.gsub(File.join(RAILS_ROOT,'test','fixtures', ''), '').gsub('.yml', '')
|
table_name = f.gsub(File.join(RAILS_ROOT,'dump','fixtures', ''), '').gsub('.yml', '')
|
||||||
import_table_fixture(table_name)
|
import_table_fixture(table_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue