diff --git a/app/models/app_config.rb b/app/models/app_config.rb index 33b29956d..f84a0f46c 100644 --- a/app/models/app_config.rb +++ b/app/models/app_config.rb @@ -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 diff --git a/spec/models/app_config_spec.rb b/spec/models/app_config_spec.rb index 2ce2d8a5f..d2f974c5e 100644 --- a/spec/models/app_config_spec.rb +++ b/spec/models/app_config_spec.rb @@ -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 \ No newline at end of file