Sha256: 6a8cc701fb24c0f429173e731df4ab3a5e431da65a2d916c5b266584508c4c14

Contents?: true

Size: 1004 Bytes

Versions: 19

Compression:

Stored size: 1004 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

describe Decidim::Surveys::SurveyUserAnswers do
  let!(:survey) { create(:survey) }
  let!(:user_1) { create(:user, organization: survey.feature.organization) }
  let!(:user_2) { create(:user, organization: survey.feature.organization) }
  let!(:survey_questions) { 3.downto(1).map { |n| create :survey_question, survey: survey, position: n } }
  let!(:survey_answers_user_1) { survey_questions.map { |question| create :survey_answer, user: user_1, survey: survey, question: question } }
  let!(:survey_answers_user_2) { survey_questions.map { |question| create :survey_answer, user: user_2, survey: survey, question: question } }

  subject { described_class.new(survey) }

  it "returns the user answers for each user" do
    result = subject.query

    expect(result[0]).to eq(survey_answers_user_1.sort { |answer| answer.question.position })
    expect(result[1]).to eq(survey_answers_user_2.sort { |answer| answer.question.position })
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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