Skip to content

Commit

Permalink
DEV: custom fields concern has be refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed Nov 25, 2023
1 parent 7028471 commit 635700a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/custom_wizard/custom_field.rb
Expand Up @@ -234,16 +234,16 @@ def self.external_list
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
Expand Down
4 changes: 2 additions & 2 deletions spec/components/custom_wizard/custom_field_spec.rb
Expand Up @@ -260,11 +260,11 @@
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
Expand Down
8 changes: 4 additions & 4 deletions spec/extensions/custom_field_extensions_spec.rb
Expand Up @@ -21,7 +21,7 @@
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
Expand Down Expand Up @@ -54,7 +54,7 @@
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
Expand Down Expand Up @@ -84,7 +84,7 @@
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
Expand All @@ -104,7 +104,7 @@
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
Expand Down

0 comments on commit 635700a

Please sign in to comment.