1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fix regression when loading fixture files with symbol keys.

Closes #22584.
This commit is contained in:
Yves Senn 2016-01-13 10:11:54 +01:00
parent ffdeb3a62a
commit ede2343031
4 changed files with 16 additions and 2 deletions

View file

@ -1,3 +1,9 @@
* Fix regression when loading fixture files with symbol keys.
Closes #22584.
*Yves Senn*
* Support `:if` and `:unless` options in `has_secure_token`
*Griffin Smith*

View file

@ -297,14 +297,15 @@ module ActiveRecord
# Inserts the given fixture into the table. Overridden in adapters that require
# something beyond a simple insert (eg. Oracle).
def insert_fixture(fixture, table_name)
columns = schema_cache.columns_hash(table_name)
fixture = fixture.stringify_keys
columns = schema_cache.columns_hash(table_name)
binds = fixture.map do |name, value|
if column = columns[name]
type = lookup_cast_type_from_column(column)
Relation::QueryAttribute.new(name, value, type)
else
raise Fixture::FixtureError, %(table "#{table_name}" has no column named "#{name}".)
raise Fixture::FixtureError, %(table "#{table_name}" has no column named #{name.inspect}.)
end
end
key_list = fixture.keys.map { |name| quote_column_name(name) }

View file

@ -223,6 +223,10 @@ class FixturesTest < ActiveRecord::TestCase
assert_equal(%(table "parrots" has no column named "arrr".), e.message)
end
def test_yaml_file_with_symbol_columns
ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT + "/naked/yml", "trees")
end
def test_omap_fixtures
assert_nothing_raised do
fixtures = ActiveRecord::FixtureSet.new(Account.connection, 'categories', Category, FIXTURES_ROOT + "/categories_ordered")

View file

@ -0,0 +1,3 @@
root:
:id: 1
:name: The Root