From e67f503af662afaf0bd3494d821a8443d66da708 Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Wed, 11 Dec 2024 09:09:47 +0200 Subject: [PATCH] Use Page#routing_conditions instead of Page#conditions Now that Page#routing_conditions returns Condition objects as expected we can use that instead of Page#conditions; and then maybe in the future we can use that method for something else. This commit replaces all the uses of Page#condition I found using the deprecation warning from the previous commit. --- app/components/page_list_component/error_summary/view.rb | 2 +- app/components/page_list_component/view.rb | 2 +- app/controllers/pages/secondary_skip_controller.rb | 4 ++-- app/input_objects/pages/secondary_skip_input.rb | 2 +- app/models/form.rb | 2 +- app/models/page.rb | 2 +- app/presenters/route_summary_card_data_presenter.rb | 2 +- app/views/pages/routes/show.html.erb | 4 ++-- app/views/pages/selection/type.html.erb | 2 +- app/views/pages/type_of_answer.html.erb | 2 +- spec/views/pages/type_of_answer.html.erb_spec.rb | 8 ++++---- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/components/page_list_component/error_summary/view.rb b/app/components/page_list_component/error_summary/view.rb index cfaa10e0d..72224466f 100644 --- a/app/components/page_list_component/error_summary/view.rb +++ b/app/components/page_list_component/error_summary/view.rb @@ -15,7 +15,7 @@ def error_object(error_name:, condition_id:, page_index:) end def conditions_with_page_indexes - @pages.map { |page| page.conditions.map { |condition| OpenStruct.new(condition:, page_index: page.position) } } + @pages.map { |page| page.routing_conditions.map { |condition| OpenStruct.new(condition:, page_index: page.position) } } .flatten end diff --git a/app/components/page_list_component/view.rb b/app/components/page_list_component/view.rb index f5532a166..ede5bd66c 100644 --- a/app/components/page_list_component/view.rb +++ b/app/components/page_list_component/view.rb @@ -75,7 +75,7 @@ def skip_condition_route_page_text(condition) # where index is the index of the condition in the array of conditions for # the page referenced by check_page_id def process_routing_conditions - all_form_conditions = @pages.flat_map(&:conditions).compact_blank + all_form_conditions = @pages.flat_map(&:routing_conditions).compact_blank all_form_conditions .group_by(&:check_page_id) diff --git a/app/controllers/pages/secondary_skip_controller.rb b/app/controllers/pages/secondary_skip_controller.rb index fe815e200..cfda28336 100644 --- a/app/controllers/pages/secondary_skip_controller.rb +++ b/app/controllers/pages/secondary_skip_controller.rb @@ -83,7 +83,7 @@ def ensure_branch_routing_feature_enabled end def ensure_page_has_skip_condition - unless page.conditions.any? { |c| c.answer_value.present? } + unless page.routing_conditions.any? { |c| c.answer_value.present? } redirect_to form_pages_path(current_form.id) end end @@ -97,6 +97,6 @@ def ensure_secondary_skip_blank end def secondary_skip_condition - @secondary_skip_condition ||= current_form.pages.flat_map(&:conditions).compact_blank.find { |c| c.secondary_skip? && c.check_page_id == page.id } + @secondary_skip_condition ||= current_form.pages.flat_map(&:routing_conditions).compact_blank.find { |c| c.secondary_skip? && c.check_page_id == page.id } end end diff --git a/app/input_objects/pages/secondary_skip_input.rb b/app/input_objects/pages/secondary_skip_input.rb index e11a37371..15753ceaf 100644 --- a/app/input_objects/pages/secondary_skip_input.rb +++ b/app/input_objects/pages/secondary_skip_input.rb @@ -69,7 +69,7 @@ def end_page_name end def answer_value - page.conditions.find { |rc| rc.answer_value.present? }.answer_value + page.routing_conditions.find { |rc| rc.answer_value.present? }.answer_value end def continue_to diff --git a/app/models/form.rb b/app/models/form.rb index 06050df81..62dafa7dc 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -113,7 +113,7 @@ def metrics_data private def has_routing_conditions - pages.filter { |p| p.conditions.any? }.any? + pages.filter { |p| p.routing_conditions.any? }.any? end def email_task_status_service diff --git a/app/models/page.rb b/app/models/page.rb index b5b28bc1a..3f97843f9 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -66,7 +66,7 @@ def show_optional_suffix? def self.qualifying_route_pages(pages) pages.filter do |page| page.answer_type == "selection" && page.answer_settings.only_one_option == "true" && - page.position != pages.length && page.conditions.empty? + page.position != pages.length && page.routing_conditions.empty? end end end diff --git a/app/presenters/route_summary_card_data_presenter.rb b/app/presenters/route_summary_card_data_presenter.rb index 3363bbf4a..075ca5c60 100644 --- a/app/presenters/route_summary_card_data_presenter.rb +++ b/app/presenters/route_summary_card_data_presenter.rb @@ -23,7 +23,7 @@ def summary_card_data end def all_routes - all_form_routing_conditions = pages.flat_map(&:conditions).compact_blank + all_form_routing_conditions = pages.flat_map(&:routing_conditions).compact_blank all_form_routing_conditions.select { |rc| rc.check_page_id == page.id } end diff --git a/app/views/pages/routes/show.html.erb b/app/views/pages/routes/show.html.erb index d9922bb14..48dd7c82d 100644 --- a/app/views/pages/routes/show.html.erb +++ b/app/views/pages/routes/show.html.erb @@ -20,10 +20,10 @@ <%= govuk_summary_list(**card) %> <% end %> - <% if page.conditions.present? %> + <% if page.routing_conditions.present? %>