Fix the spec for enum site settings
This commit is contained in:
parent
44ee7587c0
commit
f97d434174
|
@ -206,36 +206,50 @@ describe SiteSettingExtension do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# describe 'enum setting' do
|
describe 'enum setting' do
|
||||||
# before do
|
|
||||||
# @enum_class = Enum.new(:test) # not a valid site setting class
|
|
||||||
# @enum_class.stubs(:translate_names?).returns(false)
|
|
||||||
# settings.setting(:test_enum, 'en', enum: @enum_class) # would never do this in practice
|
|
||||||
# settings.refresh!
|
|
||||||
# end
|
|
||||||
|
|
||||||
# it 'should have the correct default' do
|
class TestEnumClass
|
||||||
# expect(settings.test_enum).to eq('en')
|
def self.valid_value?(v)
|
||||||
# end
|
true
|
||||||
|
end
|
||||||
|
def self.values
|
||||||
|
['en']
|
||||||
|
end
|
||||||
|
def self.translate_names?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# it 'should not hose all_settings' do
|
let :test_enum_class do
|
||||||
# settings.all_settings.detect {|s| s[:setting] == :test_enum }.should be_present
|
TestEnumClass
|
||||||
# end
|
end
|
||||||
|
|
||||||
# context 'when overridden' do
|
before do
|
||||||
|
settings.setting(:test_enum, 'en', enum: test_enum_class)
|
||||||
|
settings.refresh!
|
||||||
|
end
|
||||||
|
|
||||||
# it 'stores valid values' do
|
it 'should have the correct default' do
|
||||||
# @enum_class.expects(:valid_value?).with('fr').returns(true)
|
expect(settings.test_enum).to eq('en')
|
||||||
# settings.test_enum = 'fr'
|
end
|
||||||
# expect(settings.test_enum).to eq('fr')
|
|
||||||
# end
|
|
||||||
|
|
||||||
# it 'rejects invalid values' do
|
it 'should not hose all_settings' do
|
||||||
# @enum_class.expects(:valid_value?).with('gg').returns(false)
|
settings.all_settings.detect {|s| s[:setting] == :test_enum }.should be_present
|
||||||
# expect {settings.test_enum = 'gg' }.to raise_error(Discourse::InvalidParameters)
|
end
|
||||||
# end
|
|
||||||
# end
|
context 'when overridden' do
|
||||||
# end
|
it 'stores valid values' do
|
||||||
|
test_enum_class.expects(:valid_value?).with('fr').returns(true)
|
||||||
|
settings.test_enum = 'fr'
|
||||||
|
expect(settings.test_enum).to eq('fr')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'rejects invalid values' do
|
||||||
|
test_enum_class.expects(:valid_value?).with('gg').returns(false)
|
||||||
|
expect {settings.test_enum = 'gg' }.to raise_error(Discourse::InvalidParameters)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'a setting with a category' do
|
describe 'a setting with a category' do
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Reference in New Issue