andreo-FdlSlcb4kYpknbxzx/v8hQ@public.gmane.org
2013-Jul-04 15:18 UTC
Rspec devise, testing extended RegistrationController action destroy
Hi everyone, I have devise 1.5.4 working with rails 3.0.20 and ruby 1.8.7 . I have extended the destroy action from the RegistrationController, to soft delete users instead of really deleting them from the database. def destroy # raise resouce.inspect # this is just to see if the test hits the action resource.soft_delete set_flash_message :notice, :destroyed sign_out resource redirect_to new_session_path(resource) end This is working on the browser. When I try to write a test to the delete action, I get the test as passed but does not execute the code. Prove of that is I have put a raise on the action and it did not raise it. I have also tried to test the ''new action'' just to see if it was hitting the right controller on the test and it worked with: get :new This means the mapping it correct for devise and its hitting the right controller. But on my test I am doing: delete :destroy, :profile => active_profile #active_profile is an instance of a factory which should be the correct thing but it does not hit my action. I have tried a lot of different combinations: post :destroy, :method => :delete post :destroy put :destroy I have also tried to use a debugger on it and I can see it passes the test without hitting the action. Can please somebody help me and tell me exactly what''s the right call to this action? Thanks, Andre -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e12142f4-ae4a-40cf-bcfd-fe182d9fc8e0%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Jul-04 15:32 UTC
Re: Rspec devise, testing extended RegistrationController action destroy
On 4 July 2013 16:18, <andreo-FdlSlcb4kYpknbxzx/v8hQ@public.gmane.org> wrote:> Hi everyone, > > I have devise 1.5.4 working with rails 3.0.20 and ruby 1.8.7 . > > I have extended the destroy action from the RegistrationController, to soft > delete users instead of really deleting them from the database. > > def destroy > # raise resouce.inspect # this is just to see if the test hits the > action > resource.soft_delete > set_flash_message :notice, :destroyed > sign_out resource > redirect_to new_session_path(resource) > end > > This is working on the browser. > > When I try to write a test to the delete action, I get the test as passed > but does not execute the code. Prove of that is I have put a raise on the > action and it did not raise it. I have also tried to test the ''new action'' > just to see if it was hitting the right controller on the test and it worked > with: > > get :new > > This means the mapping it correct for devise and its hitting the right > controller. > But on my test I am doing: > > delete :destroy, :profile => active_profile #active_profile is an instance > of a factory > > which should be the correct thing but it does not hit my action. I have > tried a lot of different combinations: > > post :destroy, :method => :delete > post :destroy > put :destroy > > I have also tried to use a debugger on it and I can see it passes the test > without hitting the action.Look in test.log to see what is happening. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsXbB1PH-cZghKU60VsTvS%3DdYfhpyN-gcYTnxytA7GU8A%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
andreo-FdlSlcb4kYpknbxzx/v8hQ@public.gmane.org
2013-Jul-09 13:48 UTC
Re: Rspec devise, testing extended RegistrationController action destroy
Colin, Thanks very much, I should have done that and understood right away why it was not working. I forgot I had to login the user and that was the difference between the new and create actions to the update and destroy for the registrations controller on devise! sometimes you just need another person to look at your code or to write it down to understand what you doing wrong :) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c29a69b5-662b-44a2-af5a-714f262c33d1%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Jul-09 20:35 UTC
Re: Rspec devise, testing extended RegistrationController action destroy
On 9 July 2013 14:48, <andreo-FdlSlcb4kYpknbxzx/v8hQ@public.gmane.org> wrote:> Colin, > > Thanks very much, I should have done that and understood right away why it > was not working. > > I forgot I had to login the user and that was the difference between the new > and create actions to the update and destroy for the registrations > controller on devise! > > sometimes you just need another person to look at your code or to write it > down to understand what you doing wrong :)That is true. Glad to be of help. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsGPE-H_1%2BeDpN8WW0Pivu_6WN1AeFeV62%2B7qAOC7hwcw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.