Move subdomain logic to tenant model

We had some of the logic in the ApplicationMailer. Since we're going to
use this logic in more places, we're moving it to the Tenant model,
which is the model handling everything related to hosts.
This commit is contained in:
Javi Martín
2022-10-05 23:37:51 +02:00
parent 468761253b
commit d904fe8b4f
4 changed files with 24 additions and 24 deletions

View File

@@ -3,7 +3,7 @@ require "rails_helper"
describe Tenant do
describe ".resolve_host" do
before do
allow(ActionMailer::Base).to receive(:default_url_options).and_return({ host: "consul.dev" })
allow(Tenant).to receive(:default_url_options).and_return({ host: "consul.dev" })
end
it "returns nil for empty hosts" do
@@ -85,7 +85,7 @@ describe Tenant do
context "default host contains subdomains" do
before do
allow(ActionMailer::Base).to receive(:default_url_options).and_return({ host: "demo.consul.dev" })
allow(Tenant).to receive(:default_url_options).and_return({ host: "demo.consul.dev" })
end
it "ignores subdomains already present in the default host" do
@@ -120,7 +120,7 @@ describe Tenant do
context "default host is similar to development and test domains" do
before do
allow(ActionMailer::Base).to receive(:default_url_options).and_return({ host: "mylvh.me" })
allow(Tenant).to receive(:default_url_options).and_return({ host: "mylvh.me" })
end
it "returns nil for the default host" do