discourse/spec/components/discourse_spec.rb

82 lines
1.9 KiB
Ruby
Raw Normal View History

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 https is off' do
2013-02-05 14:16:51 -05:00
before do
SiteSetting.expects(:use_https?).returns(false)
2013-02-05 14:16:51 -05:00
end
it 'has a non https base url' do
2013-02-05 14:16:51 -05:00
Discourse.base_url.should == "http://foo.com"
end
end
context 'when https is on' do
2013-02-05 14:16:51 -05:00
before do
SiteSetting.expects(:use_https?).returns(true)
2013-02-05 14:16:51 -05:00
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
end
end
context '#site_contact_user' do
let!(:admin) { Fabricate(:admin) }
let!(:another_admin) { Fabricate(:admin) }
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
it 'returns the first admin user otherwise' do
SiteSetting.stubs(:site_contact_username).returns(nil)
Discourse.site_contact_user.should == admin
end
2013-02-25 11:42:20 -05:00
2013-02-05 14:16:51 -05:00
end
context "#store" do
it "returns LocalStore by default" do
2013-11-05 13:04:47 -05:00
Discourse.store.should be_a(FileStore::LocalStore)
end
it "returns S3Store when S3 is enabled" do
SiteSetting.expects(:enable_s3_uploads?).returns(true)
2013-11-05 13:04:47 -05:00
Discourse.store.should be_a(FileStore::S3Store)
end
end
2013-02-05 14:16:51 -05:00
end