From 3e143954e3f5c7fbf587e000f1a90d2a6536f61f Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sat, 10 Dec 2022 15:47:54 +0100 Subject: [PATCH] data_export: yeet inbox_entries --- lib/exporter.rb | 1 - lib/use_case/data_export/inbox_entries.rb | 23 -------- .../data_export/inbox_entries_spec.rb | 54 ------------------- 3 files changed, 78 deletions(-) delete mode 100644 lib/use_case/data_export/inbox_entries.rb delete mode 100644 spec/lib/use_case/data_export/inbox_entries_spec.rb diff --git a/lib/exporter.rb b/lib/exporter.rb index eb5101d3..236db967 100644 --- a/lib/exporter.rb +++ b/lib/exporter.rb @@ -7,7 +7,6 @@ require "zip/filesystem" require "use_case/data_export/answers" require "use_case/data_export/appendables" require "use_case/data_export/comments" -require "use_case/data_export/inbox_entries" require "use_case/data_export/mute_rules" require "use_case/data_export/questions" require "use_case/data_export/relationships" diff --git a/lib/use_case/data_export/inbox_entries.rb b/lib/use_case/data_export/inbox_entries.rb deleted file mode 100644 index 04b2efb4..00000000 --- a/lib/use_case/data_export/inbox_entries.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require "use_case/data_export/base" - -module UseCase - module DataExport - class InboxEntries < UseCase::DataExport::Base - def files = { - "inbox_entries.json" => json_file!( - inbox_entries: user.inboxes.map(&method(:collect_inbox_entry)) - ) - } - - def collect_inbox_entry(inbox_entry) - {}.tap do |h| - column_names(::Inbox).each do |field| - h[field] = inbox_entry[field] - end - end - end - end - end -end diff --git a/spec/lib/use_case/data_export/inbox_entries_spec.rb b/spec/lib/use_case/data_export/inbox_entries_spec.rb deleted file mode 100644 index 9682ab76..00000000 --- a/spec/lib/use_case/data_export/inbox_entries_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -require "use_case/data_export/inbox_entries" - -describe UseCase::DataExport::InboxEntries, :data_export do - include ActiveSupport::Testing::TimeHelpers - - context "when user doesn't have anything in their inbox" do - it "returns an empty set of inbox entries" do - expect(json_file("inbox_entries.json")).to eq( - { - inbox_entries: [] - } - ) - end - end - - context "when user has some questions in their inbox" do - let!(:inbox_entries) do - [ - # using `Inbox.create` here as for some reason FactoryBot.create(:inbox) always sets `new` to `nil`??? - travel_to(Time.utc(2022, 12, 10, 13, 37, 42)) { Inbox.create(user:, question: FactoryBot.create(:question), new: false) }, - travel_to(Time.utc(2022, 12, 10, 13, 39, 21)) { Inbox.create(user:, question: FactoryBot.create(:question), new: true) } - ] - end - - it "returns the inbox entries as json" do - expect(json_file("inbox_entries.json")).to eq( - { - inbox_entries: [ - { - id: inbox_entries[0].id, - user_id: user.id, - question_id: inbox_entries[0].question_id, - new: false, - created_at: "2022-12-10T13:37:42.000Z", - updated_at: "2022-12-10T13:37:42.000Z" - }, - { - id: inbox_entries[1].id, - user_id: user.id, - question_id: inbox_entries[1].question_id, - new: true, - created_at: "2022-12-10T13:39:21.000Z", - updated_at: "2022-12-10T13:39:21.000Z" - } - ] - } - ) - end - end -end