2022-12-09 18:28:17 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "rails_helper"
|
|
|
|
|
2023-10-25 20:54:48 -07:00
|
|
|
describe UseCase::DataExport::Reactions, :data_export do
|
2022-12-09 18:28:17 -08:00
|
|
|
include ActiveSupport::Testing::TimeHelpers
|
|
|
|
|
2023-10-25 20:54:48 -07:00
|
|
|
context "when user doesn't have any reactions" do
|
|
|
|
it "returns an empty set of reactions" do
|
|
|
|
expect(json_file("reactions.json")).to eq(
|
2022-12-09 18:28:17 -08:00
|
|
|
{
|
2023-10-25 21:05:14 -07:00
|
|
|
reactions: [],
|
2022-12-09 18:28:17 -08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when user has smiled some things" do
|
|
|
|
let(:answer) { FactoryBot.create(:answer, user:) }
|
|
|
|
let(:comment) { FactoryBot.create(:comment, user:, answer:) }
|
|
|
|
|
2023-10-25 20:54:48 -07:00
|
|
|
let!(:reactions) do
|
2022-12-09 18:28:17 -08:00
|
|
|
[
|
|
|
|
travel_to(Time.utc(2022, 12, 10, 13, 37, 42)) { FactoryBot.create(:comment_smile, user:, parent: comment) },
|
|
|
|
travel_to(Time.utc(2022, 12, 10, 13, 39, 21)) { FactoryBot.create(:smile, user:, parent: answer) }
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2023-10-25 20:54:48 -07:00
|
|
|
it "returns the reactions as json" do
|
|
|
|
expect(json_file("reactions.json")).to eq(
|
2022-12-09 18:28:17 -08:00
|
|
|
{
|
2023-10-25 20:54:48 -07:00
|
|
|
reactions: [
|
2022-12-09 18:28:17 -08:00
|
|
|
{
|
2023-10-25 20:54:48 -07:00
|
|
|
id: reactions[0].id,
|
2022-12-09 18:28:17 -08:00
|
|
|
user_id: user.id,
|
2023-10-25 20:54:48 -07:00
|
|
|
parent_id: reactions[0].parent_id,
|
2022-12-09 18:28:17 -08:00
|
|
|
parent_type: "Comment",
|
|
|
|
content: "🙂",
|
|
|
|
created_at: "2022-12-10T13:37:42.000Z",
|
|
|
|
updated_at: "2022-12-10T13:37:42.000Z"
|
|
|
|
},
|
|
|
|
{
|
2023-10-25 20:54:48 -07:00
|
|
|
id: reactions[1].id,
|
2022-12-09 18:28:17 -08:00
|
|
|
user_id: user.id,
|
2023-10-25 20:54:48 -07:00
|
|
|
parent_id: reactions[1].parent_id,
|
2022-12-09 18:28:17 -08:00
|
|
|
parent_type: "Answer",
|
|
|
|
content: "🙂",
|
|
|
|
created_at: "2022-12-10T13:39:21.000Z",
|
|
|
|
updated_at: "2022-12-10T13:39:21.000Z"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|