Add test for `Exporter#collect_answers`

This commit is contained in:
Karina Kwiatek 2022-07-10 12:27:06 +02:00 committed by Karina Kwiatek
parent 262705c3f0
commit 77ddf2feae
1 changed files with 24 additions and 0 deletions

View File

@ -121,6 +121,30 @@ RSpec.describe Exporter do
end end
end end
describe "#collect_answers" do
let!(:answers) { FactoryBot.create_list(:answer, 25, user: user) }
subject { instance.send(:collect_answers) }
it "collects answers" do
subject
expect(instance.instance_variable_get(:@obj)[:answers]).to eq(answers.map do |a|
{
comment_count: 0,
comments: [],
content: a.content,
created_at: a.reload.created_at,
id: a.id,
question: instance.send(:process_question,
a.question.reload,
include_user: true,
include_answers: false),
smile_count: 0
}
end)
end
end
describe "#collect_smiles" do describe "#collect_smiles" do
let!(:smiles) { FactoryBot.create_list(:smile, 25, user: user) } let!(:smiles) { FactoryBot.create_list(:smile, 25, user: user) }