Skip to content

Commit

Permalink
[helper/render.rb] fixed render_file's sync_variables. see detail:
Browse files Browse the repository at this point in the history
  This line syncs variables from current action to newly created action:
    action.sync_variables(self.action)

  but later this line eliminates above effect:
    action.variables = variables.dup

  Assume we would like variables from current action, but
  would like to override (or hide, shadow) them by passing
  another hash of variables in render_file's second arguments.
  Then change that line to:
    action.variables.merge!(variables.dup)

  spec this behavior in SpecHelperRenderFile.
  • Loading branch information
godfat committed Nov 16, 2009
1 parent 8007ab5 commit d69a954
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/innate/helper/render.rb
Expand Up @@ -121,7 +121,7 @@ def render_file(filename, variables = {})
action.node = self.class
action.engine = self.action.engine
action.instance = action.node.new
action.variables = variables.dup
action.variables.merge!(variables.dup)

yield(action) if block_given?

Expand Down
4 changes: 3 additions & 1 deletion spec/innate/helper/render.rb
Expand Up @@ -86,10 +86,12 @@ def layout
FILE = File.expand_path('../view/aspect_hello.xhtml', __FILE__)

def absolute
@bar = 'bar'
render_file(FILE)
end

def absolute_with(foo, bar)
@foo = 'foo'
render_file(FILE, :foo => foo, :bar => bar)
end
end
Expand Down Expand Up @@ -155,7 +157,7 @@ def absolute_with(foo, bar)
behaves_like :rack_test

it 'renders file from absolute path' do
get('/render_file/absolute').body.should == '{ ! }'
get('/render_file/absolute').body.should == '{ bar! }'
end

it 'renders file from absolute path with variables' do
Expand Down

0 comments on commit d69a954

Please sign in to comment.