I’m starting to add tests to my existing app which uses default_scope for multi-tenancy. The tenant is
School and almost every other object is scoped under
current_school since the app has no public/anonymous access.
I started with a simple
association :school in each factory (
Upload, etc) which was fine for model/unit tests but as soon I started doing integration tests I realized I need to be able to control which
School my tests objects are created under.
I’ve added the following to my
config.before(:suite) do School.create!(name: 'Main', subdomain: 'main') School.create!(name: 'Other', subdomain: 'other') end
but how do I efficiently use these two ‘preset’ tenants in my factories and/or specs?