rails active record returning incorrect result

Viewed 58

We have rails (4.2.7.1) app with MySQL (5.7.38) database.

There is an RSpec test. It first adds a record into storage_links table and then tests for something.

I put a debugger after the record insertion logic. Doing StorageLink.last shows older record not the last inserted one. Although the record exists in database (checked in MySQL console).

I am not sure why active record is returning wrong result.

Anyone know possible reason for this ?

EDIT: Adding main code.

enter image description here

Adding test code too. enter image description here

Issue is in second test case should return true when limit = 1

mass_add inserts record in a new Thread.

Now in test code, before line 24 I put debugger. And check StorageLink.count which shows older count. If I open a rails console in test env now, it shows updated count.

NOTE: This spec was passing on ruby 2.1.5 but failing on ruby 2.3.5

0 Answers
Related