0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 01:10:28 +01:00

DEV: custom fields concern has be refactored

6aa69bdaea
Dieser Commit ist enthalten in:
Angus McLeod 2023-11-25 11:35:21 +01:00
Ursprung 7028471603
Commit 635700a51e
3 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -234,16 +234,16 @@ class ::CustomWizard::CustomField
external = [] external = []
CLASSES.keys.each do |klass| CLASSES.keys.each do |klass|
field_types = klass.to_s.classify.constantize.custom_field_types meta_data = klass.to_s.classify.constantize.send('custom_field_meta_data')
if field_types.present? if meta_data.present?
field_types.each do |name, type| meta_data.each do |name, data|
unless list.any? { |field| field.name === name } unless list.any? { |field| field.name === name }
field = new( field = new(
'external', 'external',
name: name, name: name,
klass: klass, klass: klass,
type: type type: data.type
) )
external.push(field) external.push(field)
end end

Datei anzeigen

@ -260,11 +260,11 @@ describe CustomWizard::CustomField do
expect(CustomWizard::CustomField.list_by(:serializers, ['post']).length).to eq(0) expect(CustomWizard::CustomField.list_by(:serializers, ['post']).length).to eq(0)
end end
it "lists custom field records added by other plugins " do it "custom field records added by other plugins " do
expect(CustomWizard::CustomField.external_list.length).to be > 2 expect(CustomWizard::CustomField.external_list.length).to be > 2
end end
it "lists all custom field records" do it "all custom field records" do
expect(CustomWizard::CustomField.full_list.length).to be > 2 expect(CustomWizard::CustomField.full_list.length).to be > 2
end end
end end

Datei anzeigen

@ -21,7 +21,7 @@ describe "custom field extensions" do
context "topic" do context "topic" do
it "registers topic custom fields" do it "registers topic custom fields" do
topic topic
expect(Topic.get_custom_field_type("topic_field_1")).to eq(:boolean) expect(Topic.get_custom_field_descriptor("topic_field_1").type).to eq(:boolean)
end end
it "adds topic custom fields to the topic_view serializer" do it "adds topic custom fields to the topic_view serializer" do
@ -54,7 +54,7 @@ describe "custom field extensions" do
context "post" do context "post" do
it "registers post custom fields" do it "registers post custom fields" do
post post
expect(Post.get_custom_field_type("post_field_1")).to eq(:integer) expect(Post.get_custom_field_descriptor("post_field_1").type).to eq(:integer)
end end
it "adds post custom fields to the post serializer" do it "adds post custom fields to the post serializer" do
@ -84,7 +84,7 @@ describe "custom field extensions" do
context "category" do context "category" do
it "registers" do it "registers" do
category category
expect(Category.get_custom_field_type("category_field_1")).to eq(:json) expect(Category.get_custom_field_descriptor("category_field_1").type).to eq(:json)
end end
it "adds custom fields to the basic category serializer" do it "adds custom fields to the basic category serializer" do
@ -104,7 +104,7 @@ describe "custom field extensions" do
context "group" do context "group" do
it "registers" do it "registers" do
group group
expect(Group.get_custom_field_type("group_field_1")).to eq(:string) expect(Group.get_custom_field_descriptor("group_field_1").type).to eq(:string)
end end
it "adds custom fields to the basic group serializer" do it "adds custom fields to the basic group serializer" do