aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-12-01 20:53:15 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-12-01 20:53:15 +0000
commite47392b81faf9e96070379a18d525e25bd60678b (patch)
treea7e2090ac2a95962537e65de3cb09eaae35ac964 /railties
parentcc86875a14dda3dfb405d609ce031bea93f090b3 (diff)
downloadrails-e47392b81faf9e96070379a18d525e25bd60678b.tar.gz
rails-e47392b81faf9e96070379a18d525e25bd60678b.tar.bz2
rails-e47392b81faf9e96070379a18d525e25bd60678b.zip
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
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/tasks/databases.rake22
2 files changed, 24 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 0095bbbf89..cf0425a22e 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -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]
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 056415c501..aa347381a6 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -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