Keep pod_url and pod_uri settings in sync.
This commit is contained in:
parent
31a5ef19de
commit
828cbab792
2 changed files with 30 additions and 5 deletions
|
|
@ -75,8 +75,11 @@ HELP
|
|||
end
|
||||
|
||||
def self.[]= (key, value)
|
||||
@@pod_uri = nil if key == :pod_url
|
||||
super
|
||||
if key.to_sym == :pod_url
|
||||
@@pod_uri = nil
|
||||
normalize_pod_url
|
||||
end
|
||||
end
|
||||
|
||||
cattr_accessor :pod_uri
|
||||
|
|
|
|||
|
|
@ -146,10 +146,32 @@ describe AppConfig do
|
|||
pod_uri.scheme.should == "http"
|
||||
pod_uri.host.should == "example.org"
|
||||
end
|
||||
it "clears the cached pod_uri when you set pod_url" do
|
||||
AppConfig[:pod_uri].host.should == "example.org"
|
||||
AppConfig[:pod_url] = "http://joindiaspora.com"
|
||||
AppConfig[:pod_uri].host.should == "joindiaspora.com"
|
||||
end
|
||||
|
||||
describe ".[]=" do
|
||||
describe "when setting pod_url" do
|
||||
context "with a symbol" do
|
||||
it "clears the cached pod_uri" do
|
||||
AppConfig[:pod_uri].host.should == "example.org"
|
||||
AppConfig[:pod_url] = "http://joindiaspora.com"
|
||||
AppConfig[:pod_uri].host.should == "joindiaspora.com"
|
||||
end
|
||||
it "calls normalize_pod_url" do
|
||||
AppConfig.should_receive(:normalize_pod_url).twice
|
||||
AppConfig[:pod_url] = "http://joindiaspora.com"
|
||||
end
|
||||
end
|
||||
context "with a string" do
|
||||
it "clears the cached pod_uri" do
|
||||
AppConfig[:pod_uri].host.should == "example.org"
|
||||
AppConfig['pod_url'] = "http://joindiaspora.com"
|
||||
AppConfig[:pod_uri].host.should == "joindiaspora.com"
|
||||
end
|
||||
it "calls normalize_pod_url" do
|
||||
AppConfig.should_receive(:normalize_pod_url).twice
|
||||
AppConfig['pod_url'] = "http://joindiaspora.com"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue