Changeset 9050
- Timestamp:
- 03/17/08 21:48:28 (4 months ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/fixtures.rb (modified) (1 diff)
- trunk/activerecord/test/cases/fixtures_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r9047 r9050 1 1 *SVN* 2 3 * Added logging for dependency load errors with fixtures #11056 [stuthulhu] 2 4 3 5 * Time zone aware attributes use Time#in_time_zone [Geoff Buesing] trunk/activerecord/lib/active_record/fixtures.rb
r8594 r9050 847 847 end 848 848 849 def try_to_load_dependency(file_name) 850 require_dependency file_name 851 rescue LoadError => e 852 # Let's hope the developer has included it himself 853 854 # Let's warn in case this is a subdependency, otherwise 855 # subdependency error messages are totally cryptic 856 ActiveRecord::Base.logger.warn("Unable to load #{file_name}, underlying cause #{e.message} \n\n #{e.backtrace.join("\n")}") 857 end 858 849 859 def require_fixture_classes(table_names = nil) 850 860 (table_names || fixture_table_names).each do |table_name| 851 861 file_name = table_name.to_s 852 862 file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names 853 begin 854 require_dependency file_name 855 rescue LoadError 856 # Let's hope the developer has included it himself 857 end 863 try_to_load_dependency(file_name) 858 864 end 859 865 end trunk/activerecord/test/cases/fixtures_test.rb
r8681 r9050 591 591 end 592 592 end 593 594 class FixtureLoadingTest < ActiveRecord::TestCase 595 def test_logs_message_for_failed_dependency_load 596 Test::Unit::TestCase.expects(:require_dependency).with(:does_not_exist).raises(LoadError) 597 ActiveRecord::Base.logger.expects(:warn) 598 Test::Unit::TestCase.try_to_load_dependency(:does_not_exist) 599 end 600 601 def test_does_not_logs_message_for_successful_dependency_load 602 Test::Unit::TestCase.expects(:require_dependency).with(:works_out_fine) 603 ActiveRecord::Base.logger.expects(:warn).never 604 Test::Unit::TestCase.try_to_load_dependency(:works_out_fine) 605 end 606 end