Forum: Ruby on Rails Model records are not saved to database in during tests

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bca6763730989267ae5c7cfa6503e177?d=identicon&s=25 Roman LE NEGRATE (Guest)
on 2006-06-11 22:38
(Received via mailing list)
Hi,

I'm trying to do unit tests which should save informations into a
database that another computer should be able to get while the test
is running.

The problem is although my unit test class has
"use_transactional_fixtures" set to false, when I create a new
instance of a model and save it, it does not actually appear in the
database when connecting to this same database with the "mysql"
command line tool. The fixtures are the only present records.

My question is: how to do so that the records actually get inserted
into the test database ?


Thank you :-).
Bca6763730989267ae5c7cfa6503e177?d=identicon&s=25 Roman LE NEGRATE (Guest)
on 2006-06-11 22:44
(Received via mailing list)
(Sorry for the careless mistake in the title)
Bca6763730989267ae5c7cfa6503e177?d=identicon&s=25 Roman LE NEGRATE (Guest)
on 2006-06-12 18:45
(Received via mailing list)
> My question is: how to do so that the records actually get inserted
> into the test database ?

Unfortunately, this Rails behaviour prevents me from going further in
my project.
Does anybody have an idea ?
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-06-12 19:01
(Received via mailing list)
On Monday, June 12, 2006, at 6:42 PM, Roman LE NEGRATE wrote:
>> My question is: how to do so that the records actually get
>>inserted > into the test database ?
>
>Unfortunately, this Rails behaviour prevents me from going further
>in my project.
>Does anybody have an idea ?
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails

This is normal testing behavior.  For each test the database is
populated with your fixtures and then torn down again at the end.  This
prevents tests from being dependent on each other.

To get around this behavior you will need to do some hackery in the
Testing code.  You may want to define a new 'environment' called
'distributed-test' and then patch the testing code to skip the database
rollback in that case.  Just remember that your tests may behave oddly
since they are no longer independent of each other unless you manually
reload the data.

_Kevin
Bca6763730989267ae5c7cfa6503e177?d=identicon&s=25 Roman LE NEGRATE (Guest)
on 2006-06-13 09:52
(Received via mailing list)
> since they are no longer independent of each other unless you manually
> reload the data.

Thank you Kevin.
This topic is locked and can not be replied to.