Skip to content

Commit

Permalink
spec a 2nd other option
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwoldatwork committed Nov 28, 2024
1 parent 1ec3a25 commit fa6f7b7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/models/question_option_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@
end
end
end

context 'with a question that has an other Question Option already' do
before do
question_option = QuestionOption.create(text: 'Other Option 1', question: option_question, position: 1, value: "123", other_option: true)
@question_option2 = QuestionOption.create(text: 'Another Other Option', question: option_question, position: 2, value: "456", other_option: true)
end

it 'does not save and has an error message' do
expect(@question_option2.errors.messages).to eq({ question_option: ["only one 'other_option' can be true for a question"] })
end
end
end

0 comments on commit fa6f7b7

Please sign in to comment.