Skip to content

Commit

Permalink
using View.prepare now for including helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed May 11, 2011
1 parent f6a249b commit 6b145f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/cell/rails.rb
Expand Up @@ -61,17 +61,13 @@ def setup_backwardibility(*args)
end

def self.view_context_class
controller = self

View.class_eval do
include controller._helpers
include controller._routes.url_helpers
@view_context_class ||= begin
routes = _routes #if respond_to?(:_routes)
helpers = _helpers #if respond_to?(:_helpers)
View.prepare(routes, helpers)
end
end


@view_context_class ||= View
end

def self.controller_path
@controller_path ||= name.sub(/Cell$/, '').underscore unless anonymous?
end
Expand Down
6 changes: 6 additions & 0 deletions test/rails/router_test.rb
@@ -1,8 +1,14 @@
require 'test_helper'

module ApplicationTests
class RouterTest < ActionController::TestCase
tests MusicianController

context "A Rails app" do
should "pass url_helpers to the cell instance" do
assert_equal "/", BassistCell.new(@controller).root_path
end

should "allow cells to use url_helpers" do
BassistCell.class_eval do
def promote; render; end
Expand Down

0 comments on commit 6b145f2

Please sign in to comment.