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
|
|
|
|
|
2013-02-14 12:57:26 -05:00
|
|
|
describe 'call_discourse_hub?' do
|
2013-02-05 14:16:51 -05:00
|
|
|
it 'should be true when enforce_global_nicknames is true and discourse_org_access_key is set' do
|
|
|
|
SiteSetting.enforce_global_nicknames = true
|
2013-06-22 23:35:06 -04:00
|
|
|
SiteSetting.enforce_global_nicknames.should == true
|
2013-02-05 14:16:51 -05:00
|
|
|
SiteSetting.discourse_org_access_key = 'asdfasfsafd'
|
2013-02-14 12:57:26 -05:00
|
|
|
SiteSetting.call_discourse_hub?.should == true
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be false when enforce_global_nicknames is false and discourse_org_access_key is set' do
|
|
|
|
SiteSetting.enforce_global_nicknames = false
|
|
|
|
SiteSetting.discourse_org_access_key = 'asdfasfsafd'
|
2013-02-14 12:57:26 -05:00
|
|
|
SiteSetting.call_discourse_hub?.should == false
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be false when enforce_global_nicknames is true and discourse_org_access_key is not set' do
|
|
|
|
SiteSetting.enforce_global_nicknames = true
|
|
|
|
SiteSetting.discourse_org_access_key = ''
|
2013-02-14 12:57:26 -05:00
|
|
|
SiteSetting.call_discourse_hub?.should == false
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be false when enforce_global_nicknames is false and discourse_org_access_key is not set' do
|
|
|
|
SiteSetting.enforce_global_nicknames = false
|
|
|
|
SiteSetting.discourse_org_access_key = ''
|
2013-02-14 12:57:26 -05:00
|
|
|
SiteSetting.call_discourse_hub?.should == false
|
2013-02-05 14:16:51 -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
|
2013-06-12 22:41:27 -04:00
|
|
|
SiteSetting.topic_title_length.should ==
|
2013-04-10 08:54:10 -04:00
|
|
|
(SiteSetting.defaults[:min_topic_title_length]..SiteSetting.defaults[:max_topic_title_length])
|
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
|
2013-04-10 08:54:10 -04:00
|
|
|
SiteSetting.post_length.should == (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
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|