diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-05-21 18:54:51 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-05-21 18:54:51 +0000 |
commit | 96bc3d224d42fdd75d104feadc8f93ae41209fcb (patch) | |
tree | 6a7670c7bab88913a11639bc40b6359d1c6a01b7 | |
parent | d1c957d06744e468c56274e047460e596ef61d73 (diff) | |
download | rails-96bc3d224d42fdd75d104feadc8f93ae41209fcb.tar.gz rails-96bc3d224d42fdd75d104feadc8f93ae41209fcb.tar.bz2 rails-96bc3d224d42fdd75d104feadc8f93ae41209fcb.zip |
Fix column type detection while loading fixtures. Closes #7987 [roderickvd]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6798 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/fixtures.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/fixtures_test.rb | 14 |
3 files changed, 12 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 37d0ca53e4..5a9b781b72 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix column type detection while loading fixtures. Closes #7987 [roderickvd] + * Document deep eager includes. #6267 [Josh Susser, Dan Manges] * Document warning that associations names shouldn't be reserved words. #4378 [murphy@cYcnus.de, Josh Susser] diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 96fd0c57af..c837fd7b50 100755 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -415,7 +415,7 @@ class Fixture #:nodoc: klass = @class_name.constantize rescue nil list = @fixture.inject([]) do |fixtures, (key, value)| - col = klass.columns_hash[key] if klass.kind_of?(ActiveRecord::Base) + col = klass.columns_hash[key] if klass.respond_to?(:ancestors) && klass.ancestors.include?(ActiveRecord::Base) fixtures << ActiveRecord::Base.connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r") end list * ', ' diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/fixtures_test.rb index 7ccfc9be86..d9973683cc 100755 --- a/activerecord/test/fixtures_test.rb +++ b/activerecord/test/fixtures_test.rb @@ -12,13 +12,15 @@ class FixturesTest < Test::Unit::TestCase self.use_instantiated_fixtures = true self.use_transactional_fixtures = false - fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes + fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries - FIXTURES = %w( accounts companies customers + FIXTURES = %w( accounts binaries companies customers developers developers_projects entrants movies projects subscribers topics tasks ) MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/ + BINARY_FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures/flowers.jpg' + def test_clean_fixtures FIXTURES.each do |name| fixtures = nil @@ -100,7 +102,6 @@ class FixturesTest < Test::Unit::TestCase assert first end - def test_bad_format path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures') Dir.entries(path).each do |file| @@ -174,7 +175,6 @@ class FixturesTest < Test::Unit::TestCase end end - def test_yml_file_in_subdirectory assert_equal(categories(:sub_special_1).name, "A special category in a subdir file") assert_equal(categories(:sub_special_1).class, SpecialCategory) @@ -185,7 +185,11 @@ class FixturesTest < Test::Unit::TestCase assert_equal(categories(:sub_special_3).class, SpecialCategory) end - + def test_binary_in_fixtures + assert_equal 1, @binaries.size + data = File.read(BINARY_FIXTURE_PATH).freeze + assert_equal data, @flowers.data + end end if Account.connection.respond_to?(:reset_pk_sequence!) |