Using rails 2.3 and MySQL 5.
I have code in a controller that is something like
begin
User.transaction do
user_object.save
do something that might raise an exeception
end
rescue
Log the error
give the user the form to try again
end
It works perfectly when the functionality is executed from the browser
post. The user is not in the db when the exception is raised.
However, when I run my functional test this the I do a user.find_by_name
after the post is executed and it comes back with the user (should come
back nil).
I see the exception logged properly but the transaction just is not
rolled back.
Is this a known issue? Have something to do with the transaction
created to reset fixture data?
Thanks in advance
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 10, 9:17 pm, Homer Simpson <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> However, when I run my functional test this the I do a user.find_by_name > after the post is executed and it comes back with the user (should come > back nil). > > I see the exception logged properly but the transaction just is not > rolled back. > > Is this a known issue? Have something to do with the transaction > created to reset fixture data?Tests are special, because each test already runs within a transaction. In rails 2.3 Active Record should be using savepoints as a substitute for actual nested transactions - do your logs show that happening? Fred> > Thanks in advance > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Frederick Cheung wrote:> On Feb 10, 9:17�pm, Homer Simpson <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > Tests are special, because each test already runs within a > transaction. In rails 2.3 Active Record should be using savepoints as > a substitute for actual nested transactions - do your logs show that > happening? > > FredWhat exactly should I be searching for in the log? I don''t see the word save point. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 11 February 2010 11:34, Homer Simpson <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Frederick Cheung wrote: >> On Feb 10, 9:17�pm, Homer Simpson <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> >> Tests are special, because each test already runs within a >> transaction. In rails 2.3 Active Record should be using savepoints as >> a substitute for actual nested transactions - do your logs show that >> happening? >> >> Fred > > What exactly should I be searching for in the log? I don''t see the word > save point. >Delete the log file then run just that test. Then you will see what happened. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Homer Simpson
2010-Feb-11 14:09 UTC
Re: Re: Transaction not rolled back in Functional Test
Colin Law wrote:> On 11 February 2010 11:34, Homer Simpson <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Delete the log file then run just that test. Then you will see what > happened. > > ColinAll I see in the test.log is a few selects, an insert (that should be rolled back), the rendering messages, the error I output for the exception and the "completed" stats -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.