[Rails] Can Base#before_destroy not be deprecated?
I understand the motivation for deprecating it in actual application
code, but I ask because I've been testing my controller's destroy
actions in specs as follows:
describe "POST destroy" do
it "should redirect to show with an alert on failed destroy" do
ModelOfThisController.class_eval { def before_destroy; false;
end }
#rest of code...
end
it "should redirect to index with a notice on successful destroy"
do
ModelOfThisController.class_eval { def before_destroy; true;
end }
#rest of code...
end
end
And i thought it was a pretty clean way to accomplish the goal. If
you deprecate Base#before_destroy and then remove it in favor of
Base.before_destroy :method, Then what? Won't I have to do the
equivalent to every method in the before_destroy callback chain?
Seems messier and more brittle.
Or is there a rails way of testing this that I don't know about?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home