2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-16 19:48:57 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
require_dependency 'category'
|
|
|
|
|
|
|
|
describe CategorySerializer do
|
|
|
|
let(:category) { Fabricate(:category) }
|
|
|
|
|
|
|
|
it "includes custom fields" do
|
2019-03-25 10:29:56 +08:00
|
|
|
json = described_class.new(category, scope: Guardian.new, root: false).as_json
|
|
|
|
expect(json[:custom_fields]).to be_empty
|
|
|
|
|
2019-03-16 19:48:57 +08:00
|
|
|
category.custom_fields["enable_marketplace"] = true
|
|
|
|
category.save_custom_fields
|
|
|
|
|
|
|
|
json = described_class.new(category, scope: Guardian.new, root: false).as_json
|
|
|
|
expect(json[:custom_fields]).to be_present
|
|
|
|
end
|
|
|
|
end
|