mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: introduces list/compact_list components
This commit is contained in:
@@ -306,7 +306,7 @@ describe SiteSettings::TypeSupervisor do
|
||||
settings.setting(:type_url_list, 'string', type: 'url_list')
|
||||
settings.setting(:type_enum_choices, '2', type: 'enum', choices: ['1', '2'])
|
||||
settings.setting(:type_enum_class, 'a', enum: 'TestEnumClass2')
|
||||
settings.setting(:type_list, 'a', type: 'list', choices: ['a', 'b'])
|
||||
settings.setting(:type_list, 'a', type: 'list', choices: ['a', 'b'], list_type: 'compact')
|
||||
settings.refresh!
|
||||
end
|
||||
|
||||
@@ -336,6 +336,10 @@ describe SiteSettings::TypeSupervisor do
|
||||
expect(settings.type_supervisor.type_hash(:type_list)[:choices]).to eq ['a', 'b']
|
||||
end
|
||||
|
||||
it 'returns list list_type' do
|
||||
expect(settings.type_supervisor.type_hash(:type_list)[:list_type]).to eq 'compact'
|
||||
end
|
||||
|
||||
it 'returns enum choices' do
|
||||
hash = settings.type_supervisor.type_hash(:type_enum_choices)
|
||||
expect(hash[:valid_values]).to eq [{ name: '1', value: '1' }, { name: '2', value: '2' }]
|
||||
|
||||
@@ -114,4 +114,11 @@ describe ThemeSettingsManager do
|
||||
expect { string_setting.value = ("a" * 21) }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
end
|
||||
|
||||
context "List" do
|
||||
it "can have a list type" do
|
||||
list_setting = find_by_name(:compact_list_setting)
|
||||
expect(list_setting.list_type).to eq("compact")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,4 +82,11 @@ describe ThemeSettingsParser do
|
||||
expect(choices.length).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
context "list setting" do
|
||||
it "supports list type" do
|
||||
list_type = loader.find_by_name(:compact_list_setting)[:opts][:list_type]
|
||||
expect(list_type).to eq("compact")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,6 +37,12 @@ list_setting:
|
||||
description: "help text"
|
||||
default: "name|age|last name"
|
||||
|
||||
compact_list_setting:
|
||||
type: list
|
||||
list_type: compact
|
||||
description: "help text"
|
||||
default: "name|age|last name"
|
||||
|
||||
enum_setting:
|
||||
default: "trust level 4"
|
||||
type: enum
|
||||
|
||||
Reference in New Issue
Block a user