Show answers with attachments in additional info

We weren't showing the details of answers without a description, even if
they had images, videos or documents. Some users found that behavior
unexpected since the description isn't a mandatory field and so they
left it blank, but they added images to that answer and they didn't
appear on the poll page.

Note we had a condition not to show the title of an answer when it had
no description. I think that condition was redundant because answers
without a description weren't loaded in the first place. Anyway, that
condition doesn't make sense anymore because we're displaying answers
with images but no description.
This commit is contained in:
Javi Martín
2021-09-05 02:14:22 +02:00
parent 25465e71ea
commit 6d26ce57cb
6 changed files with 67 additions and 4 deletions

View File

@@ -2,4 +2,36 @@ require "rails_helper"
describe Poll::Question::Answer do
it_behaves_like "globalizable", :poll_question_answer
describe "#with_content" do
it "returns answers with a description" do
answer = create(:poll_question_answer, description: "I've got a description")
expect(Poll::Question::Answer.with_content).to eq [answer]
end
it "returns answers with images and no description" do
answer = create(:poll_question_answer, :with_image, description: "")
expect(Poll::Question::Answer.with_content).to eq [answer]
end
it "returns answers with documents and no description" do
question = create(:poll_question_answer, :with_document, description: "")
expect(Poll::Question::Answer.with_content).to eq [question]
end
it "returns answers with videos and no description" do
question = create(:poll_question_answer, :with_video, description: "")
expect(Poll::Question::Answer.with_content).to eq [question]
end
it "does not return answers with no description and no images, documents nor videos" do
create(:poll_question_answer, description: "")
expect(Poll::Question::Answer.with_content).to be_empty
end
end
end