data_export: yeet inbox_entries

This commit is contained in:
Georg Gadinger 2022-12-10 15:47:54 +01:00
parent 3b99e43876
commit 3e143954e3
3 changed files with 0 additions and 78 deletions

View File

@ -7,7 +7,6 @@ require "zip/filesystem"
require "use_case/data_export/answers" require "use_case/data_export/answers"
require "use_case/data_export/appendables" require "use_case/data_export/appendables"
require "use_case/data_export/comments" 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/mute_rules"
require "use_case/data_export/questions" require "use_case/data_export/questions"
require "use_case/data_export/relationships" require "use_case/data_export/relationships"

View File

@ -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

View File

@ -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