0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-05-19 23:40:07 +02: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 = []
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?
field_types.each do |name, type|
if meta_data.present?
meta_data.each do |name, data|
unless list.any? { |field| field.name === name }
field = new(
'external',
name: name,
klass: klass,
type: type
type: data.type
)
external.push(field)
end

Datei anzeigen

@ -260,11 +260,11 @@ describe CustomWizard::CustomField do
expect(CustomWizard::CustomField.list_by(:serializers, ['post']).length).to eq(0)
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
end
it "lists all custom field records" do
it "all custom field records" do
expect(CustomWizard::CustomField.full_list.length).to be > 2
end
end

Datei anzeigen

@ -21,7 +21,7 @@ describe "custom field extensions" do
context "topic" do
it "registers topic custom fields" do
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
it "adds topic custom fields to the topic_view serializer" do
@ -54,7 +54,7 @@ describe "custom field extensions" do
context "post" do
it "registers post custom fields" do
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
it "adds post custom fields to the post serializer" do
@ -84,7 +84,7 @@ describe "custom field extensions" do
context "category" do
it "registers" do
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
it "adds custom fields to the basic category serializer" do
@ -104,7 +104,7 @@ describe "custom field extensions" do
context "group" do
it "registers" do
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
it "adds custom fields to the basic group serializer" do