aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/fixture_set
diff options
context:
space:
mode:
authorVictor Costan <costan@gmail.com>2013-11-24 12:52:53 -0500
committerVictor Costan <costan@gmail.com>2013-12-03 02:52:26 -0500
commitddf27acbc285a892842866cde04951cdad52c5c9 (patch)
tree9497d0ae23ce1217adb5d21143587c54825dc564 /activerecord/lib/active_record/fixture_set
parentabc1e5831cae724cfcdf524f62abb71be02d7e86 (diff)
downloadrails-ddf27acbc285a892842866cde04951cdad52c5c9.tar.gz
rails-ddf27acbc285a892842866cde04951cdad52c5c9.tar.bz2
rails-ddf27acbc285a892842866cde04951cdad52c5c9.zip
Introduce a context for rendering fixtures ERB.
Fixture files are passed through an ERB renderer before being read as YAML. The rendering is currently done in the context of the main object, so method definitons leak into other fixtures, and there is no clean place to define fixture helpers. After this commit, the ERB renderer will use a new subclass of ActiveRecord::FixtureSet.context_class each time a fixture is rendered.
Diffstat (limited to 'activerecord/lib/active_record/fixture_set')
-rw-r--r--activerecord/lib/active_record/fixture_set/file.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/fixture_set/file.rb b/activerecord/lib/active_record/fixture_set/file.rb
index fbd7a4d891..8132310c91 100644
--- a/activerecord/lib/active_record/fixture_set/file.rb
+++ b/activerecord/lib/active_record/fixture_set/file.rb
@@ -38,7 +38,8 @@ module ActiveRecord
end
def render(content)
- ERB.new(content).result
+ context = ActiveRecord::FixtureSet::RenderContext.create_subclass.new
+ ERB.new(content).result(context.get_binding)
end
# Validate our unmarshalled data.