This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

controller.action_name

  • Loading branch information...
1 parent 8f33851 commit b45b806cf81d34b86495c170f0c666299f5611e1 Joe Ferris and Mike Burns committed with jferris Aug 3, 2012
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/turning/renderer.rb
  2. +9 −0 spec/turning/renderer_spec.rb
View
@@ -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
@@ -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

0 comments on commit b45b806

Please sign in to comment.