-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Site obj in global scope is NilSite and never persisted.
- Loading branch information
Showing
8 changed files
with
192 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# NilSite is used to represent the Site in the global tenant in a multitenant environment | ||
# (i.e. Sites only exist on individual tenants and never globally) | ||
class NilSite | ||
class << self | ||
# NilSite must be a singleton like Site | ||
attr_writer :instance | ||
def instance | ||
@instance ||= NilSite.new | ||
end | ||
end | ||
|
||
def id | ||
nil | ||
end | ||
|
||
def account | ||
nil | ||
end | ||
|
||
def application_name | ||
nil | ||
end | ||
|
||
def institution_name | ||
nil | ||
end | ||
|
||
def institution_name_full | ||
nil | ||
end | ||
|
||
def reload | ||
NilSite.instance | ||
end | ||
|
||
def update(*) | ||
false | ||
end | ||
|
||
def admin_emails | ||
[] | ||
end | ||
|
||
def admin_emails=(value) | ||
value | ||
end | ||
|
||
def banner_image? | ||
false | ||
end | ||
|
||
def banner_image | ||
nil | ||
end | ||
|
||
def primary_key | ||
nil | ||
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
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe NilSite do | ||
let(:instance) { described_class.instance } | ||
|
||
describe "#instance" do | ||
subject { described_class.instance } | ||
# 'instance' should always return same obj (i.e. singleton) | ||
it { is_expected.to be instance } | ||
end | ||
|
||
describe "#id" do | ||
subject { instance.id } | ||
it { is_expected.to be nil } | ||
end | ||
|
||
describe "#account" do | ||
subject { instance.account } | ||
it { is_expected.to be nil } | ||
end | ||
|
||
describe "#application_name" do | ||
subject { instance.application_name } | ||
it { is_expected.to be nil } | ||
end | ||
|
||
describe "#institution_name" do | ||
subject { instance.institution_name } | ||
it { is_expected.to be nil } | ||
end | ||
|
||
describe "#institution_name_full" do | ||
subject { instance.institution_name_full } | ||
it { is_expected.to be nil } | ||
end | ||
|
||
describe "#reload" do | ||
subject { instance.reload } | ||
it { is_expected.to be described_class.instance } | ||
end | ||
|
||
describe "#update" do | ||
subject { instance.update(param: 'one') } | ||
it { is_expected.to be false } | ||
end | ||
|
||
describe "#admin_emails" do | ||
context "default value" do | ||
subject { instance.admin_emails } | ||
it { is_expected.to be_empty } | ||
end | ||
context "set a value" do | ||
before { instance.admin_emails = "test@test.org" } | ||
subject { instance.admin_emails } | ||
it { is_expected.to be_empty } | ||
end | ||
end | ||
|
||
describe "#admin_emails=" do | ||
subject { instance.admin_emails = "one@two.org" } | ||
it { is_expected.to eq("one@two.org") } | ||
end | ||
|
||
describe "#banner_image?" do | ||
subject { instance.banner_image? } | ||
it { is_expected.to be false } | ||
end | ||
|
||
describe "#banner_image" do | ||
subject { instance.banner_image } | ||
it { is_expected.to be nil } | ||
end | ||
|
||
describe "#primary_key" do | ||
subject { instance.primary_key } | ||
it { is_expected.to be nil } | ||
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