I have a multi-tenancy app using ascts_as_tenant. I am trying to write a spec that tests a scope. So I want to test the output of User.active.
In general this works fine with code such as the following
it "returns a correct active user" do
user_active = Fabricate(:user, curremp: true)
user_scope2_active = Fabricate(:user, curremp: true)
user_not_active = Fabricate(:user, account_id: user_active.account_id, curremp: false)
expect(User.active).should include(user_active)
#expect(User.active).to_not include(user_scope2_active)
expect(User.active).to_not include(user_not_active)
end
However, I'm lost on how I get it to use the acts_as_tenant functionality to use a current_tenant and to therefore validate it only lists active users from one tenant. I'm sure this has been done before but I haven't found any documentation on it as yet.
Therefore how do I test acts_as_tenant user model with rspec?