diff options
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/4_1_release_notes.md | 4 | ||||
-rw-r--r-- | guides/source/upgrading_ruby_on_rails.md | 17 |
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 ------------------------------------- |