I’ve got a question about how variables are made available to templates.
have a test that looks something like this:
xhr :get, :do_stuff, :id => 1
And our app code looks like this:
class SuperClass < ActionController
@parent_model = ParentModel.find(params[:id])
render :template => ‘superclass/do_stuff’
class SubClass < SuperClass
@thing = @parent_model.thing
When we run our tests with the code above, it fails saying that
assigns(:thing) is nil. If we redefine do_stuff in SubClass to look
@thing = ParentModel.find(params[:id])
then the test will pass. Unfortunately, this requires an extra database
query to find the parent model twice. Is there a way of telling the
reload its member variables after render has been called, but still
whatever the chosen template is?