Fix bug in :pod_uri generation.

This commit is contained in:
Sarah Mei 2010-12-24 13:00:06 -08:00
parent 1f67cc2485
commit 5ae16c15a3
2 changed files with 44 additions and 0 deletions

View file

@ -40,6 +40,9 @@ class AppConfig
def self.generate_pod_uri
require 'uri'
unless self.config_vars[:pod_url] =~ /^(https?:\/\/)/
self.config_vars[:pod_url] = "http://#{self.config_vars[:pod_url]}"
end
begin
self.config_vars[:pod_uri] = URI.parse(self.config_vars[:pod_url])
rescue

View file

@ -0,0 +1,41 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe AppConfig do
describe ".generate_pod_uri" do
before do
@environment_vars = AppConfig.config_vars
AppConfig.config_vars = {}
end
after do
AppConfig.config_vars = @environment_vars
end
describe "when pod_url is prefixed with protocol" do
it "generates a URI with a host for http" do
AppConfig[:pod_url] = "http://oscar.joindiaspora.com"
AppConfig.generate_pod_uri
AppConfig[:pod_uri].host.should == "oscar.joindiaspora.com"
end
it "generates a URI with a host for https" do
AppConfig[:pod_url] = "https://oscar.joindiaspora.com"
AppConfig.generate_pod_uri
AppConfig[:pod_uri].host.should == "oscar.joindiaspora.com"
end
end
describe "when pod_url is not prefixed with protocol" do
it "generates a URI with a host" do
AppConfig[:pod_url] = "oscar.joindiaspora.com"
AppConfig.generate_pod_uri
AppConfig[:pod_uri].host.should == "oscar.joindiaspora.com"
end
it "adds http:// to the front of the pod_url" do
AppConfig[:pod_url] = "oscar.joindiaspora.com"
AppConfig.generate_pod_uri
AppConfig[:pod_url].should == "http://oscar.joindiaspora.com"
end
end
end
end