aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/fixtures/file.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/fixtures/file.rb b/activerecord/lib/active_record/fixtures/file.rb
index beda5a65df..da07cf5da1 100644
--- a/activerecord/lib/active_record/fixtures/file.rb
+++ b/activerecord/lib/active_record/fixtures/file.rb
@@ -34,12 +34,19 @@ module ActiveRecord
return @rows if @rows
data = YAML.load(render(IO.read(@file)))
- @rows = data ? data.to_a : []
+ @rows = data ? validate(data).to_a : []
end
def render(content)
ERB.new(content).result
end
+
+ # Validate our unmarshalled data.
+ def validate(data)
+ raise Fixture::FormatError, 'fixture is not a hash' unless Hash === data
+ raise Fixture::FormatError unless data.all? { |name, row| Hash === row }
+ data
+ end
end
end
end