apotonick / apotomo

MVC Components for Rails.
http://apotomo.de
654 stars 68 forks source link

parent_controller in tests #133

Closed AlexVangelov closed 10 years ago

AlexVangelov commented 10 years ago

Expecting parent_controller in Apotomo::Widget instance to be thе same as @controller assigned in Apotomo::TestCase. Delegates to parrent_controller breaks tests.

apotonick commented 10 years ago

What's the actual object the widget#parent_controller is refering to? nil?

AlexVangelov commented 10 years ago

No it is kind of ActionController::Base with #controller_path == 'barn'

AlexVangelov commented 10 years ago

I think it comes from Cell::TestCase, where it is overwrited in def setup @controller = Class.new(ActionController::Base).new

AlexVangelov commented 10 years ago

That's right, overriding this module (Cell::TestCase::CommonTestMethods#setup), adding if @controller.nil? to setter makes everything as I expected. BR!

kuraga commented 10 years ago

So, do we have a problem, @AlexVangelov , @apotonick ?

AlexVangelov commented 10 years ago

Actually Yes. But the problem is not in this repository. It's related to https://github.com/apotonick/cells Setup in Cell::TestCase should not overwrite @controller (and may be @request, there is a practice to modify request in TestCase setup, like http basic authentication ). I think that setup should check @controller for existence and kind of ActionController::Base, and if it's OK to pass it untouched.

apotonick commented 10 years ago

Agreed! PR?