-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
119 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,14 @@ | |
described_class.tenants(nil) | ||
end | ||
end | ||
|
||
context 'when tenant_list param is empty' do | ||
it 'calls Account.all' do | ||
expect(Account).to receive(:all) | ||
described_class.tenants([]) | ||
end | ||
end | ||
|
||
context 'when tenant_list param is a string' do | ||
it 'calls Account.where' do | ||
expect(Account).to receive(:where).with(cname: 'foo bar baz') | ||
|
@@ -261,6 +263,7 @@ | |
Site.update(account: account) | ||
Site.instance.admin_emails = ["[email protected]", "[email protected]"] | ||
end | ||
|
||
it 'switches to current tenant database and returns Site admin_emails' do | ||
expect(Apartment::Tenant).to receive(:switch).with(account.tenant).and_yield | ||
expect(account.admin_emails).to match_array(["[email protected]", "[email protected]"]) | ||
|
@@ -274,6 +277,7 @@ | |
Site.update(account: account) | ||
Site.instance.admin_emails = ["[email protected]", "[email protected]"] | ||
end | ||
|
||
it 'switches to current tenant database updates Site admin_emails' do | ||
expect(Apartment::Tenant).to receive(:switch).with(account.tenant).exactly(3).times.and_yield | ||
expect(account.admin_emails).to match_array(["[email protected]", "[email protected]"]) | ||
|
@@ -288,19 +292,23 @@ | |
context 'default setting for test environment' do | ||
it { is_expected.to be false } | ||
end | ||
|
||
context 'single tenant in production environment' do | ||
before do | ||
allow(Settings.multitenancy).to receive(:enabled).and_return false | ||
allow(Rails.env).to receive(:test?).and_return false | ||
end | ||
|
||
it { is_expected.to be false } | ||
end | ||
|
||
context 'default tenant in a multitenant production environment' do | ||
before do | ||
allow(Settings.multitenancy).to receive(:enabled).and_return true | ||
allow(Rails.env).to receive(:test?).and_return false | ||
allow(Apartment::Tenant).to receive(:current_tenant).and_return Apartment::Tenant.default_tenant | ||
end | ||
|
||
it { is_expected.to be true } | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,10 +56,12 @@ | |
|
||
it { is_expected.to be_empty } | ||
end | ||
|
||
context "set a value" do | ||
before { instance.admin_emails = "[email protected]" } | ||
subject { instance.admin_emails } | ||
|
||
before { instance.admin_emails = "[email protected]" } | ||
|
||
it { is_expected.to be_empty } | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.