Sha256: 52a86b039a6d45572fbabafd61a2439c7d6caee966f0ece35deb3f9d1b68ad75

Contents?: true

Size: 992 Bytes

Versions: 19

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Surveys
    describe SurveyUserAnswersSerializer do
      let!(:survey) { create(:survey) }
      let!(:user) { create(:user, organization: survey.feature.organization) }
      let!(:survey_questions) { create_list :survey_question, 3, survey: survey }
      let!(:survey_answers) do
        survey_questions.map do |question|
          create :survey_answer, survey: survey, question: question, user: user
        end
      end

      subject do
        described_class.new(survey_answers)
      end

      describe "#serialize" do
        let(:serialized) { subject.serialize }

        it "includes the answer for each question" do
          survey_questions.each_with_index do |question, idx|
            expect(serialized).to include(
              "#{idx + 1}. #{translated(question.body, locale: I18n.locale)}" => survey_answers[idx].body
            )
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.7 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.6 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.5 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.4 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.3 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.2 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.1 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.6.0 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.5.1 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.5.0 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.4.4 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.4.3 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.4.2 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.4.1 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.4.0 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.3.2 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.3.1 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb
decidim-0.3.0 decidim-surveys/spec/services/decidim/surveys/surveys/survey_user_answer_serializer_spec.rb