2013-02-05 14:16:51 -05:00
|
|
|
require 'spec_helper'
|
2013-06-12 22:41:27 -04:00
|
|
|
require_dependency 'site_setting'
|
|
|
|
require_dependency 'site_setting_extension'
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
describe SiteSetting do
|
|
|
|
|
2014-02-12 15:55:44 -05:00
|
|
|
describe "normalized_embeddable_host" do
|
|
|
|
it 'returns the `embeddable_host` value' do
|
|
|
|
SiteSetting.stubs(:embeddable_host).returns("eviltrout.com")
|
2015-01-05 11:04:23 -05:00
|
|
|
expect(SiteSetting.normalized_embeddable_host).to eq("eviltrout.com")
|
2014-02-12 15:55:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'strip http from `embeddable_host` value' do
|
|
|
|
SiteSetting.stubs(:embeddable_host).returns("http://eviltrout.com")
|
2015-01-05 11:04:23 -05:00
|
|
|
expect(SiteSetting.normalized_embeddable_host).to eq("eviltrout.com")
|
2014-02-12 15:55:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'strip https from `embeddable_host` value' do
|
|
|
|
SiteSetting.stubs(:embeddable_host).returns("https://eviltrout.com")
|
2015-01-05 11:04:23 -05:00
|
|
|
expect(SiteSetting.normalized_embeddable_host).to eq("eviltrout.com")
|
2014-02-12 15:55:44 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-26 11:27:59 -05:00
|
|
|
describe 'topic_title_length' do
|
|
|
|
it 'returns a range of min/max topic title length' do
|
2015-01-05 11:04:23 -05:00
|
|
|
expect(SiteSetting.topic_title_length).to eq(
|
2013-04-10 08:54:10 -04:00
|
|
|
(SiteSetting.defaults[:min_topic_title_length]..SiteSetting.defaults[:max_topic_title_length])
|
2015-01-05 11:04:23 -05:00
|
|
|
)
|
2013-02-26 11:27:59 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-28 13:54:12 -05:00
|
|
|
describe 'post_length' do
|
|
|
|
it 'returns a range of min/max post length' do
|
2015-01-05 11:04:23 -05:00
|
|
|
expect(SiteSetting.post_length).to eq(SiteSetting.defaults[:min_post_length]..SiteSetting.defaults[:max_post_length])
|
2013-02-28 13:54:12 -05:00
|
|
|
end
|
|
|
|
end
|
2013-06-04 17:58:25 -04:00
|
|
|
|
|
|
|
describe 'private_message_title_length' do
|
|
|
|
it 'returns a range of min/max pm topic title length' do
|
|
|
|
expect(SiteSetting.private_message_title_length).to eq(SiteSetting.defaults[:min_private_message_title_length]..SiteSetting.defaults[:max_topic_title_length])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-22 23:35:06 -04:00
|
|
|
describe 'in test we do some judo to ensure SiteSetting is always reset between tests' do
|
|
|
|
|
|
|
|
it 'is always the correct default' do
|
|
|
|
expect(SiteSetting.contact_email).to eq('')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets a setting' do
|
|
|
|
SiteSetting.contact_email = 'sam@sam.com'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is always the correct default' do
|
|
|
|
expect(SiteSetting.contact_email).to eq('')
|
|
|
|
end
|
2013-06-21 16:31:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "anonymous_homepage" do
|
|
|
|
it "returns latest" do
|
|
|
|
expect(SiteSetting.anonymous_homepage).to eq('latest')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "top_menu" do
|
2014-06-02 21:48:52 -04:00
|
|
|
before(:each) { SiteSetting.top_menu = 'one,-nope|two|three,-not|four,ignored|category/xyz' }
|
2013-06-22 23:35:06 -04:00
|
|
|
|
2013-06-21 16:31:40 -04:00
|
|
|
describe "items" do
|
|
|
|
let(:items) { SiteSetting.top_menu_items }
|
|
|
|
|
|
|
|
it 'returns TopMenuItem objects' do
|
|
|
|
expect(items[0]).to be_kind_of(TopMenuItem)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "homepage" do
|
|
|
|
it "has homepage" do
|
|
|
|
expect(SiteSetting.homepage).to eq('one')
|
|
|
|
end
|
|
|
|
end
|
2013-06-22 23:35:06 -04:00
|
|
|
end
|
|
|
|
|
2013-12-16 05:44:59 -05:00
|
|
|
describe "scheme" do
|
|
|
|
|
|
|
|
it "returns http when ssl is disabled" do
|
2014-01-08 18:51:38 -05:00
|
|
|
SiteSetting.expects(:use_https).returns(false)
|
2015-01-05 11:04:23 -05:00
|
|
|
expect(SiteSetting.scheme).to eq("http")
|
2013-12-16 05:44:59 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns https when using ssl" do
|
2014-01-08 18:51:38 -05:00
|
|
|
SiteSetting.expects(:use_https).returns(true)
|
2015-01-05 11:04:23 -05:00
|
|
|
expect(SiteSetting.scheme).to eq("https")
|
2013-12-16 05:44:59 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|