Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

controller.action_name

  • Loading branch information...
commit b45b806cf81d34b86495c170f0c666299f5611e1 1 parent 8f33851
Joe Ferris and Mike Burns authored jferris committed
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/turning/renderer.rb
  2. +9 −0 spec/turning/renderer_spec.rb
View
4 lib/turning/renderer.rb
@@ -40,12 +40,16 @@ def self.name
'StaticController'
end
layout nil
+
+ # So that controller.action_name continues to work
+ attr_accessor :action_name
}.new
@renderable.controller_path = @controller_path
end
def render_to_file(template_name, path, assigns)
@renderable.view_assigns = assigns
+ @renderable.action_name = template_name
contents = @renderable.render_to_string(action: template_name)
@storage.put(path, contents)
end
View
9 spec/turning/renderer_spec.rb
@@ -52,6 +52,15 @@ def greet
storage.should have_static_view('/examples/simple', 'Check this: Hello')
end
+ it 'provides an action name' do
+ create_view('examples/example_template.html.erb', '<%= controller.action_name %>')
+ storage = mock_storage
+ renderer = Turning::Renderer.new('examples', storage)
+ renderer.render_to_file('example_template', '/examples/example_template', {})
+
+ storage.should have_static_view('/examples/example_template', 'example_template')
+ end
+
def mock_storage
stub('storage', put: nil)
end
Please sign in to comment.
Something went wrong with that request. Please try again.