mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added db:fixtures:identity as a way of locating what ID a foxy fixture was assigned (closes #10332) [jbarnette]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8248 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
cc86875a14
commit
e47392b81f
2 changed files with 24 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Added db:fixtures:identity as a way of locating what ID a foxy fixture was assigned #10332 [jbarnette]
|
||||
|
||||
* Generated fixtures should not specify ids since theyre expected to be foxy fixtures #10330 [jbarnette]
|
||||
|
||||
|
||||
|
|
|
@ -134,6 +134,28 @@ namespace :db do
|
|||
Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
|
||||
end
|
||||
end
|
||||
|
||||
desc "Search for a fixture given a LABEL or ID."
|
||||
task :identify => :environment do
|
||||
require "active_record/fixtures"
|
||||
|
||||
label, id = ENV["LABEL"], ENV["ID"]
|
||||
raise "LABEL or ID required" if label.blank? && id.blank?
|
||||
|
||||
puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label
|
||||
|
||||
Dir["#{RAILS_ROOT}/test/fixtures/**/*.yml"].each do |file|
|
||||
if data = YAML::load(ERB.new(IO.read(file)).result)
|
||||
data.keys.each do |key|
|
||||
key_id = Fixtures.identify(key)
|
||||
|
||||
if key == label || key_id == id.to_i
|
||||
puts "#{file}: #{key} (#{key_id})"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :schema do
|
||||
|
|
Loading…
Reference in a new issue