From fa6f7b72e0ece7e012858e10d306729a4df9df21 Mon Sep 17 00:00:00 2001 From: Ryan Wold Date: Wed, 27 Nov 2024 17:23:23 -0800 Subject: [PATCH] spec a 2nd other option --- spec/models/question_option_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/models/question_option_spec.rb b/spec/models/question_option_spec.rb index 325dc75eb..f557a0ee5 100644 --- a/spec/models/question_option_spec.rb +++ b/spec/models/question_option_spec.rb @@ -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