Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions app/models/question/selection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,6 @@ def none_of_the_above_question_text
"#{none_of_the_above_question.question_text} #{I18n.t('page.optional')}"
end

def selection=(value)
# TODO: This setter can be removed after 15/06/2026
if allow_multiple_answers?
if value.include?(I18n.t("page.none_of_the_above", locale: :en)) || value.include?(I18n.t("page.none_of_the_above", locale: :cy))
super([NONE_OF_THE_ABOVE_VALUE])
return
end
elsif value == I18n.t("page.none_of_the_above", locale: :en) || value == I18n.t("page.none_of_the_above", locale: :cy)
super(NONE_OF_THE_ABOVE_VALUE)
return
end

super(value)
end

private

def clear_none_of_the_above_answer_if_not_selected
Expand Down
32 changes: 0 additions & 32 deletions spec/models/question/selection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -761,36 +761,4 @@
end
end
end

describe "backwards compatibility for none of the above option" do
let(:is_optional) { true }

context "when the selection question is a checkbox" do
let(:only_one_option) { "false" }

it "sets the selection to ['none_of_the_above'] when attempting to set to the English localised translation" do
question.selection = [I18n.t("page.none_of_the_above")]
expect(question.selection).to eq([Question::Selection::NONE_OF_THE_ABOVE_VALUE])
end

it "sets the selection to ['none_of_the_above'] when attempting to set to the Welsh localised translation" do
question.selection = [I18n.t("page.none_of_the_above", locale: :cy)]
expect(question.selection).to eq([Question::Selection::NONE_OF_THE_ABOVE_VALUE])
end
end

context "when the selection question is a radio button" do
let(:only_one_option) { "true" }

it "sets the selection to 'none_of_the_above' when attempting to set to the English localised translation" do
question.selection = I18n.t("page.none_of_the_above")
expect(question.selection).to eq(Question::Selection::NONE_OF_THE_ABOVE_VALUE)
end

it "sets the selection to 'none_of_the_above' when attempting to set to the Welsh localised translation" do
question.selection = I18n.t("page.none_of_the_above", locale: :cy)
expect(question.selection).to eq(Question::Selection::NONE_OF_THE_ABOVE_VALUE)
end
end
end
end