Consider the current tenant with delayed jobs

This commit is contained in:
Eduardo Vilar
2019-02-20 18:45:48 +01:00
committed by Javi Martín
parent 275ddb08d8
commit 52ebeb7ba6
5 changed files with 38 additions and 1 deletions

View File

@@ -51,4 +51,23 @@ describe Mailer do
expect(user.subscriptions_token).to eq "subscriptions_token_value"
end
end
describe "multitenancy" do
it "uses the current tenant when using delayed jobs", :delay_jobs do
allow(ActionMailer::Base).to receive(:default_url_options).and_return({ host: "consul.dev" })
create(:tenant, schema: "delay")
Tenant.switch("delay") do
Setting["org_name"] = "Delayed tenant"
Mailer.delay.user_invite("test@consul.dev")
end
Delayed::Worker.new.work_off
body = ActionMailer::Base.deliveries.last.body.to_s
expect(body).to match "Delayed tenant"
expect(body).to match "href=\"http://delay.consul.dev/"
expect(body).to match "src=\"http://delay.consul.dev/"
end
end
end