2020-11-08 04:24:20 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe CustomWizard::CustomFieldSerializer do
|
|
|
|
fab!(:user) { Fabricate(:user) }
|
2021-09-07 14:06:13 +02:00
|
|
|
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2023-09-28 14:47:22 +02:00
|
|
|
before do
|
2023-09-28 15:27:24 +02:00
|
|
|
stub_out_subscription_classes
|
2023-09-28 14:47:22 +02:00
|
|
|
end
|
|
|
|
|
2020-11-08 04:24:20 +01:00
|
|
|
it 'should return custom field attributes' do
|
|
|
|
custom_field_json['custom_fields'].each do |field_json|
|
|
|
|
CustomWizard::CustomField.new(nil, field_json).save
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-08 04:24:20 +01:00
|
|
|
json = CustomWizard::CustomFieldSerializer.new(
|
2020-11-10 01:56:11 +01:00
|
|
|
CustomWizard::CustomField.find_by_name("topic_field_1"),
|
2020-11-08 04:24:20 +01:00
|
|
|
scope: Guardian.new(user),
|
|
|
|
root: false
|
|
|
|
).as_json
|
|
|
|
expect(json[:name]).to eq("topic_field_1")
|
|
|
|
expect(json[:klass]).to eq("topic")
|
|
|
|
expect(json[:type]).to eq("boolean")
|
2021-03-11 07:30:15 +01:00
|
|
|
expect(json[:serializers]).to match_array(["topic_list_item", "topic_view"])
|
2020-11-08 04:24:20 +01:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|