diff --git a/lib/discourse_data_explorer/data_explorer.rb b/lib/discourse_data_explorer/data_explorer.rb index 8f01b1d..ff43fa5 100644 --- a/lib/discourse_data_explorer/data_explorer.rb +++ b/lib/discourse_data_explorer/data_explorer.rb @@ -198,11 +198,9 @@ module ::DiscourseDataExplorer .includes(support_info[:include]) .order(:id) - ret[cls] = ActiveModel::ArraySerializer.new( - all_objs, - each_serializer: support_info[:serializer], - only: support_info[:only], - ) + opts = { each_serializer: support_info[:serializer] } + opts[:only] = support_info[:only] if support_info[:only] + ret[cls] = ActiveModel::ArraySerializer.new(all_objs, **opts) end [ret, col_map] end diff --git a/spec/data_explorer_spec.rb b/spec/data_explorer_spec.rb index af0385b..9fa562b 100644 --- a/spec/data_explorer_spec.rb +++ b/spec/data_explorer_spec.rb @@ -100,6 +100,9 @@ describe DiscourseDataExplorer::DataExplorer do records = relations[:topic].object records.map { |t| BasicTopicSerializer.new(t, root: false).as_json } }.not_to raise_error + + json = relations[:topic].as_json + expect(json).to include(BasicTopicSerializer.new(topic, root: false).as_json) end it "chooses the correct serializer for tag_group" do