0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00
discourse-custom-wizard/spec/serializers/custom_wizard/custom_field_serializer_spec.rb

30 Zeilen
900 B
Ruby

# frozen_string_literal: true
require_relative '../../plugin_helper'
describe CustomWizard::CustomFieldSerializer do
fab!(:user) { Fabricate(:user) }
2021-03-11 07:30:15 +01:00
let(:custom_field_json) {
JSON.parse(File.open(
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/custom_field/custom_fields.json"
).read)
}
2021-03-11 07:30:15 +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
json = CustomWizard::CustomFieldSerializer.new(
2020-11-10 01:56:11 +01:00
CustomWizard::CustomField.find_by_name("topic_field_1"),
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"])
end
2021-03-11 07:30:15 +01:00
end