From b8bd031648afa17fb3952dea17f54ec8c9c30caf Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Mon, 25 Mar 2019 07:59:56 +0530 Subject: [PATCH] FIX: Always include custom fields in CategorySerializer even if it is empty --- app/serializers/category_serializer.rb | 4 ++++ spec/serializers/category_serializer_spec.rb | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/serializers/category_serializer.rb b/app/serializers/category_serializer.rb index 1621397165e..d7973eb0355 100644 --- a/app/serializers/category_serializer.rb +++ b/app/serializers/category_serializer.rb @@ -102,4 +102,8 @@ class CategorySerializer < BasicCategorySerializer def custom_fields object.custom_fields end + + def include_custom_fields? + true + end end diff --git a/spec/serializers/category_serializer_spec.rb b/spec/serializers/category_serializer_spec.rb index 8f5a286427d..05d89c1a3f7 100644 --- a/spec/serializers/category_serializer_spec.rb +++ b/spec/serializers/category_serializer_spec.rb @@ -5,6 +5,9 @@ describe CategorySerializer do let(:category) { Fabricate(:category) } it "includes custom fields" do + json = described_class.new(category, scope: Guardian.new, root: false).as_json + expect(json[:custom_fields]).to be_empty + category.custom_fields["enable_marketplace"] = true category.save_custom_fields