Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
merge [6798] into stable.
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6799 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
technoweenie committed May 21, 2007
1 parent 07f92e8 commit b14378c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions 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]

* Oracle: extract column length for CHAR also. #7866 [ymendel]
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/fixtures.rb
Expand Up @@ -412,7 +412,7 @@ def value_list
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 * ', '
Expand Down
14 changes: 9 additions & 5 deletions activerecord/test/fixtures_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -100,7 +102,6 @@ def test_insert_with_datetime
assert first
end


def test_bad_format
path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures')
Dir.entries(path).each do |file|
Expand Down Expand Up @@ -174,7 +175,6 @@ def test_omap_fixtures
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)
Expand All @@ -185,7 +185,11 @@ def test_subsubdir_file_with_arbitrary_name
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!)
Expand Down

0 comments on commit b14378c

Please sign in to comment.