Any ROR developers here? need your help. I am havi...
# random
q
Any ROR developers here? need your help. I am having trouble in identifying how to run controller test in sequence or with transaction lock..๐Ÿงต
message has been deleted
I know i can assign created record to a variable and assert the result with variable, but I want to figure out if there is a way to run test in synchronous or in transactional mode ( records created by one test doesn't interfere with another )
w
Use databasecleaner
๐Ÿ‘€ 1
โž• 2
q
Thanks @wide-twilight-82330 let me dig into this
f
For the first test above, does
@response.body
return the newly created SellerCompany's ID? If it does, then using that id to get the object instead of
SellerCompany.last
might work
a
One straight forwards solution would be, instead of using
SellerCompany.last
, use
SellerCompany.find_by(name: '')
q
@freezing-whale-32835 @adventurous-fireman-74405 that would work, but I was curious to know why it
SellerCompany.last
does not works and wether it is an issue with parallel controller test or fixtures. finally found out that sorting goes for a toss when using uuids as the primary keys
Update: Issue was due to usage of uuids as the primary key which breaks the implicit sorting; uuids are not sequential, Fixed it by overriding,
self.implicit_order_column = :created_at
w
@quaint-farmer-12353 IMO, not a good idea to rely on timestamp unless that's part of the behaviour you're designing. I don't know which test framework is that but I have used transactional fixtures in rspec, until I was blocked by limitations of the transactional fixtures due to multiple dbs - so switched to databasecleaner.