If you follow this cast and are testing with RSpec here is a tip.
In order for the scopes to work I added this to the before block
RSpec test before block
before do
sign_up_tenant(subdomain)
@tenant = Tenant.first
Tenant.current_id = @tenant.id
end
I have a macro setup called sign_up_tenant that simply fills in the form and submits, but you can just create the Tenant using FactoryGirl or something similar.
The important bit is the Tenant.current_id = @tenant.id
Testing
If you follow this cast and are testing with RSpec here is a tip.
In order for the scopes to work I added this to the before block
I have a macro setup called sign_up_tenant that simply fills in the form and submits, but you can just create the Tenant using FactoryGirl or something similar.
The important bit is the
Tenant.current_id = @tenant.id
If anyone is using this with Devise gem and want to have unique emails per scope, here is what I added to the user model file.
This disables the Devise validation for email (only) so you can implement your own. ie Use the validation Ryan shows in this video.