From 279e9c54a08ab0ba238d96c9455f0cbec038266e Mon Sep 17 00:00:00 2001 From: Louis Kirkham Date: Fri, 14 Jun 2024 14:46:44 +0100 Subject: [PATCH 1/2] Sets from and to variables for error --- .../trade_most_recent_financial_year_options_question.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb b/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb index 2fbeffcb5..ea9190983 100644 --- a/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb +++ b/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb @@ -6,6 +6,8 @@ def errors date, range = question.get_changeable_date_range if date.present? && range.present? && !date.in?(range) && question.year_has_changed? + from = Settings.current_award_year_switch_date + to = Settings.current_submission_deadline result[question.key] = "You can only change the year if your dates in question D2 range between #{from.decorate.formatted_trigger_date} to #{to.decorate.formatted_trigger_date}." end From a62a7527436fd72fb2f59340c09d44b0d18444f1 Mon Sep 17 00:00:00 2001 From: Louis Kirkham Date: Fri, 14 Jun 2024 16:17:14 +0100 Subject: [PATCH 2/2] Removes custom error validation --- ...e_most_recent_financial_year_options_question.rb | 13 ------------- spec/fixtures/form_answer_innovation.json | 3 ++- spec/fixtures/form_answer_trade.json | 3 ++- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb b/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb index ea9190983..54b1947ef 100644 --- a/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb +++ b/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb @@ -1,18 +1,5 @@ class QaeFormBuilder class TradeMostRecentFinancialYearOptionsQuestionValidator < OptionsQuestionValidator - def errors - result = {} - - date, range = question.get_changeable_date_range - - if date.present? && range.present? && !date.in?(range) && question.year_has_changed? - from = Settings.current_award_year_switch_date - to = Settings.current_submission_deadline - result[question.key] = "You can only change the year if your dates in question D2 range between #{from.decorate.formatted_trigger_date} to #{to.decorate.formatted_trigger_date}." - end - - result - end end class TradeMostRecentFinancialYearOptionsQuestionBuilder < OptionsQuestionBuilder diff --git a/spec/fixtures/form_answer_innovation.json b/spec/fixtures/form_answer_innovation.json index 99820e046..80a26f0a7 100644 --- a/spec/fixtures/form_answer_innovation.json +++ b/spec/fixtures/form_answer_innovation.json @@ -212,5 +212,6 @@ "head_job_title": "test", "head_email": "test", "strong_esg_record": "on", -"major_issues_overcome": "test" +"major_issues_overcome": "test", +"most_recent_financial_year": "2024" } diff --git a/spec/fixtures/form_answer_trade.json b/spec/fixtures/form_answer_trade.json index d38cae39e..66e2f5a9f 100644 --- a/spec/fixtures/form_answer_trade.json +++ b/spec/fixtures/form_answer_trade.json @@ -178,5 +178,6 @@ "head_job_title": "test", "head_email": "test", "strong_esg_record": "on", -"major_issues_overcome": "test" +"major_issues_overcome": "test", +"most_recent_financial_year": "2024" }