Hi,
I just ran into kind of an issue with child models in a one-to-one
relationship who are also in a polymorphic association, i.e., their
foreign key is kept by another model, e.g., ‘Comment’.
So, the path for a child might be “human_parents/1/child”, while the
path to the polymorphic association would be “human_parents/1/child/
comments”. (Imagine that there are many kinds of parents, all capable
of only one child, e.g., “kangaroo_parents/1/child”.)
The problem, I’ve found, is that a relatively efficient approach to
controlling the Comment model, i.e., having a CommentController, is
not fully testable under rspec-rails, bc the routes are unique within
the CommentController spec file only by their params. So, when I do
say ‘get :new, :human_parent_id=>2’ I can’t further specify the action
on the child, e.g., ‘get new comment for the child’.
From a rspec-rails testing perspective, then, this should make you
prefer to distribute the comment controller actions among the child
controllers and not, as is often proposed, in a single controller.
If anyone has any thoughts on how I can in fact, run around this
problem and keep my CommentController, please write.
Lille