From 6b145f2d5bb941b1ab219764b7be0a17cae95010 Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Wed, 11 May 2011 12:43:46 +0200 Subject: [PATCH] using View.prepare now for including helpers. --- lib/cell/rails.rb | 14 +++++--------- test/rails/router_test.rb | 6 ++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/cell/rails.rb b/lib/cell/rails.rb index cf689ca6..6168da37 100644 --- a/lib/cell/rails.rb +++ b/lib/cell/rails.rb @@ -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 diff --git a/test/rails/router_test.rb b/test/rails/router_test.rb index 7f270ff3..68c70fdb 100644 --- a/test/rails/router_test.rb +++ b/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