Permalink
Browse files

Catch FixtureClassNotFound when using instantiated fixtures on a fixt…

…ure that has no ActiveRecord model [Rick Olson]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3866 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 796a43d commit 4965a754d5c9bfde332398c653e003c749e62cf9 @technoweenie technoweenie committed Mar 14, 2006
Showing with 7 additions and 3 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +4 −2 activerecord/lib/active_record/fixtures.rb
  3. +1 −1 activerecord/test/fixtures_test.rb
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson]
+
* Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com]
* Dynamically set allow_concurrency. #4044 [Stefan Kaes]
View
6 activerecord/lib/active_record/fixtures.rb
@@ -223,8 +223,10 @@ def self.instantiate_fixtures(object, table_name, fixtures, load_instances=true)
if load_instances
ActiveRecord::Base.silence do
fixtures.each do |name, fixture|
- if model = fixture.find
- object.instance_variable_set "@#{name}", model
+ begin
+ object.instance_variable_set "@#{name}", fixture.find
+ rescue FixtureClassNotFound
+ nil
end
end
end
View
2 activerecord/test/fixtures_test.rb
@@ -11,7 +11,7 @@ class FixturesTest < Test::Unit::TestCase
self.use_instantiated_fixtures = true
self.use_transactional_fixtures = false
- fixtures :topics, :developers, :accounts, :tasks, :categories
+ fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes
FIXTURES = %w( accounts companies customers
developers developers_projects entrants

0 comments on commit 4965a75

Please sign in to comment.