2013-02-05 14:16:51 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'discourse'
|
|
|
|
|
|
|
|
describe Discourse do
|
|
|
|
|
|
|
|
before do
|
|
|
|
RailsMultisite::ConnectionManagement.stubs(:current_hostname).returns('foo.com')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'current_hostname' do
|
|
|
|
|
|
|
|
it 'returns the hostname from the current db connection' do
|
|
|
|
Discourse.current_hostname.should == 'foo.com'
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'base_url' do
|
|
|
|
context 'when ssl is off' do
|
|
|
|
before do
|
|
|
|
SiteSetting.expects(:use_ssl?).returns(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a non-ssl base url' do
|
|
|
|
Discourse.base_url.should == "http://foo.com"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when ssl is on' do
|
|
|
|
before do
|
|
|
|
SiteSetting.expects(:use_ssl?).returns(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a non-ssl base url' do
|
|
|
|
Discourse.base_url.should == "https://foo.com"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a non standard port specified' do
|
|
|
|
before do
|
|
|
|
SiteSetting.stubs(:port).returns(3000)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the non standart port in the base url" do
|
|
|
|
Discourse.base_url.should == "http://foo.com:3000"
|
|
|
|
end
|
2013-05-10 16:58:23 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-09-06 03:28:37 -04:00
|
|
|
context '#site_contact_user' do
|
2013-05-10 16:58:23 -04:00
|
|
|
|
|
|
|
let!(:admin) { Fabricate(:admin) }
|
2013-05-31 11:41:40 -04:00
|
|
|
let!(:another_admin) { Fabricate(:admin) }
|
2013-05-10 16:58:23 -04:00
|
|
|
|
2013-09-06 03:28:37 -04:00
|
|
|
it 'returns the user specified by the site setting site_contact_username' do
|
|
|
|
SiteSetting.stubs(:site_contact_username).returns(another_admin.username)
|
|
|
|
Discourse.site_contact_user.should == another_admin
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
2013-05-10 16:58:23 -04:00
|
|
|
it 'returns the first admin user otherwise' do
|
2013-09-06 03:28:37 -04:00
|
|
|
SiteSetting.stubs(:site_contact_username).returns(nil)
|
|
|
|
Discourse.site_contact_user.should == admin
|
2013-05-10 16:58:23 -04:00
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
2013-07-31 17:26:34 -04:00
|
|
|
context "#store" do
|
|
|
|
|
|
|
|
it "returns LocalStore by default" do
|
|
|
|
Discourse.store.should be_a(LocalStore)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns S3Store when S3 is enabled" do
|
|
|
|
SiteSetting.expects(:enable_s3_uploads?).returns(true)
|
|
|
|
Discourse.store.should be_a(S3Store)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|