m_r and integration tests fail

0 views
Skip to first unread message

jcfischer

unread,
Mar 22, 2008, 7:56:27 AM3/22/08
to make_resourceful
I spent the better part of yesterday debugging m_r in conjunction with
integration tests. Turns out, that any controller that is m_r enabled
can't be integration testet.

After much cursing and sweating, I found out where the problem is:

in integrtion.rb, the call to Controller#new is aliased to
#new_with_capture. new_with_capture stores the controller away and the
integration test later retrieve it, to check the response.

In m_r, builder, on line 85, new is called on the controller to
determine the plurality:

available_actions = controller.new.plural? ? ACTIONS :
SINGULAR_ACTIONS

Now the integration tests store an empty controller, and
subsequentely, the integration tests fail.

I hacked the following workaround:

# The available actions are defined in Default::Actions.
def actions(*available_actions)
if available_actions.first == :all
if controller.respond_to?(:new_without_capture)
available_actions = controller.new_without_capture.plural? ?
ACTIONS : SINGULAR_ACTIONS
else
available_actions = controller.new.plural? ? ACTIONS :
SINGULAR_ACTIONS
end
end

but I guess, plurality should be detemined without instantiating a new
controller.

I have but up my version of m_r on github: http://github.com/jcfischer/make_resourceful/tree/master

cheers
Jens-Christian

Nathan Weizenbaum

unread,
Mar 23, 2008, 2:33:36 AM3/23/08
to make_res...@googlegroups.com
This solution, while clever, is pretty hacky. If you could make a patch
that makes plural? (and, for that matter, all similar methods that don't
depend on instance state) into a class method that's also accessible as
an instance method, I'd definitely commit that. I'll do it myself once I
have time, but that may not be for a couple of weeks (directing a play),
so your patch would be much faster.

jcfischer

unread,
Mar 23, 2008, 9:12:06 AM3/23/08
to make_resourceful


On 23 Mrz., 07:33, Nathan Weizenbaum <nex...@gmail.com> wrote:
> This solution, while clever, is pretty hacky. If you could make a patch
> that makes plural? (and, for that matter, all similar methods that don't
> depend on instance state) into a class method that's also accessible as
> an instance method, I'd definitely commit that. I'll do it myself once I
> have time, but that may not be for a couple of weeks (directing a play),
> so your patch would be much faster.

Yeah - that sounds like a plan. I was just tired after 6 hours in the
debugger and got something hacked up quickly...

I'll patch something in the next few days :)

jc

Ian Duggan

unread,
Mar 27, 2008, 4:38:04 PM3/27/08
to make_res...@googlegroups.com, jcfisch...@gmail.com, nex...@gmail.com

Nathan Weizenbaum wrote:
> This solution, while clever, is pretty hacky. If you could make a patch
> that makes plural? (and, for that matter, all similar methods that don't
> depend on instance state) into a class method that's also accessible as
> an instance method, I'd definitely commit that. I'll do it myself once I
> have time, but that may not be for a couple of weeks (directing a play),
> so your patch would be much faster.

Odd that we found this at nearly the same time. I just went through a
long debug session to find the same thing, but I was coming from the
rails side...

This seems, to me, to be a bug in rails.

I welcome a make_resourceful patch that is gentler on rails, but the
attached bug w/ patches also addresses the problem and the fix is a
one-liner in rails' integration.rb.

http://dev.rubyonrails.org/ticket/11449

I'm going to update the ticket w/ your diagnosis of what caused the issue.

--Ian

Reply all
Reply to author
Forward
0 new messages