public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
rake db:fixtures:load and db:fixtures:identify now accept a FIXTURES_PATH option 
eg. "rake db:fixtures:load FIXTURES_PATH=spec/fixtures"

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#792 state:committed]
matthewrudy (author)
Sat Aug 09 09:04:54 -0700 2008
NZKoz (committer)
Sat Aug 09 09:36:40 -0700 2008
commit  eb4668b26ad4aacf79488d2bee553e9452971c35
tree    bc7ee2f508c073b430bc34f285aaac4e6d59593a
parent  b2630502a0525e5965d4eff283e3d2613cd1ca19
...
182
183
184
185
 
186
187
188
189
 
190
191
192
...
194
195
196
197
 
198
199
200
...
203
204
205
206
 
 
207
208
209
...
182
183
184
 
185
186
187
188
 
189
190
191
192
...
194
195
196
 
197
198
199
200
...
203
204
205
 
206
207
208
209
210
0
@@ -182,11 +182,11 @@ namespace :db do
0
   end
0
 
0
   namespace :fixtures do
0
-    desc "Load fixtures into the current environment's database.  Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
0
+    desc "Load fixtures into the current environment's database.  Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
0
     task :load => :environment do
0
       require 'active_record/fixtures'
0
       ActiveRecord::Base.establish_connection(Rails.env)
0
-      base_dir = File.join(Rails.root, 'test', 'fixtures')
0
+      base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
0
       fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
0
 
0
       (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
0
@@ -194,7 +194,7 @@ namespace :db do
0
       end
0
     end
0
 
0
-    desc "Search for a fixture given a LABEL or ID."
0
+    desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
0
     task :identify => :environment do
0
       require "active_record/fixtures"
0
 
0
@@ -203,7 +203,8 @@ namespace :db do
0
 
0
       puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label
0
 
0
-      Dir["#{RAILS_ROOT}/test/fixtures/**/*.yml"].each do |file|
0
+      base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
0
+      Dir["#{base_dir}/**/*.yml"].each do |file|
0
         if data = YAML::load(ERB.new(IO.read(file)).result)
0
           data.keys.each do |key|
0
             key_id = Fixtures.identify(key)

Comments