diff --git a/app/models/app_config.rb b/app/models/app_config.rb index 33b29956ddb667f0b66fddbb7f041572e66df15e..f84a0f46cdbfcb919fc97706522181ee9371d546 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 2ce2d8a5fc50a3f617199021c0967bf736d0fd49..d2f974c5eb8c5f584940c833104ac0ee235dcf5b 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