Skip to content

Commit

Permalink
Add spec for SubmissionParametersProjection
Browse files Browse the repository at this point in the history
  • Loading branch information
delonnewman committed Sep 27, 2024
1 parent 70bfd66 commit 33b34f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def project

def answers_attributes
survey.questions.each_with_object({}) do |q, h|
h[q.id] = %i[answer_id reply_id survey_id question_type_id value]
h[q.id] = %i[question_id reply_id survey_id question_type_id value]
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

describe Dragnet::Survey::SubmissionParametersProjection do
subject(:projection) { described_class.new(survey) }

let(:survey) { Dragnet::Survey.generate! }

it 'includes id and survey_id' do
expect(projection.project).to include(:id, :survey_id)
end

it 'includes the correct attributes that are required for answer submission' do
attributes = %i[question_id reply_id survey_id question_type_id value]

expect(projection.project.last[:answers_attributes].values.first).to eq(attributes)
end
end

0 comments on commit 33b34f5

Please sign in to comment.