Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6798

Show
Ignore:
Timestamp:
05/21/07 18:54:51 (1 year ago)
Author:
rick
Message:

Fix column type detection while loading fixtures. Closes #7987 [roderickvd]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r6790 r6798  
    11*SVN* 
     2 
     3* Fix column type detection while loading fixtures.  Closes #7987 [roderickvd] 
    24 
    35* Document deep eager includes.  #6267 [Josh Susser, Dan Manges] 
  • trunk/activerecord/lib/active_record/fixtures.rb

    r6360 r6798  
    416416 
    417417    list = @fixture.inject([]) do |fixtures, (key, value)| 
    418       col = klass.columns_hash[key] if klass.kind_of?(ActiveRecord::Base) 
     418      col = klass.columns_hash[key] if klass.respond_to?(:ancestors) && klass.ancestors.include?(ActiveRecord::Base) 
    419419      fixtures << ActiveRecord::Base.connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r") 
    420420    end 
  • trunk/activerecord/test/fixtures_test.rb

    r6227 r6798  
    1313  self.use_transactional_fixtures = false 
    1414 
    15   fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes 
    16  
    17   FIXTURES = %w( accounts companies customers 
     15  fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries 
     16 
     17  FIXTURES = %w( accounts binaries companies customers 
    1818                 developers developers_projects entrants 
    1919                 movies projects subscribers topics tasks ) 
    2020  MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/ 
     21 
     22  BINARY_FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures/flowers.jpg' 
    2123 
    2224  def test_clean_fixtures 
     
    101103  end 
    102104 
    103  
    104105  def test_bad_format 
    105106    path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures') 
     
    175176  end 
    176177 
    177  
    178178  def test_yml_file_in_subdirectory 
    179179    assert_equal(categories(:sub_special_1).name, "A special category in a subdir file") 
     
    186186  end 
    187187 
    188  
     188  def test_binary_in_fixtures 
     189    assert_equal 1, @binaries.size 
     190    data = File.read(BINARY_FIXTURE_PATH).freeze 
     191    assert_equal data, @flowers.data 
     192  end 
    189193end 
    190194