aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-12-03 00:11:24 -0800
committerYves Senn <yves.senn@gmail.com>2013-12-03 00:11:24 -0800
commitb6f189e2f0bcc8f36f52c83e8ac2255d5e578a42 (patch)
tree9497d0ae23ce1217adb5d21143587c54825dc564 /guides
parentabc1e5831cae724cfcdf524f62abb71be02d7e86 (diff)
parentddf27acbc285a892842866cde04951cdad52c5c9 (diff)
downloadrails-b6f189e2f0bcc8f36f52c83e8ac2255d5e578a42.tar.gz
rails-b6f189e2f0bcc8f36f52c83e8ac2255d5e578a42.tar.bz2
rails-b6f189e2f0bcc8f36f52c83e8ac2255d5e578a42.zip
Merge pull request #13022 from pwnall/fixture_context
Introduce a context for rendering fixtures ERB.
Diffstat (limited to 'guides')
-rw-r--r--guides/source/4_1_release_notes.md4
-rw-r--r--guides/source/upgrading_ruby_on_rails.md17
2 files changed, 21 insertions, 0 deletions
diff --git a/guides/source/4_1_release_notes.md b/guides/source/4_1_release_notes.md
index f278aa9ea5..de29b2e58e 100644
--- a/guides/source/4_1_release_notes.md
+++ b/guides/source/4_1_release_notes.md
@@ -348,6 +348,10 @@ for detailed changes.
ActiveRecord will now translate aliased attribute names to the actual column
name used in the database. ([Pull Request](https://github.com/rails/rails/pull/7839))
+* The ERB in fixture files is no longer evaluated in the context of the main
+ object. Helper methods used by multiple fixtures should be defined on modules
+ included in `ActiveRecord::FixtureSet.context_class`. ([Pull Request](https://github.com/rails/rails/pull/13022))
+
Credits
-------
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index ef5f6ac024..3fbc913d8b 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -27,6 +27,23 @@ Upgrading from Rails 4.0 to Rails 4.1
NOTE: This section is a work in progress.
+### Methods defined in Active Record fixtures
+
+Rails 4.1 evaluates each fixture's ERB in a separate context, so helper methods
+defined in a fixture will not be available in other fixtures.
+
+Helper methods that are used in multiple fixtures should be defined on modules
+included in the newly introduced `ActiveRecord::FixtureSet.context_class`, in
+`test_helper.rb`.
+
+```ruby
+class FixtureFileHelpers
+ def file_sha(path)
+ Digest::SHA2.hexdigest(File.read(Rails.root.join('test/fixtures', path)))
+ end
+end
+ActiveRecord::FixtureSet.context_class.send :include, FixtureFileHelpers
+```
Upgrading from Rails 3.2 to Rails 4.0
-------------------------------------