diff --git a/app/models/custom/poll/question/answer/exporter.rb b/app/models/custom/poll/question/answer/exporter.rb index ff126a918..3b9116cc9 100644 --- a/app/models/custom/poll/question/answer/exporter.rb +++ b/app/models/custom/poll/question/answer/exporter.rb @@ -29,6 +29,8 @@ def csv_values(voter) def value_of(answer) if answer.question.single_choice? answer.question_answer&.title + elsif answer.question.multiple_choice? + answer.question_answers.order(given_order: :asc).map(&:title).join(";") else answer.open_answer end diff --git a/spec/system/custom/admin/poll/polls_spec.rb b/spec/system/custom/admin/poll/polls_spec.rb index eb5583d96..c78421b35 100644 --- a/spec/system/custom/admin/poll/polls_spec.rb +++ b/spec/system/custom/admin/poll/polls_spec.rb @@ -176,6 +176,12 @@ question_3 = create(:poll_question, :yes_no, poll: poll, title: "Do you have environmental concerns?") create(:poll_answer, question: question_3, question_answer: question_3.question_answers.first, author: user_1) create(:poll_answer, question: question_3, question_answer: nil, author: user_2) + question_4 = create(:poll_question, :multiple_choice, poll: poll, title: "Choose many") + option_a = create(:poll_question_answer, question: question_4, title: "Option A") + option_b = create(:poll_question_answer, question: question_4, title: "Option B") + option_c = create(:poll_question_answer, question: question_4, title: "Option C") + create(:poll_answer, question: question_4, question_answers: [option_a, option_c], author: user_1) + create(:poll_answer, question: question_4, question_answers: [option_b], author: user_2) create(:poll_voter, user: user_1, poll: poll) create(:poll_voter, user: user_2, poll: poll) @@ -185,9 +191,9 @@ header = page.response_headers["Content-Disposition"] expect(header).to match(/^attachment/) expect(header).to match(/filename="questions_to_citizens_questions_answers.csv"$/) - csv_contents = "What is your favourite color?,Do you agree?,Do you have environmental concerns?\n"\ - "Red,Yes,Yes\n"\ - "Blue,No,\n"\ + csv_contents = "What is your favourite color?,Do you agree?,Do you have environmental concerns?,Choose many\n"\ + "Red,Yes,Yes,Option A;Option C\n"\ + "Blue,No,,Option B\n"\ expect(page.body).to eq(csv_contents) end