diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2011-01-12 15:18:45 -0800 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-06 18:45:42 -0200 |
commit | a3f5d7159d00a0c7c7d79d15652028ac13df30af (patch) | |
tree | 53b18592ac740b729ba6a6ff855c145182f52458 | |
parent | 10cab35d3b9e87e4b182162f7783c220cf2a937f (diff) | |
download | rails-a3f5d7159d00a0c7c7d79d15652028ac13df30af.tar.gz rails-a3f5d7159d00a0c7c7d79d15652028ac13df30af.tar.bz2 rails-a3f5d7159d00a0c7c7d79d15652028ac13df30af.zip |
fix db:fixtures:load with FIXTURES specified [#6061 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 4 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 49d4b8f76b..ff36814684 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -296,8 +296,8 @@ db_namespace = namespace :db do base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures') fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir["#{fixtures_dir}/**/*.{yml,csv}"]).each do |fixture_file| - Fixtures.create_fixtures(fixtures_dir, fixture_file[(fixtures_dir.size + 1)..-5]) + (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir["#{fixtures_dir}/**/*.{yml,csv}"].map {|f| f[(fixtures_dir.size + 1)..-5] }).each do |fixture_file| + Fixtures.create_fixtures(fixtures_dir, fixture_file) end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 822a6bf032..59e5ef4dee 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -82,5 +82,22 @@ module ApplicationTests assert_match /remove_column\("users", :email\)/, output assert_match /AddEmailToUsers: reverted/, output end + + def test_loading_specific_fixtures + Dir.chdir(app_path) do + `rails generate model user username:string password:string` + `rails generate model product name:string` + `rake db:migrate` + end + + require "#{rails_root}/config/environment" + + # loading a specific fixture + errormsg = Dir.chdir(app_path) { `rake db:fixtures:load FIXTURES=products` } + assert $?.success?, errormsg + + assert_equal 2, ::AppTemplate::Application::Product.count + assert_equal 0, ::AppTemplate::Application::User.count + end end end |