Random failures in core

There seem to be random failures in core:

http://ci.theforeman.org/job/test_develop_pr_core/17162/

unexpected invocation: #<AnyInstance:SmartProxy(id: integer, name: string, url: string, created_at: datetime, updated_at: datetime, expired_logs: string)>.statuses()

Initially I thought these were caused by incorrect Rails cache handling in tests, but it looks like we clear cache correctly.

Looks familiar?

Can it be yet another use case where we stub methods outside test scope?

It’s just a wild guess, but worth investigating.

Been there, haven’t found any suspicious code.

I suspect

https://github.com/theforeman/foreman/pull/3611

in combination with

https://github.com/theforeman/foreman/pull/5445

I am trying to move some stubs to different level:

https://github.com/theforeman/foreman/pull/5487

But I am shooting in the dark, I’d appreciate someone taking another look I’ve already spent 2 days with this.