I have an ActiveRecord class which has scopes dynamically added based on content of another table.
(simplified code example)
class Thing < ActiveRecord::Base
Feature.all.each do |feature|
scope feature.name, ->{joins(:feature).where("feature.name = #{feature.name})}
end
end
Another part of the UI of the app is a "Thing display" that lets you search and apply these feature scopes as part of the search.
This all works fine in the running app.
In tests, however, it seems success depends on what order things are loaded in. Sometimes Thing
has the expected scopes, other times not. I thought I could force the Feature
class and fixtures to load first by calling Feature.count
before any tests run, but this doesn't work.
Is there some way to force the loading of class/fixtures to resolve this?
Aucun commentaire:
Enregistrer un commentaire