On Thu, Mar 18, 2010 at 6:08 AM, Vikrant Chaudhary <nas...@gmail.com> wrote:
> In following code -
>
> require "test_helper"
> Class SomeControllerTest < ActionController::TestCase
>
>  def test_something
>    record = SomeModel.create :name => 'test'
>    record.save!
>    gets
>  end
>
> end
>
> Above record is not being saved in the database. I can confirm this by
> pausing execution by calling gets() and doing a "SELECT * FROM
> some_models" right into the test database which returns no rows.
>
> --

Tests are ran inside a transaction and are rolled back after each
test. In a separate process (i.e. ./script/dbconsole) you will not see
the data create from a test, even if you pause execution.

You *should* be able to see the insert (and the roll back) happening in test.log

Even though the transaction is rolled back, the sequence on the
primary key is still advanced, so you should see that effect in a
separate process.

- Steven

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to