Permalink
Browse files

adding Widget#parent_controller so we do access root's AC, only.

  • Loading branch information...
1 parent 97f08d5 commit 43985ac73c19ae37f10a98e3f7c7a8bd1787937f @apotonick committed Oct 12, 2011
Showing with 10 additions and 3 deletions.
  1. +5 −0 lib/apotomo/widget.rb
  2. +1 −0 lib/apotomo/widget_shortcuts.rb
  3. +1 −1 test/rails/rails_integration_test.rb
  4. +3 −2 test/widget_test.rb
View
@@ -88,6 +88,11 @@ def initialize(parent, id, options={})
run_hook :after_initialize, self
end
+ def parent_controller
+ # i hope we'll get rid of any parent_controller dependency, soon.
+ root? ? @parent_controller : root.parent_controller
+ end
+
def visible?
@visible
end
@@ -52,6 +52,7 @@ def constant_for(class_name) # TODO: use Cell.class_from_cell_name.
end
end
+ # Mixed into Widget.
module DSL
def <<(child)
child.build(self)
@@ -67,7 +67,7 @@ def mum
context "nested widgets" do
should "render" do
get 'mum', :state => :child
- assert_equal "/rails_integration_test/mum/render_event_response?source=kid&amp;type=click\n", @response.body
+ assert_equal "/barn/render_event_response?source=kid&amp;type=click\n", @response.body
end
should "process events" do
View
@@ -83,7 +83,6 @@ class WidgetTest < ActiveSupport::TestCase
end
should "find children" do
- puts @mum.printTree
assert_equal @kid, @mum.find_widget('kid')
end
@@ -96,8 +95,10 @@ class WidgetTest < ActiveSupport::TestCase
assert_respond_to @mum, :widget
end
- should "respond to #parent_controller" do
+ should "respond to #parent_controller and return the AC in root" do
+ @mum << mouse_mock(:kid)
assert_equal @controller, @mum.parent_controller
+ assert_equal @controller, @mum[:kid].parent_controller
end
should "alias #widget_id to #name" do

0 comments on commit 43985ac

Please sign in to comment.