From b2b6b085d352f0999499de9813cead9e0966418b Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Tue, 29 Oct 2024 11:59:46 +0100 Subject: [PATCH] test: add test for questions order --- .../decidim/forms/user_answers_serializer_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/decidim-forms/spec/serializers/decidim/forms/user_answers_serializer_spec.rb b/decidim-forms/spec/serializers/decidim/forms/user_answers_serializer_spec.rb index cc3b00849e21..ac7f03526841 100644 --- a/decidim-forms/spec/serializers/decidim/forms/user_answers_serializer_spec.rb +++ b/decidim-forms/spec/serializers/decidim/forms/user_answers_serializer_spec.rb @@ -219,6 +219,13 @@ def memory_usage end end end + + describe "questions_hash" do + it "generates a hash of questions ordered by position" do + questions.shuffle! + expect(subject.instance_eval { questions_hash }.keys.map { |key| key[0].to_i }.uniq).to eq(questions.sort_by(&:position).map { |question| question.position + 1 }) + end + end end end end