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

Merge pull request #24356 from denofevil/fixture_filename

provide file name for fixture ERB
This commit is contained in:
Rafael França 2016-03-30 06:51:52 -03:00
commit 7e976fd84d
2 changed files with 13 additions and 1 deletions

View file

@ -52,9 +52,15 @@ module ActiveRecord
end
end
def prepare_erb(content)
erb = ERB.new(content)
erb.filename = @file
erb
end
def render(content)
context = ActiveRecord::FixtureSet::RenderContext.create_subclass.new
ERB.new(content).result(context.get_binding)
prepare_erb(content).result(context.get_binding)
end
# Validate our unmarshalled data.

View file

@ -135,6 +135,12 @@ END
end
end
def test_erb_filename
filename = 'filename.yaml'
erb = File.new(filename).send(:prepare_erb, "<% Rails.env %>\n")
assert_equal erb.filename, filename
end
private
def tmp_yaml(name, contents)
t = Tempfile.new name