diff --git a/app/controllers/waste_carriers_engine/forms_controller.rb b/app/controllers/waste_carriers_engine/forms_controller.rb index ee56310c4..09cc77583 100644 --- a/app/controllers/waste_carriers_engine/forms_controller.rb +++ b/app/controllers/waste_carriers_engine/forms_controller.rb @@ -31,7 +31,7 @@ def create(form_class, form) def go_back find_or_initialize_transient_registration(params[:token]) - @transient_registration.back! if form_matches_state? + @transient_registration.previous_valid_state! redirect_to_correct_form end @@ -71,7 +71,7 @@ def set_up_form(form_class, form, token, get_request = false) def submit_form(form, params) respond_to do |format| if form.submit(params) - @transient_registration.next! + @transient_registration.next_state! format.html { redirect_to_correct_form } true else diff --git a/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb b/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb index 341bca965..8e77fcb4c 100644 --- a/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb @@ -72,7 +72,7 @@ def respond_to_acceptable_payment(action) if response_is_valid?(action, params) log_and_send_worldpay_response(true, action) - @transient_registration.next! + @transient_registration.next_state! redirect_to_correct_form else log_and_send_worldpay_response(false, action) diff --git a/app/models/concerns/waste_carriers_engine/can_use_ceased_or_revoked_registration_workflow.rb b/app/models/concerns/waste_carriers_engine/can_use_ceased_or_revoked_registration_workflow.rb index c4eb3d199..13a795a3e 100644 --- a/app/models/concerns/waste_carriers_engine/can_use_ceased_or_revoked_registration_workflow.rb +++ b/app/models/concerns/waste_carriers_engine/can_use_ceased_or_revoked_registration_workflow.rb @@ -26,11 +26,6 @@ module CanUseCeasedOrRevokedRegistrationWorkflow to: :ceased_or_revoked_completed_form end - - event :back do - transitions from: :ceased_or_revoked_confirm_form, - to: :cease_or_revoke_form - end end end end diff --git a/app/models/concerns/waste_carriers_engine/can_use_edit_registration_workflow.rb b/app/models/concerns/waste_carriers_engine/can_use_edit_registration_workflow.rb index 08add4264..63ccb8657 100644 --- a/app/models/concerns/waste_carriers_engine/can_use_edit_registration_workflow.rb +++ b/app/models/concerns/waste_carriers_engine/can_use_edit_registration_workflow.rb @@ -189,74 +189,6 @@ module CanUseEditRegistrationWorkflow to: :edit_cancelled_form end - event :back do - # Registration and account - transitions from: :cbd_type_form, - to: :edit_form - - # Business details - transitions from: :company_name_form, - to: :edit_form - - transitions from: :main_people_form, - to: :edit_form - - # Company address - transitions from: :company_postcode_form, - to: :edit_form - - transitions from: :company_address_form, - to: :company_postcode_form - - transitions from: :company_address_manual_form, - to: :edit_form, - if: :based_overseas? - - transitions from: :company_address_manual_form, - to: :company_postcode_form - - # Contact details - transitions from: :contact_name_form, - to: :edit_form - - transitions from: :contact_phone_form, - to: :edit_form - - transitions from: :contact_email_form, - to: :edit_form - - # Contact address - transitions from: :contact_postcode_form, - to: :edit_form - - transitions from: :contact_address_form, - to: :contact_postcode_form - - transitions from: :contact_address_manual_form, - to: :edit_form, - if: :based_overseas? - - transitions from: :contact_address_manual_form, - to: :contact_postcode_form - - # Complete an edit - transitions from: :declaration_form, - to: :edit_form - - transitions from: :edit_payment_summary_form, - to: :declaration_form - - transitions from: :edit_bank_transfer_form, - to: :edit_payment_summary_form - - transitions from: :worldpay_form, - to: :edit_payment_summary_form - - # Cancelling the edit process - transitions from: :confirm_edit_cancelled_form, - to: :edit_form - end - event :skip_to_manual_address do transitions from: :company_postcode_form, to: :company_address_manual_form diff --git a/app/models/concerns/waste_carriers_engine/can_use_new_registration_workflow.rb b/app/models/concerns/waste_carriers_engine/can_use_new_registration_workflow.rb index eb9af2855..d4cf0e33f 100644 --- a/app/models/concerns/waste_carriers_engine/can_use_new_registration_workflow.rb +++ b/app/models/concerns/waste_carriers_engine/can_use_new_registration_workflow.rb @@ -283,170 +283,6 @@ module CanUseNewRegistrationWorkflow end # Transitions - event :back do - transitions from: :location_form, to: :start_form - - transitions from: :renew_registration_form, to: :start_form - - # Location - - transitions from: :location_form, to: :renewal_start_form - - transitions from: :register_in_northern_ireland_form, to: :location_form - - transitions from: :register_in_scotland_form, to: :location_form - - transitions from: :register_in_wales_form, to: :location_form - - # End location - - transitions from: :business_type_form, to: :register_in_northern_ireland_form, - if: :should_register_in_northern_ireland? - - transitions from: :business_type_form, to: :register_in_scotland_form, - if: :should_register_in_scotland? - - transitions from: :business_type_form, to: :register_in_wales_form, - if: :should_register_in_wales? - - transitions from: :business_type_form, to: :location_form - - transitions from: :check_your_tier_form, to: :location_form, - if: :overseas? - - transitions from: :check_your_tier_form, to: :business_type_form - - # Smart answers - transitions from: :company_name_form, to: :check_your_tier_form, - if: :check_your_tier_lower? - - transitions from: :company_name_form, to: :your_tier_form, - if: :lower_tier? - - transitions from: :company_name_form, to: :main_people_form, - if: :skip_registration_number? - - transitions from: :company_name_form, to: :check_registered_company_name_form - - transitions from: :your_tier_form, to: :business_type_form, - if: :switch_to_lower_tier_based_on_business_type? - - transitions from: :your_tier_form, to: :check_your_tier_form, - unless: :check_your_tier_unknown? - - transitions from: :your_tier_form, to: :construction_demolition_form, - if: %i[lower_tier? only_carries_own_waste?] - - transitions from: :your_tier_form, to: :waste_types_form, - if: %i[lower_tier? waste_is_main_service?] - - transitions from: :your_tier_form, to: :construction_demolition_form, - if: %i[lower_tier?] - - transitions from: :check_registered_company_name_form, to: :registration_number_form - - transitions from: :incorrect_company_form, to: :check_registered_company_name_form - - transitions from: :other_businesses_form, to: :check_your_tier_form - - transitions from: :service_provided_form, to: :other_businesses_form - - transitions from: :waste_types_form, to: :service_provided_form - - transitions from: :construction_demolition_form, to: :other_businesses_form, - if: :only_carries_own_waste? - - transitions from: :construction_demolition_form, to: :service_provided_form - - transitions from: :cbd_type_form, to: :check_your_tier_form, - if: :check_your_tier_upper? - - transitions from: :cbd_type_form, to: :your_tier_form - - transitions from: :your_tier_form, to: :waste_types_form, - if: :not_only_amf? - - transitions from: :your_tier_form, to: :construction_demolition_form - - # End smart answers - - transitions from: :registration_number_form, to: :cbd_type_form - - # Registered address - - transitions from: :company_postcode_form, to: :company_name_form - - transitions from: :company_address_form, to: :company_postcode_form - - transitions from: :company_address_manual_form, to: :company_name_form, - if: :overseas? - - transitions from: :company_address_manual_form, to: :company_postcode_form - - transitions from: :main_people_form, to: :cbd_type_form, - if: :skip_registration_number? - - transitions from: :main_people_form, to: :check_registered_company_name_form - - # End registered address - - transitions from: :declare_convictions_form, to: :company_address_manual_form, - if: :registered_address_was_manually_entered? - - transitions from: :declare_convictions_form, to: :company_address_form - - transitions from: :conviction_details_form, to: :declare_convictions_form - - transitions from: :contact_name_form, to: :company_address_manual_form, - if: %i[lower_tier? registered_address_was_manually_entered?] - - transitions from: :contact_name_form, to: :company_address_form, - if: :lower_tier? - - transitions from: :contact_name_form, to: :conviction_details_form, - if: :declared_convictions? - - transitions from: :contact_name_form, to: :declare_convictions_form - - transitions from: :contact_phone_form, to: :contact_name_form - - transitions from: :contact_email_form, to: :contact_phone_form - - # Contact address - - transitions from: :contact_address_reuse_form, to: :contact_email_form - - transitions from: :contact_postcode_form, to: :contact_address_reuse_form - - transitions from: :contact_postcode_form, to: :contact_email_form - - transitions from: :contact_address_form, to: :contact_postcode_form - - transitions from: :contact_address_manual_form, to: :contact_address_reuse_form, - if: :overseas? - - transitions from: :contact_address_manual_form, to: :contact_postcode_form - - transitions from: :check_your_answers_form, to: :contact_address_manual_form, - if: :contact_address_was_manually_entered? - - transitions from: :check_your_answers_form, to: :contact_address_reuse_form, - if: :reuse_registered_address? - - transitions from: :check_your_answers_form, to: :contact_address_form - - # End contact address - - transitions from: :declaration_form, to: :check_your_answers_form - - transitions from: :cards_form, to: :declaration_form - - transitions from: :payment_summary_form, to: :cards_form - - transitions from: :worldpay_form, to: :payment_summary_form - - transitions from: :confirm_bank_transfer_form, to: :payment_summary_form - end event :skip_to_manual_address do transitions from: :company_postcode_form, to: :company_address_manual_form diff --git a/app/models/concerns/waste_carriers_engine/can_use_order_copy_cards_workflow.rb b/app/models/concerns/waste_carriers_engine/can_use_order_copy_cards_workflow.rb index 7e6e95ca1..e4cf590db 100644 --- a/app/models/concerns/waste_carriers_engine/can_use_order_copy_cards_workflow.rb +++ b/app/models/concerns/waste_carriers_engine/can_use_order_copy_cards_workflow.rb @@ -5,7 +5,6 @@ module CanUseOrderCopyCardsWorkflow extend ActiveSupport::Concern include Mongoid::Document - # rubocop:disable Metrics/BlockLength included do include AASM @@ -39,20 +38,8 @@ module CanUseOrderCopyCardsWorkflow transitions from: :worldpay_form, to: :copy_cards_order_completed_form end - - event :back do - transitions from: :copy_cards_payment_form, - to: :copy_cards_form - - transitions from: :worldpay_form, - to: :copy_cards_payment_form - - transitions from: :copy_cards_bank_transfer_form, - to: :copy_cards_payment_form - end end end - # rubocop:enable Metrics/BlockLength private diff --git a/app/models/concerns/waste_carriers_engine/can_use_renewing_registration_workflow.rb b/app/models/concerns/waste_carriers_engine/can_use_renewing_registration_workflow.rb index 53fa242f4..05178f8ba 100644 --- a/app/models/concerns/waste_carriers_engine/can_use_renewing_registration_workflow.rb +++ b/app/models/concerns/waste_carriers_engine/can_use_renewing_registration_workflow.rb @@ -208,122 +208,6 @@ module CanUseRenewingRegistrationWorkflow after: :set_metadata_route end - event :back do - # Location - - transitions from: :location_form, to: :renewal_start_form - - transitions from: :register_in_northern_ireland_form, to: :location_form - - transitions from: :register_in_scotland_form, to: :location_form - - transitions from: :register_in_wales_form, to: :location_form - - # End location - - transitions from: :business_type_form, to: :register_in_northern_ireland_form, - if: :should_register_in_northern_ireland? - - transitions from: :business_type_form, to: :register_in_scotland_form, - if: :should_register_in_scotland? - - transitions from: :business_type_form, to: :register_in_wales_form, - if: :should_register_in_wales? - - transitions from: :business_type_form, to: :location_form - - # Smart answers - - transitions from: :cbd_type_form, to: :location_form, - if: :based_overseas? - - transitions from: :cbd_type_form, to: :business_type_form - - # End smart answers - - transitions from: :renewal_information_form, to: :cbd_type_form - - transitions from: :registration_number_form, to: :renewal_information_form - - transitions from: :company_name_form, to: :renewal_information_form, - if: :lower_tier? - - transitions from: :company_name_form, to: :main_people_form, - if: :skip_registration_number? - - transitions from: :company_name_form, to: :check_registered_company_name_form - - transitions from: :check_registered_company_name_form, to: :renewal_information_form - - transitions from: :incorrect_company_form, to: :check_registered_company_name_form - - # Registered address - - transitions from: :company_postcode_form, to: :company_name_form - - transitions from: :company_address_form, to: :company_postcode_form - - transitions from: :company_address_manual_form, to: :company_name_form, - if: :based_overseas? - - transitions from: :company_address_manual_form, to: :company_postcode_form - - transitions from: :main_people_form, to: :cbd_type_form, - if: :skip_registration_number? - - transitions from: :main_people_form, to: :check_registered_company_name_form - - # End registered address - - transitions from: :declare_convictions_form, to: :company_address_manual_form, - if: :registered_address_was_manually_entered? - - transitions from: :declare_convictions_form, to: :company_address_form - - transitions from: :conviction_details_form, to: :declare_convictions_form - - transitions from: :contact_name_form, to: :conviction_details_form, - if: :declared_convictions? - - transitions from: :contact_name_form, to: :declare_convictions_form - - transitions from: :contact_phone_form, to: :contact_name_form - - transitions from: :contact_email_form, to: :contact_phone_form - - # Contact address - - transitions from: :contact_postcode_form, to: :contact_email_form - - transitions from: :contact_address_form, to: :contact_postcode_form - - transitions from: :contact_address_manual_form, to: :contact_email_form, - if: :based_overseas? - - transitions from: :contact_address_manual_form, to: :contact_postcode_form - - transitions from: :check_your_answers_form, to: :contact_address_manual_form, - if: :contact_address_was_manually_entered? - - transitions from: :check_your_answers_form, to: :contact_address_form - - # End contact address - - transitions from: :declaration_form, to: :check_your_answers_form - - transitions from: :cards_form, to: :declaration_form - - transitions from: :payment_summary_form, to: :cards_form - - transitions from: :worldpay_form, to: :payment_summary_form - - transitions from: :confirm_bank_transfer_form, to: :payment_summary_form - - # Exit routes from renewals process - - transitions from: :cannot_renew_type_change_form, to: :business_type_form - end - event :skip_to_manual_address do transitions from: :company_postcode_form, to: :company_address_manual_form diff --git a/app/models/waste_carriers_engine/transient_registration.rb b/app/models/waste_carriers_engine/transient_registration.rb index 32ef3a4d1..61854ff09 100644 --- a/app/models/waste_carriers_engine/transient_registration.rb +++ b/app/models/waste_carriers_engine/transient_registration.rb @@ -24,6 +24,7 @@ class TransientRegistration field :temp_payment_method, type: String field :temp_reuse_registered_address, type: String field :temp_use_registered_company_details, type: String + field :workflow_history, type: Array, default: [] scope :in_progress, -> { where(:workflow_state.nin => RenewingRegistration::SUBMITTED_STATES) } scope :submitted, -> { where(:workflow_state.in => RenewingRegistration::SUBMITTED_STATES) } @@ -61,8 +62,43 @@ def registration raise NotImplementedError end + def next_state! + previous_state = workflow_state + next! + workflow_history << previous_state unless previous_state.nil? + save! + rescue AASM::UndefinedState, AASM::InvalidTransition => e + Airbrake.notify(e, reg_identifier) if defined?(Airbrake) + Rails.logger.warn "Failed to transition to next workflow state, registration #{reg_identifier}: #{e}" + end + + def previous_valid_state! + return unless workflow_history&.length + + last_popped = nil + until workflow_history.empty? + last_popped = workflow_history.pop + break if valid_state?(last_popped) + + last_popped = nil + end + + self.workflow_state = last_popped || "start_form" + save! + end + private + def valid_state?(state) + return false unless state.present? + + valid_state_names.include? state.to_sym + end + + def valid_state_names + @valid_state_names ||= aasm.states.map(&:name) + end + def registration_type_base_charges [] # default. Override on STI objects where necessary. end diff --git a/app/services/waste_carriers_engine/edit_completion_service.rb b/app/services/waste_carriers_engine/edit_completion_service.rb index 72cdafaeb..b3e700ca2 100644 --- a/app/services/waste_carriers_engine/edit_completion_service.rb +++ b/app/services/waste_carriers_engine/edit_completion_service.rb @@ -54,7 +54,8 @@ def copy_attributes "temp_os_places_error", "temp_payment_method", "_type", - "workflow_state") + "workflow_state", + "workflow_history") registration.write_attributes(copyable_attributes) end diff --git a/app/services/waste_carriers_engine/registration_completion_service.rb b/app/services/waste_carriers_engine/registration_completion_service.rb index 23f4939a4..665d70524 100644 --- a/app/services/waste_carriers_engine/registration_completion_service.rb +++ b/app/services/waste_carriers_engine/registration_completion_service.rb @@ -127,6 +127,7 @@ def copy_data_from_transient_registration "temp_use_registered_company_details", "_type", "workflow_state", + "workflow_history", "locking_name", "locked_at", "key_people" diff --git a/app/services/waste_carriers_engine/renewal_completion_service.rb b/app/services/waste_carriers_engine/renewal_completion_service.rb index 3dd2413bd..c2dfdeaed 100644 --- a/app/services/waste_carriers_engine/renewal_completion_service.rb +++ b/app/services/waste_carriers_engine/renewal_completion_service.rb @@ -133,6 +133,7 @@ def copy_data_from_transient_registration "from_magic_link", "_type", "workflow_state", + "workflow_history", "locking_name", "locked_at" ) diff --git a/app/views/waste_carriers_engine/business_type_forms/new.html.erb b/app/views/waste_carriers_engine/business_type_forms/new.html.erb index 4dd23898b..759e5a34b 100644 --- a/app/views/waste_carriers_engine/business_type_forms/new.html.erb +++ b/app/views/waste_carriers_engine/business_type_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_business_type_forms_path(@business_type_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @business_type_form.token) %> <%= form_for @business_type_form do |f| %> <%= render partial: "waste_carriers_engine/shared/error_summary", locals: { f: f } %> diff --git a/app/views/waste_carriers_engine/cannot_renew_type_change_forms/new.html.erb b/app/views/waste_carriers_engine/cannot_renew_type_change_forms/new.html.erb index 72a203530..19640f91e 100644 --- a/app/views/waste_carriers_engine/cannot_renew_type_change_forms/new.html.erb +++ b/app/views/waste_carriers_engine/cannot_renew_type_change_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_cannot_renew_type_change_forms_path(@cannot_renew_type_change_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @cannot_renew_type_change_form.token) %>

<%= t(".heading", reg_identifier: @cannot_renew_type_change_form.reg_identifier) %>

diff --git a/app/views/waste_carriers_engine/cards_forms/new.html.erb b/app/views/waste_carriers_engine/cards_forms/new.html.erb index 4c0468443..e578e96b7 100644 --- a/app/views/waste_carriers_engine/cards_forms/new.html.erb +++ b/app/views/waste_carriers_engine/cards_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_cards_forms_path(@cards_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @cards_form.token) %>
diff --git a/app/views/waste_carriers_engine/cbd_type_forms/new.html.erb b/app/views/waste_carriers_engine/cbd_type_forms/new.html.erb index d99eb7d1a..9f94bb208 100644 --- a/app/views/waste_carriers_engine/cbd_type_forms/new.html.erb +++ b/app/views/waste_carriers_engine/cbd_type_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_cbd_type_forms_path(@cbd_type_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @cbd_type_form.token) %>
diff --git a/app/views/waste_carriers_engine/ceased_or_revoked_confirm_forms/new.html.erb b/app/views/waste_carriers_engine/ceased_or_revoked_confirm_forms/new.html.erb index 107c4c6d5..0b07a5154 100644 --- a/app/views/waste_carriers_engine/ceased_or_revoked_confirm_forms/new.html.erb +++ b/app/views/waste_carriers_engine/ceased_or_revoked_confirm_forms/new.html.erb @@ -1,5 +1,5 @@ <% content_for :title, t(".title", reg_identifier: @transient_registration.reg_identifier, revoke_or_cease: t(".revoke_or_cease.#{@transient_registration.status}")).html_safe %> -<%= render("waste_carriers_engine/shared/back", back_path: back_ceased_or_revoked_confirm_forms_path(token: @transient_registration.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @transient_registration.token) %>
diff --git a/app/views/waste_carriers_engine/check_registered_company_name_forms/new.html.erb b/app/views/waste_carriers_engine/check_registered_company_name_forms/new.html.erb index e5a7ace88..02dad4b34 100644 --- a/app/views/waste_carriers_engine/check_registered_company_name_forms/new.html.erb +++ b/app/views/waste_carriers_engine/check_registered_company_name_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_check_registered_company_name_forms_path(@check_registered_company_name_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @check_registered_company_name_form.token) %>
diff --git a/app/views/waste_carriers_engine/check_your_answers_forms/new.html.erb b/app/views/waste_carriers_engine/check_your_answers_forms/new.html.erb index 19e1d548c..37e837253 100644 --- a/app/views/waste_carriers_engine/check_your_answers_forms/new.html.erb +++ b/app/views/waste_carriers_engine/check_your_answers_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_check_your_answers_forms_path(@check_your_answers_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @check_your_answers_form.token) %>
diff --git a/app/views/waste_carriers_engine/check_your_tier_forms/new.html.erb b/app/views/waste_carriers_engine/check_your_tier_forms/new.html.erb index 135d09563..a71163ce9 100644 --- a/app/views/waste_carriers_engine/check_your_tier_forms/new.html.erb +++ b/app/views/waste_carriers_engine/check_your_tier_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_check_your_tier_forms_path(@check_your_tier.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @check_your_tier.token) %>
diff --git a/app/views/waste_carriers_engine/company_address_forms/new.html.erb b/app/views/waste_carriers_engine/company_address_forms/new.html.erb index 6bb0b2e28..355a8a6fe 100644 --- a/app/views/waste_carriers_engine/company_address_forms/new.html.erb +++ b/app/views/waste_carriers_engine/company_address_forms/new.html.erb @@ -1,5 +1,5 @@ <% content_for :title, t(".heading.#{@company_address_form.business_type}").html_safe %> -<%= render("waste_carriers_engine/shared/back", back_path: back_company_address_forms_path(@company_address_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @company_address_form.token) %>
@@ -22,7 +22,7 @@ <%= @company_address_form.temp_company_postcode %> <%= link_to(t(".postcode_change_link"), - back_company_address_forms_path(@company_address_form.token)) %> + go_back_forms_path(@company_address_form.token)) %>

<%= form.fields_for :company_address do |f| %> diff --git a/app/views/waste_carriers_engine/company_address_manual_forms/new.html.erb b/app/views/waste_carriers_engine/company_address_manual_forms/new.html.erb index 66da7e56b..a31ad625f 100644 --- a/app/views/waste_carriers_engine/company_address_manual_forms/new.html.erb +++ b/app/views/waste_carriers_engine/company_address_manual_forms/new.html.erb @@ -1,5 +1,5 @@ <% content_for :title, t(".heading.#{@company_address_manual_form.business_type}").html_safe %> -<%= render("waste_carriers_engine/shared/back", back_path: back_company_address_manual_forms_path(@company_address_manual_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @company_address_manual_form.token) %>
@@ -28,7 +28,7 @@ <%= @company_address_manual_form.postcode %> - <%= link_to(t(".postcode_change_link"), back_company_address_manual_forms_path(@company_address_manual_form.token)) %> + <%= link_to(t(".postcode_change_link"), go_back_forms_path(@company_address_manual_form.token)) %>

<% end %> diff --git a/app/views/waste_carriers_engine/company_name_forms/new.html.erb b/app/views/waste_carriers_engine/company_name_forms/new.html.erb index 1b083e7fb..3ec992b0a 100644 --- a/app/views/waste_carriers_engine/company_name_forms/new.html.erb +++ b/app/views/waste_carriers_engine/company_name_forms/new.html.erb @@ -1,5 +1,5 @@ <% content_for :title, t(".heading.#{@company_name_form.business_type}.#{@company_name_form.tier}").html_safe %> -<%= render("waste_carriers_engine/shared/back", back_path: back_company_name_forms_path(@company_name_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @company_name_form.token) %>
diff --git a/app/views/waste_carriers_engine/company_postcode_forms/new.html.erb b/app/views/waste_carriers_engine/company_postcode_forms/new.html.erb index 731c4d1f8..a9b98bf09 100644 --- a/app/views/waste_carriers_engine/company_postcode_forms/new.html.erb +++ b/app/views/waste_carriers_engine/company_postcode_forms/new.html.erb @@ -1,5 +1,5 @@ <% content_for :title, t(".heading.#{@company_postcode_form.business_type}").html_safe %> -<%= render("waste_carriers_engine/shared/back", back_path: back_company_postcode_forms_path(@company_postcode_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @company_postcode_form.token) %>
diff --git a/app/views/waste_carriers_engine/confirm_bank_transfer_forms/new.html.erb b/app/views/waste_carriers_engine/confirm_bank_transfer_forms/new.html.erb index 697bbc5da..3e27d754d 100644 --- a/app/views/waste_carriers_engine/confirm_bank_transfer_forms/new.html.erb +++ b/app/views/waste_carriers_engine/confirm_bank_transfer_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_confirm_bank_transfer_forms_path(@confirm_bank_transfer_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @confirm_bank_transfer_form.token) %>
@@ -20,7 +20,7 @@

<%= link_to(t(".link_text"), - back_confirm_bank_transfer_forms_path(@confirm_bank_transfer_form.token)) %> + go_back_forms_path(@confirm_bank_transfer_form.token)) %>

<%= f.govuk_submit t(".next_button") %> diff --git a/app/views/waste_carriers_engine/confirm_edit_cancelled_forms/new.html.erb b/app/views/waste_carriers_engine/confirm_edit_cancelled_forms/new.html.erb index 393e35575..6ba7cbf45 100644 --- a/app/views/waste_carriers_engine/confirm_edit_cancelled_forms/new.html.erb +++ b/app/views/waste_carriers_engine/confirm_edit_cancelled_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_confirm_edit_cancelled_forms_path(@confirm_edit_cancelled_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @confirm_edit_cancelled_form.token) %> <%= form_for(@confirm_edit_cancelled_form) do |f| %> <%= render partial: "waste_carriers_engine/shared/error_summary", locals: { f: f } %> diff --git a/app/views/waste_carriers_engine/construction_demolition_forms/new.html.erb b/app/views/waste_carriers_engine/construction_demolition_forms/new.html.erb index d35c154ba..80b559589 100644 --- a/app/views/waste_carriers_engine/construction_demolition_forms/new.html.erb +++ b/app/views/waste_carriers_engine/construction_demolition_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_construction_demolition_forms_path(@construction_demolition_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @construction_demolition_form.token) %>
diff --git a/app/views/waste_carriers_engine/contact_address_forms/new.html.erb b/app/views/waste_carriers_engine/contact_address_forms/new.html.erb index bb42be092..b0632c816 100644 --- a/app/views/waste_carriers_engine/contact_address_forms/new.html.erb +++ b/app/views/waste_carriers_engine/contact_address_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_contact_address_forms_path(@contact_address_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @contact_address_form.token) %>
@@ -20,7 +20,7 @@ <%= @contact_address_form.temp_contact_postcode %> <%= link_to(t(".postcode_change_link"), - back_contact_address_forms_path(@contact_address_form.token)) %> + go_back_forms_path(@contact_address_form.token)) %>

<%= form.fields_for :contact_address do |f| %> diff --git a/app/views/waste_carriers_engine/contact_address_manual_forms/new.html.erb b/app/views/waste_carriers_engine/contact_address_manual_forms/new.html.erb index a0b3ea980..7d462cc2a 100644 --- a/app/views/waste_carriers_engine/contact_address_manual_forms/new.html.erb +++ b/app/views/waste_carriers_engine/contact_address_manual_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_contact_address_manual_forms_path(@contact_address_manual_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @contact_address_manual_form.token) %>
@@ -27,7 +27,7 @@ <%= @contact_address_manual_form.postcode %> - <%= link_to(t(".postcode_change_link"), back_contact_address_manual_forms_path(@contact_address_manual_form.token)) %> + <%= link_to(t(".postcode_change_link"), go_back_forms_path(@contact_address_manual_form.token)) %>

<% end %> diff --git a/app/views/waste_carriers_engine/contact_address_reuse_forms/new.html.erb b/app/views/waste_carriers_engine/contact_address_reuse_forms/new.html.erb index 3161641c2..33466d0b6 100644 --- a/app/views/waste_carriers_engine/contact_address_reuse_forms/new.html.erb +++ b/app/views/waste_carriers_engine/contact_address_reuse_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_contact_address_reuse_forms_path(@contact_address_reuse_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @contact_address_reuse_form.token) %>
diff --git a/app/views/waste_carriers_engine/contact_email_forms/new.html.erb b/app/views/waste_carriers_engine/contact_email_forms/new.html.erb index 6f51cbfb9..5956d0b71 100644 --- a/app/views/waste_carriers_engine/contact_email_forms/new.html.erb +++ b/app/views/waste_carriers_engine/contact_email_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_contact_email_forms_path(@contact_email_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @contact_email_form.token) %>
diff --git a/app/views/waste_carriers_engine/contact_name_forms/new.html.erb b/app/views/waste_carriers_engine/contact_name_forms/new.html.erb index d2dee02a6..5fbfd699b 100644 --- a/app/views/waste_carriers_engine/contact_name_forms/new.html.erb +++ b/app/views/waste_carriers_engine/contact_name_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_contact_name_forms_path(@contact_name_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @contact_name_form.token) %>
diff --git a/app/views/waste_carriers_engine/contact_phone_forms/new.html.erb b/app/views/waste_carriers_engine/contact_phone_forms/new.html.erb index 782f28097..f74a46a2c 100644 --- a/app/views/waste_carriers_engine/contact_phone_forms/new.html.erb +++ b/app/views/waste_carriers_engine/contact_phone_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_contact_phone_forms_path(@contact_phone_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @contact_phone_form.token) %>
diff --git a/app/views/waste_carriers_engine/contact_postcode_forms/new.html.erb b/app/views/waste_carriers_engine/contact_postcode_forms/new.html.erb index dfe4993c3..41c58c319 100644 --- a/app/views/waste_carriers_engine/contact_postcode_forms/new.html.erb +++ b/app/views/waste_carriers_engine/contact_postcode_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_contact_postcode_forms_path(@contact_postcode_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @contact_postcode_form.token) %>
diff --git a/app/views/waste_carriers_engine/conviction_details_forms/new.html.erb b/app/views/waste_carriers_engine/conviction_details_forms/new.html.erb index 24ef09e98..aa29e2274 100644 --- a/app/views/waste_carriers_engine/conviction_details_forms/new.html.erb +++ b/app/views/waste_carriers_engine/conviction_details_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_conviction_details_forms_path(@conviction_details_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @conviction_details_form.token) %>
diff --git a/app/views/waste_carriers_engine/copy_cards_bank_transfer_forms/new.html.erb b/app/views/waste_carriers_engine/copy_cards_bank_transfer_forms/new.html.erb index 5f2970a79..de8172088 100644 --- a/app/views/waste_carriers_engine/copy_cards_bank_transfer_forms/new.html.erb +++ b/app/views/waste_carriers_engine/copy_cards_bank_transfer_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_copy_cards_bank_transfer_forms_path(@copy_cards_bank_transfer_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @copy_cards_bank_transfer_form.token) %>
diff --git a/app/views/waste_carriers_engine/copy_cards_payment_forms/new.html.erb b/app/views/waste_carriers_engine/copy_cards_payment_forms/new.html.erb index 0b1db9dbc..cfdb5a9a2 100644 --- a/app/views/waste_carriers_engine/copy_cards_payment_forms/new.html.erb +++ b/app/views/waste_carriers_engine/copy_cards_payment_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_copy_cards_payment_forms_path(token: @transient_registration.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @transient_registration.token) %>
diff --git a/app/views/waste_carriers_engine/declaration_forms/new.html.erb b/app/views/waste_carriers_engine/declaration_forms/new.html.erb index c2a465d68..9e8d25ce9 100644 --- a/app/views/waste_carriers_engine/declaration_forms/new.html.erb +++ b/app/views/waste_carriers_engine/declaration_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_declaration_forms_path(@declaration_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @declaration_form.token) %> <%= form_for(@declaration_form) do |f| %> <%= render partial: "waste_carriers_engine/shared/error_summary", locals: { f: f } %> diff --git a/app/views/waste_carriers_engine/declare_convictions_forms/new.html.erb b/app/views/waste_carriers_engine/declare_convictions_forms/new.html.erb index 89dddc712..53923f7cd 100644 --- a/app/views/waste_carriers_engine/declare_convictions_forms/new.html.erb +++ b/app/views/waste_carriers_engine/declare_convictions_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_declare_convictions_forms_path(@declare_convictions_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @declare_convictions_form.token) %> <%= form_for @declare_convictions_form do |f| %> <%= render partial: "waste_carriers_engine/shared/error_summary", locals: { f: f } %> diff --git a/app/views/waste_carriers_engine/edit_bank_transfer_forms/new.html.erb b/app/views/waste_carriers_engine/edit_bank_transfer_forms/new.html.erb index a7e3ce130..9df88856f 100644 --- a/app/views/waste_carriers_engine/edit_bank_transfer_forms/new.html.erb +++ b/app/views/waste_carriers_engine/edit_bank_transfer_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_edit_bank_transfer_forms_path(@edit_bank_transfer_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @edit_bank_transfer_form.token) %>
diff --git a/app/views/waste_carriers_engine/edit_payment_summary_forms/new.html.erb b/app/views/waste_carriers_engine/edit_payment_summary_forms/new.html.erb index f650dc8d5..634dd7e3b 100644 --- a/app/views/waste_carriers_engine/edit_payment_summary_forms/new.html.erb +++ b/app/views/waste_carriers_engine/edit_payment_summary_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_edit_payment_summary_forms_path(token: @transient_registration.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @transient_registration.token) %>
diff --git a/app/views/waste_carriers_engine/incorrect_company_forms/new.html.erb b/app/views/waste_carriers_engine/incorrect_company_forms/new.html.erb index 874e4707b..72877a560 100644 --- a/app/views/waste_carriers_engine/incorrect_company_forms/new.html.erb +++ b/app/views/waste_carriers_engine/incorrect_company_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_incorrect_company_forms_path(@incorrect_company_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @incorrect_company_form.token) %>
diff --git a/app/views/waste_carriers_engine/location_forms/new.html.erb b/app/views/waste_carriers_engine/location_forms/new.html.erb index cc040b7f6..fde5ea403 100644 --- a/app/views/waste_carriers_engine/location_forms/new.html.erb +++ b/app/views/waste_carriers_engine/location_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_location_forms_path(@location_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @location_form.token) %>
diff --git a/app/views/waste_carriers_engine/main_people_forms/new.html.erb b/app/views/waste_carriers_engine/main_people_forms/new.html.erb index 2bbf14084..73b14d79f 100644 --- a/app/views/waste_carriers_engine/main_people_forms/new.html.erb +++ b/app/views/waste_carriers_engine/main_people_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_main_people_forms_path(@main_people_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @main_people_form.token) %>
diff --git a/app/views/waste_carriers_engine/other_businesses_forms/new.html.erb b/app/views/waste_carriers_engine/other_businesses_forms/new.html.erb index 8cf71480e..3820fb128 100644 --- a/app/views/waste_carriers_engine/other_businesses_forms/new.html.erb +++ b/app/views/waste_carriers_engine/other_businesses_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_other_businesses_forms_path(@other_businesses_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @other_businesses_form.token) %>
<%= form_for @other_businesses_form do |f| %> diff --git a/app/views/waste_carriers_engine/payment_summary_forms/new.html.erb b/app/views/waste_carriers_engine/payment_summary_forms/new.html.erb index 2e3acb6ac..36cd1d136 100644 --- a/app/views/waste_carriers_engine/payment_summary_forms/new.html.erb +++ b/app/views/waste_carriers_engine/payment_summary_forms/new.html.erb @@ -4,7 +4,7 @@ <% end %> <% end %> -<%= render("waste_carriers_engine/shared/back", back_path: back_payment_summary_forms_path(@payment_summary_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @payment_summary_form.token) %>
diff --git a/app/views/waste_carriers_engine/register_in_northern_ireland_forms/new.html.erb b/app/views/waste_carriers_engine/register_in_northern_ireland_forms/new.html.erb index 4810470f4..b96e6e208 100644 --- a/app/views/waste_carriers_engine/register_in_northern_ireland_forms/new.html.erb +++ b/app/views/waste_carriers_engine/register_in_northern_ireland_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_register_in_northern_ireland_forms_path(@register_in_northern_ireland_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @register_in_northern_ireland_form.token) %>
diff --git a/app/views/waste_carriers_engine/register_in_scotland_forms/new.html.erb b/app/views/waste_carriers_engine/register_in_scotland_forms/new.html.erb index 15ef77a64..9465b4c5d 100644 --- a/app/views/waste_carriers_engine/register_in_scotland_forms/new.html.erb +++ b/app/views/waste_carriers_engine/register_in_scotland_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_register_in_scotland_forms_path(@register_in_scotland_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @register_in_scotland_form.token) %>
diff --git a/app/views/waste_carriers_engine/register_in_wales_forms/new.html.erb b/app/views/waste_carriers_engine/register_in_wales_forms/new.html.erb index 38e2f2a10..c37060ecf 100644 --- a/app/views/waste_carriers_engine/register_in_wales_forms/new.html.erb +++ b/app/views/waste_carriers_engine/register_in_wales_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_register_in_wales_forms_path(@register_in_wales_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @register_in_wales_form.token) %>
diff --git a/app/views/waste_carriers_engine/registration_number_forms/new.html.erb b/app/views/waste_carriers_engine/registration_number_forms/new.html.erb index 89567a498..db5701b81 100644 --- a/app/views/waste_carriers_engine/registration_number_forms/new.html.erb +++ b/app/views/waste_carriers_engine/registration_number_forms/new.html.erb @@ -1,5 +1,5 @@ <% content_for :title, t(".heading.#{@registration_number_form.business_type}").html_safe %> -<%= render("waste_carriers_engine/shared/back", back_path: back_registration_number_forms_path(@registration_number_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @registration_number_form.token) %>
diff --git a/app/views/waste_carriers_engine/renew_registration_forms/new.html.erb b/app/views/waste_carriers_engine/renew_registration_forms/new.html.erb index e0581fbac..a3692fcbd 100644 --- a/app/views/waste_carriers_engine/renew_registration_forms/new.html.erb +++ b/app/views/waste_carriers_engine/renew_registration_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_renew_registration_forms_path(token: @renew_registration_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @renew_registration_form.token) %>
diff --git a/app/views/waste_carriers_engine/renewal_information_forms/new.html.erb b/app/views/waste_carriers_engine/renewal_information_forms/new.html.erb index c169103dd..6ff1c67be 100644 --- a/app/views/waste_carriers_engine/renewal_information_forms/new.html.erb +++ b/app/views/waste_carriers_engine/renewal_information_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_renewal_information_forms_path(@renewal_information_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @renewal_information_form.token) %>
diff --git a/app/views/waste_carriers_engine/service_provided_forms/new.html.erb b/app/views/waste_carriers_engine/service_provided_forms/new.html.erb index 34cdca322..d28e711c2 100644 --- a/app/views/waste_carriers_engine/service_provided_forms/new.html.erb +++ b/app/views/waste_carriers_engine/service_provided_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_service_provided_forms_path(@service_provided_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @service_provided_form.token) %>
diff --git a/app/views/waste_carriers_engine/shared/_back.html.erb b/app/views/waste_carriers_engine/shared/_back.html.erb index d90ced6e3..e87f7c812 100644 --- a/app/views/waste_carriers_engine/shared/_back.html.erb +++ b/app/views/waste_carriers_engine/shared/_back.html.erb @@ -2,7 +2,7 @@ content_for :back_link do link_to( t(".back_link"), - back_path, + defined?(back_path) ? back_path : go_back_forms_path(token), class: "govuk-back-link" ) end diff --git a/app/views/waste_carriers_engine/waste_types_forms/new.html.erb b/app/views/waste_carriers_engine/waste_types_forms/new.html.erb index 48fc996eb..865207cb0 100644 --- a/app/views/waste_carriers_engine/waste_types_forms/new.html.erb +++ b/app/views/waste_carriers_engine/waste_types_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_waste_types_forms_path(@waste_types_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @waste_types_form.token) %>
diff --git a/app/views/waste_carriers_engine/worldpay_forms/new.html.erb b/app/views/waste_carriers_engine/worldpay_forms/new.html.erb index 0c2be5537..50037971d 100644 --- a/app/views/waste_carriers_engine/worldpay_forms/new.html.erb +++ b/app/views/waste_carriers_engine/worldpay_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_worldpay_forms_path(@worldpay_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @worldpay_form.token) %>
<% if @worldpay_form.errors.any? %> diff --git a/app/views/waste_carriers_engine/your_tier_forms/new.html.erb b/app/views/waste_carriers_engine/your_tier_forms/new.html.erb index 9ebc043e2..f6455b8de 100644 --- a/app/views/waste_carriers_engine/your_tier_forms/new.html.erb +++ b/app/views/waste_carriers_engine/your_tier_forms/new.html.erb @@ -1,5 +1,5 @@ <% content_for :title, t(".heading.#{@transient_registration.tier}").html_safe %> -<%= render("waste_carriers_engine/shared/back", back_path: back_your_tier_forms_path(@your_tier_form.token)) %> +<%= render("waste_carriers_engine/shared/back", token: @your_tier_form.token) %>
diff --git a/config/routes.rb b/config/routes.rb index 38b6d099f..4097913d8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,12 +17,7 @@ resources :renew_registration_forms, only: %i[new create], path: "renew-registration", - path_names: { new: "" } do - get "back", - to: "renew_registration_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :your_tier_forms, only: %i[new create], @@ -37,12 +32,7 @@ resources :check_your_tier_forms, only: %i[new create], path: "check-your-tier", - path_names: { new: "" } do - get "back", - to: "check_your_tier_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :registration_received_pending_payment_forms, only: :new, @@ -84,12 +74,7 @@ resources :copy_cards_bank_transfer_forms, only: %i[new create], path: "order-copy-cards-bank-transfer", - path_names: { new: "" } do - get "back", - to: "copy_cards_bank_transfer_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :copy_cards_order_completed_forms, only: %i[new create], @@ -183,12 +168,7 @@ resources :edit_bank_transfer_forms, only: %i[new create], path: "edit-bank-transfer", - path_names: { new: "" } do - get "back", - to: "edit_bank_transfer_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :edit_complete_forms, only: %i[new create], @@ -198,12 +178,7 @@ resources :confirm_edit_cancelled_forms, only: %i[new create], path: "confirm-edit-cancelled", - path_names: { new: "" } do - get "back", - to: "confirm_edit_cancelled_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :edit_cancelled_forms, only: %i[new create], @@ -219,162 +194,82 @@ resources :location_forms, only: %i[new create], path: "location", - path_names: { new: "" } do - get "back", - to: "location_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :register_in_northern_ireland_forms, only: %i[new create], path: "register-in-northern-ireland", - path_names: { new: "" } do - get "back", - to: "register_in_northern_ireland_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :register_in_scotland_forms, only: %i[new create], path: "register-in-scotland", - path_names: { new: "" } do - get "back", - to: "register_in_scotland_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :register_in_wales_forms, only: %i[new create], path: "register-in-wales", - path_names: { new: "" } do - get "back", - to: "register_in_wales_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :business_type_forms, only: %i[new create], path: "business-type", - path_names: { new: "" } do - get "back", - to: "business_type_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :other_businesses_forms, only: %i[new create], path: "other-businesses", - path_names: { new: "" } do - get "back", - to: "other_businesses_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :service_provided_forms, only: %i[new create], path: "service-provided", - path_names: { new: "" } do - get "back", - to: "service_provided_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :construction_demolition_forms, only: %i[new create], path: "construction-demolition", - path_names: { new: "" } do - get "back", - to: "construction_demolition_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :waste_types_forms, only: %i[new create], path: "waste-types", - path_names: { new: "" } do - get "back", - to: "waste_types_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :cbd_type_forms, only: %i[new create], path: "cbd-type", - path_names: { new: "" } do - get "back", - to: "cbd_type_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :renewal_information_forms, only: %i[new create], path: "renewal-information", - path_names: { new: "" } do - get "back", - to: "renewal_information_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :registration_number_forms, only: %i[new create], path: "registration-number", - path_names: { new: "" } do - get "back", - to: "registration_number_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :check_registered_company_name_forms, only: %i[new create], path: "check-registered-company-name", - path_names: { new: "" } do - get "back", - to: "check_registered_company_name_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :incorrect_company_forms, only: %i[new create], path: "incorrect-company", - path_names: { new: "" } do - get "back", - to: "incorrect_company_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :company_name_forms, only: %i[new create], path: "company-name", - path_names: { new: "" } do - get "back", - to: "company_name_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :company_postcode_forms, only: %i[new create], path: "company-postcode", path_names: { new: "" } do - get "back", - to: "company_postcode_forms#go_back", - as: "back", - on: :collection - get "skip_to_manual_address", to: "company_postcode_forms#skip_to_manual_address", as: "skip_to_manual_address", @@ -385,11 +280,6 @@ only: %i[new create], path: "company-address", path_names: { new: "" } do - get "back", - to: "company_address_forms#go_back", - as: "back", - on: :collection - get "skip_to_manual_address", to: "company_address_forms#skip_to_manual_address", as: "skip_to_manual_address", @@ -399,22 +289,12 @@ resources :company_address_manual_forms, only: %i[new create], path: "company-address-manual", - path_names: { new: "" } do - get "back", - to: "company_address_manual_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :main_people_forms, only: %i[new create], path: "main-people", path_names: { new: "" } do - get "back", - to: "main_people_forms#go_back", - as: "back", - on: :collection - delete "delete_person/:id", to: "main_people_forms#delete_person", as: "delete_person", @@ -424,22 +304,12 @@ resources :declare_convictions_forms, only: %i[new create], path: "declare-convictions", - path_names: { new: "" } do - get "back", - to: "declare_convictions_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :conviction_details_forms, only: %i[new create], path: "conviction-details", path_names: { new: "" } do - get "back", - to: "conviction_details_forms#go_back", - as: "back", - on: :collection - delete "delete_person/:id", to: "conviction_details_forms#delete_person", as: "delete_person", @@ -449,42 +319,22 @@ resources :contact_name_forms, only: %i[new create], path: "contact-name", - path_names: { new: "" } do - get "back", - to: "contact_name_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :contact_phone_forms, only: %i[new create], path: "contact-phone", - path_names: { new: "" } do - get "back", - to: "contact_phone_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :contact_email_forms, only: %i[new create], path: "contact-email", - path_names: { new: "" } do - get "back", - to: "contact_email_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :contact_postcode_forms, only: %i[new create], path: "contact-postcode", path_names: { new: "" } do - get "back", - to: "contact_postcode_forms#go_back", - as: "back", - on: :collection - get "skip_to_manual_address", to: "contact_postcode_forms#skip_to_manual_address", as: "skip_to_manual_address", @@ -495,11 +345,6 @@ only: %i[new create], path: "contact-address", path_names: { new: "" } do - get "back", - to: "contact_address_forms#go_back", - as: "back", - on: :collection - get "skip_to_manual_address", to: "contact_address_forms#skip_to_manual_address", as: "skip_to_manual_address", @@ -509,62 +354,32 @@ resources :contact_address_manual_forms, only: %i[new create], path: "contact-address-manual", - path_names: { new: "" } do - get "back", - to: "contact_address_manual_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :contact_address_reuse_forms, only: %i[new create], path: "contact-address-reuse", - path_names: { new: "" } do - get "back", - to: "contact_address_reuse_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :check_your_answers_forms, only: %i[new create], path: "check-your-answers", - path_names: { new: "" } do - get "back", - to: "check_your_answers_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :declaration_forms, only: %i[new create], path: "declaration", - path_names: { new: "" } do - get "back", - to: "declaration_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :cards_forms, only: %i[new create], path: "cards", - path_names: { new: "" } do - get "back", - to: "cards_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :payment_summary_forms, only: %i[new create], path: "payment-summary", - path_names: { new: "" } do - get "back", - to: "payment_summary_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :worldpay_forms, only: %i[new create], @@ -599,12 +414,7 @@ resources :confirm_bank_transfer_forms, only: %i[new create], path: "confirm-bank-transfer", - path_names: { new: "" } do - get "back", - to: "confirm_bank_transfer_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } resources :renewal_complete_forms, only: %i[new create], @@ -629,12 +439,10 @@ resources :cannot_renew_type_change_forms, only: %i[new create], path: "cannot-renew-type-change", - path_names: { new: "" } do - get "back", - to: "cannot_renew_type_change_forms#go_back", - as: "back", - on: :collection - end + path_names: { new: "" } + + get "/back", to: "forms#go_back", as: "go_back_forms" + end mount DefraRubyEmail::Engine => "/email" diff --git a/spec/models/waste_carriers_engine/ceased_or_revoked_registration_workflow/ceased_or_revoked_confirm_form_spec.rb b/spec/models/waste_carriers_engine/ceased_or_revoked_registration_workflow/ceased_or_revoked_confirm_form_spec.rb index b31a686d1..0085b5bdd 100644 --- a/spec/models/waste_carriers_engine/ceased_or_revoked_registration_workflow/ceased_or_revoked_confirm_form_spec.rb +++ b/spec/models/waste_carriers_engine/ceased_or_revoked_registration_workflow/ceased_or_revoked_confirm_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "ceased_or_revoked_completed_form" end - - context "on back" do - include_examples "has back transition", previous_state: "cease_or_revoke_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/cbd_type_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/cbd_type_form_spec.rb index 5ae902a7b..f2e5464b5 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/cbd_type_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/cbd_type_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/company_address_manual_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/company_address_manual_form_spec.rb index fd1280960..dd32f22f6 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/company_address_manual_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/company_address_manual_form_spec.rb @@ -6,7 +6,6 @@ module WasteCarriersEngine RSpec.describe EditRegistration, type: :model do describe "#workflow_state" do it_behaves_like "a manual address transition", - previous_state_if_overseas: :edit_form, next_state: :edit_form, address_type: "company", factory: :edit_registration diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/company_name_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/company_name_form_spec.rb index a0ba7bc1f..c8af4755d 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/company_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/company_name_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/company_postcode_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/company_postcode_form_spec.rb index d03dea248..e436beed2 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/company_postcode_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/company_postcode_form_spec.rb @@ -6,7 +6,6 @@ module WasteCarriersEngine RSpec.describe EditRegistration, type: :model do describe "#workflow_state" do it_behaves_like "a postcode transition", - previous_state: :edit_form, address_type: "company", factory: :edit_registration end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/confirm_edit_cancelled_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/confirm_edit_cancelled_form_spec.rb index a845bca84..2032dfe3c 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/confirm_edit_cancelled_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/confirm_edit_cancelled_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_cancelled_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_address_manual_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_address_manual_form_spec.rb index 618902b15..a562f00f2 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_address_manual_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_address_manual_form_spec.rb @@ -6,7 +6,6 @@ module WasteCarriersEngine RSpec.describe EditRegistration, type: :model do describe "#workflow_state" do it_behaves_like "a manual address transition", - previous_state_if_overseas: :edit_form, next_state: :edit_form, address_type: "contact", factory: :edit_registration diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_email_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_email_form_spec.rb index 95fbd1252..7dfcfd955 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_email_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_email_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_name_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_name_form_spec.rb index 9f31da472..1c1fd4571 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_name_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_phone_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_phone_form_spec.rb index c29364151..babb3731e 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_phone_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_phone_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_postcode_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_postcode_form_spec.rb index 139e8946f..22b88d25d 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/contact_postcode_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/contact_postcode_form_spec.rb @@ -6,7 +6,6 @@ module WasteCarriersEngine RSpec.describe EditRegistration, type: :model do describe "#workflow_state" do it_behaves_like "a postcode transition", - previous_state: :edit_form, address_type: "contact", factory: :edit_registration end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/declaration_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/declaration_form_spec.rb index 484f0c715..50752331e 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/declaration_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/declaration_form_spec.rb @@ -17,10 +17,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "edit_payment_summary_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/edit_bank_transfer_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/edit_bank_transfer_form_spec.rb index 2fd9ac9fb..2e1c62bcc 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/edit_bank_transfer_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/edit_bank_transfer_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_complete_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_payment_summary_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/edit_payment_summary_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/edit_payment_summary_form_spec.rb index 75ae157b0..0e8a22121 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/edit_payment_summary_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/edit_payment_summary_form_spec.rb @@ -17,10 +17,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "edit_bank_transfer_form" end - - context "on back" do - include_examples "has back transition", previous_state: "declaration_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/main_people_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/main_people_form_spec.rb index 5de06313e..4d8936c7f 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/main_people_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/main_people_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_form" - end end end end diff --git a/spec/models/waste_carriers_engine/edit_registration_workflow/worldpay_form_spec.rb b/spec/models/waste_carriers_engine/edit_registration_workflow/worldpay_form_spec.rb index 15249f63a..f7b14cfbc 100644 --- a/spec/models/waste_carriers_engine/edit_registration_workflow/worldpay_form_spec.rb +++ b/spec/models/waste_carriers_engine/edit_registration_workflow/worldpay_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "edit_complete_form" end - - context "on back" do - include_examples "has back transition", previous_state: "edit_payment_summary_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/business_type_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/business_type_form_spec.rb index 297c50654..4e2f31f75 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/business_type_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/business_type_form_spec.rb @@ -21,34 +21,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "check_your_tier_form" end - - context "on back" do - subject { build(:new_registration, workflow_state: "business_type_form", location: location) } - - context "when the location is northern_ireland" do - let(:location) { "northern_ireland" } - - include_examples "has back transition", previous_state: "register_in_northern_ireland_form" - end - - context "when the location is scotland" do - let(:location) { "scotland" } - - include_examples "has back transition", previous_state: "register_in_scotland_form" - end - - context "when the location is wales" do - let(:location) { "wales" } - - include_examples "has back transition", previous_state: "register_in_wales_form" - end - - context "when the location is in england" do - let(:location) { "england" } - - include_examples "has back transition", previous_state: "location_form" - end - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/cards_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/cards_form_spec.rb index 9cdd19c7d..eef98b57c 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/cards_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/cards_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "payment_summary_form" end - - context "on back" do - include_examples "has back transition", previous_state: "declaration_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/cbd_type_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/cbd_type_form_spec.rb index 7783878ff..e23a4ab2b 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/cbd_type_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/cbd_type_form_spec.rb @@ -17,16 +17,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "main_people_form" end - - context "on back" do - context "when the answer to check your tier is upper" do - subject { build(:new_registration, workflow_state: "cbd_type_form", temp_check_your_tier: "upper") } - - include_examples "has back transition", previous_state: "check_your_tier_form" - end - - include_examples "has back transition", previous_state: "your_tier_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/check_registered_company_name_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/check_registered_company_name_form_spec.rb index eea08ab72..eaccb5194 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/check_registered_company_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/check_registered_company_name_form_spec.rb @@ -21,10 +21,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "incorrect_company_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "registration_number_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/check_your_answers_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/check_your_answers_form_spec.rb index d82e087fb..dc4cedc8a 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/check_your_answers_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/check_your_answers_form_spec.rb @@ -11,17 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "declaration_form" end - - context "on back" do - context "when the contact address was manually entered" do - let(:contact_address) { build(:address, :contact, :manual_uk) } - subject { build(:new_registration, workflow_state: "check_your_answers_form", contact_address: contact_address) } - - include_examples "has back transition", previous_state: "contact_address_manual_form" - end - - include_examples "has back transition", previous_state: "contact_address_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/check_your_tier_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/check_your_tier_form_spec.rb index 6b104f090..6aefcb4f9 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/check_your_tier_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/check_your_tier_form_spec.rb @@ -35,18 +35,6 @@ module WasteCarriersEngine end end end - - context "on back" do - context "if the company is based overseas" do - subject { build(:new_registration, workflow_state: "check_your_tier_form", location: "overseas") } - - include_examples "has back transition", previous_state: "location_form" - end - - subject { build(:new_registration, workflow_state: "check_your_tier_form") } - - include_examples "has back transition", previous_state: "business_type_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/company_address_manual_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/company_address_manual_form_spec.rb index 0c9097b02..a81d43a2d 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/company_address_manual_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/company_address_manual_form_spec.rb @@ -9,7 +9,6 @@ module WasteCarriersEngine let(:tier) { WasteCarriersEngine::Registration::UPPER_TIER } it_behaves_like "a manual address transition", - previous_state_if_overseas: :company_name_form, next_state: :declare_convictions_form, address_type: "company", factory: :new_registration @@ -19,7 +18,6 @@ module WasteCarriersEngine let(:tier) { WasteCarriersEngine::Registration::LOWER_TIER } it_behaves_like "a manual address transition", - previous_state_if_overseas: :company_name_form, next_state: :contact_name_form, address_type: "company", factory: :new_registration diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/company_name_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/company_name_form_spec.rb index dfb75fe90..e4ad62907 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/company_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/company_name_form_spec.rb @@ -17,32 +17,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "company_postcode_form" end - - context "on back" do - context "when the business does not require a registration number and the registration is upper tier" do - subject { build(:new_registration, :upper, workflow_state: "company_name_form", location: "overseas") } - - include_examples "has back transition", previous_state: "main_people_form" - end - - context "when the registration is lower tier" do - subject { build(:new_registration, :lower, workflow_state: "company_name_form") } - - context "when the check your tier answer is lower" do - subject { build(:new_registration, :lower, workflow_state: "company_name_form", temp_check_your_tier: "lower") } - - include_examples "has back transition", previous_state: "check_your_tier_form" - end - - include_examples "has back transition", previous_state: "your_tier_form" - end - - context "When the registration requires a company number" do - subject { build(:new_registration, workflow_state: "company_name_form", business_type: "limitedCompany") } - - include_examples "has back transition", previous_state: "check_registered_company_name_form" - end - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/company_postcode_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/company_postcode_form_spec.rb index 537c65507..7a90d1ec3 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/company_postcode_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/company_postcode_form_spec.rb @@ -7,7 +7,6 @@ module WasteCarriersEngine describe "#workflow_state" do it_behaves_like "a postcode transition", - previous_state: :company_name_form, address_type: "company", factory: :new_registration diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/confirm_bank_transfer_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/confirm_bank_transfer_form_spec.rb index d8800409f..bcab81775 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/confirm_bank_transfer_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/confirm_bank_transfer_form_spec.rb @@ -17,10 +17,6 @@ module WasteCarriersEngine expect { subject.next! }.to change { subject.metaData.route }.to("test_route") end end - - context "on back" do - include_examples "has back transition", previous_state: "payment_summary_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/construction_demolition_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/construction_demolition_form_spec.rb index 41524367d..bd76b9782 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/construction_demolition_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/construction_demolition_form_spec.rb @@ -35,16 +35,6 @@ module WasteCarriersEngine end end end - - context "on back" do - context "when the company only carries its own waste" do - subject { build(:new_registration, workflow_state: "construction_demolition_form", other_businesses: "no") } - - include_examples "has back transition", previous_state: "other_businesses_form" - end - - include_examples "has back transition", previous_state: "service_provided_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/contact_address_manual_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/contact_address_manual_form_spec.rb index bde73eef6..7a800da40 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/contact_address_manual_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/contact_address_manual_form_spec.rb @@ -6,7 +6,6 @@ module WasteCarriersEngine RSpec.describe NewRegistration do describe "#workflow_state" do it_behaves_like "a manual address transition", - previous_state_if_overseas: :contact_address_reuse_form, next_state: :check_your_answers_form, address_type: "contact", factory: :new_registration diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/contact_email_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/contact_email_form_spec.rb index abcd073f7..9db871d17 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/contact_email_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/contact_email_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_address_reuse_form" end - - context "on back" do - include_examples "has back transition", previous_state: "contact_phone_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/contact_name_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/contact_name_form_spec.rb index 726a6a900..15098e63c 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/contact_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/contact_name_form_spec.rb @@ -11,29 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_phone_form" end - - context "on back" do - context "When the user has convictions to declare" do - subject { build(:new_registration, workflow_state: "contact_name_form", declared_convictions: "yes") } - - include_examples "has back transition", previous_state: "conviction_details_form" - end - - context "When the registration is a lower tier" do - subject { build(:new_registration, :lower, workflow_state: "contact_name_form") } - - context "when the registered address was manually entered" do - let(:registered_address) { build(:address, :registered, :manual_foreign) } - subject { build(:new_registration, :lower, workflow_state: "contact_name_form", registered_address: registered_address) } - - include_examples "has back transition", previous_state: "company_address_manual_form" - end - - include_examples "has back transition", previous_state: "company_address_form" - end - - include_examples "has back transition", previous_state: "declare_convictions_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/contact_phone_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/contact_phone_form_spec.rb index a4aa5260a..238f2f66e 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/contact_phone_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/contact_phone_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_email_form" end - - context "on back" do - include_examples "has back transition", previous_state: "contact_name_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/contact_postcode_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/contact_postcode_form_spec.rb index f104b57fc..6b07a934d 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/contact_postcode_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/contact_postcode_form_spec.rb @@ -5,7 +5,6 @@ module WasteCarriersEngine RSpec.describe NewRegistration do it_behaves_like "a postcode transition", - previous_state: :contact_address_reuse_form, address_type: "contact", factory: :new_registration end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/conviction_details_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/conviction_details_form_spec.rb index bf1cc31b3..c1839c9cf 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/conviction_details_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/conviction_details_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_name_form" end - - context "on back" do - include_examples "has back transition", previous_state: "declare_convictions_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/declaration_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/declaration_form_spec.rb index bd5e88ad5..e127b432e 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/declaration_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/declaration_form_spec.rb @@ -17,10 +17,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "cards_form" end - - context "on back" do - include_examples "has back transition", previous_state: "check_your_answers_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/declare_convictions_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/declare_convictions_form_spec.rb index 76c92895c..073457cd0 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/declare_convictions_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/declare_convictions_form_spec.rb @@ -17,17 +17,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "contact_name_form" end - - context "on back" do - context "when the registered address was manually entered" do - let(:registered_address) { build(:address, :registered, :manual_foreign) } - subject { build(:new_registration, workflow_state: "declare_convictions_form", registered_address: registered_address) } - - include_examples "has back transition", previous_state: "company_address_manual_form" - end - - include_examples "has back transition", previous_state: "company_address_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/location_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/location_form_spec.rb index 8fa566d20..bb52234c6 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/location_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/location_form_spec.rb @@ -41,10 +41,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "business_type_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "start_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/main_people_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/main_people_form_spec.rb index 6191b9ae8..4fb4ebb35 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/main_people_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/main_people_form_spec.rb @@ -12,20 +12,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "company_name_form" end - - context "on back" do - context "when the business type is limited company" do - let(:business_type) { "limitedCompany" } - - include_examples "has back transition", previous_state: "check_registered_company_name_form" - end - - context "when the business type is sole trader" do - let(:business_type) { "soleTrader" } - - include_examples "has back transition", previous_state: "cbd_type_form" - end - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/other_businesses_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/other_businesses_form_spec.rb index ed9de4084..271560f20 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/other_businesses_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/other_businesses_form_spec.rb @@ -19,10 +19,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "service_provided_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "check_your_tier_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/payment_summary_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/payment_summary_form_spec.rb index db081309a..c5c4eec28 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/payment_summary_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/payment_summary_form_spec.rb @@ -17,10 +17,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "confirm_bank_transfer_form" end - - context "on back" do - include_examples "has back transition", previous_state: "cards_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/register_in_northern_ireland_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/register_in_northern_ireland_form_spec.rb index d91ccdc56..911d405da 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/register_in_northern_ireland_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/register_in_northern_ireland_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "business_type_form" end - - context "on back" do - include_examples "has back transition", previous_state: "location_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/register_in_scotland_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/register_in_scotland_form_spec.rb index e20d15684..1aa05f1e0 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/register_in_scotland_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/register_in_scotland_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "business_type_form" end - - context "on back" do - include_examples "has back transition", previous_state: "location_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/register_in_wales_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/register_in_wales_form_spec.rb index bc125189b..7da7fcb11 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/register_in_wales_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/register_in_wales_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "business_type_form" end - - context "on back" do - include_examples "has back transition", previous_state: "location_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/registration_number_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/registration_number_form_spec.rb index 6934507fc..f7768289f 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/registration_number_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/registration_number_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "check_registered_company_name_form" end - - context "on back" do - include_examples "has back transition", previous_state: "cbd_type_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/renew_registration_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/renew_registration_form_spec.rb deleted file mode 100644 index f45dd7ddd..000000000 --- a/spec/models/waste_carriers_engine/new_registration_workflow/renew_registration_form_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -module WasteCarriersEngine - RSpec.describe NewRegistration do - subject { build(:new_registration, workflow_state: "renew_registration_form") } - - describe "#workflow_state" do - context ":renew_registration_form state transitions" do - context "on back" do - include_examples "has back transition", previous_state: "start_form" - end - end - end - end -end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/service_provided_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/service_provided_form_spec.rb index 9ff6db4a5..edb608cd4 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/service_provided_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/service_provided_form_spec.rb @@ -19,10 +19,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "construction_demolition_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "other_businesses_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/waste_types_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/waste_types_form_spec.rb index 85a4bb173..05ec8ab66 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/waste_types_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/waste_types_form_spec.rb @@ -35,10 +35,6 @@ module WasteCarriersEngine end end end - - context "on back" do - include_examples "has back transition", previous_state: "service_provided_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/worldpay_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/worldpay_form_spec.rb index 6d6f3c849..59e27f018 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/worldpay_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/worldpay_form_spec.rb @@ -23,10 +23,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "registration_received_pending_worldpay_payment_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "payment_summary_form" - end end end end diff --git a/spec/models/waste_carriers_engine/new_registration_workflow/your_tier_form_spec.rb b/spec/models/waste_carriers_engine/new_registration_workflow/your_tier_form_spec.rb index 3cbd115c5..906d9b142 100644 --- a/spec/models/waste_carriers_engine/new_registration_workflow/your_tier_form_spec.rb +++ b/spec/models/waste_carriers_engine/new_registration_workflow/your_tier_form_spec.rb @@ -21,46 +21,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "cbd_type_form" end end - - context "on back" do - context "when the check your tier answer is not unknown" do - subject { build(:new_registration, workflow_state: "your_tier_form", temp_check_your_tier: "lower") } - - include_examples "has back transition", previous_state: "check_your_tier_form" - end - - context "when the registration is lower tier" do - subject { build(:new_registration, :lower, workflow_state: "your_tier_form", temp_check_your_tier: "unknown") } - - context "when the waste is the main service" do - subject { build(:new_registration, :lower, workflow_state: "your_tier_form", is_main_service: "yes", temp_check_your_tier: "unknown") } - - include_examples "has back transition", previous_state: "waste_types_form" - end - - context "when the company only carries own waste" do - subject { build(:new_registration, :lower, workflow_state: "your_tier_form", other_businesses: "no", temp_check_your_tier: "unknown") } - - include_examples "has back transition", previous_state: "construction_demolition_form" - end - - include_examples "has back transition", previous_state: "construction_demolition_form" - end - - context "when the company deals with more than amf waste" do - subject { build(:new_registration, workflow_state: "your_tier_form", only_amf: "no", temp_check_your_tier: "unknown") } - - include_examples "has back transition", previous_state: "waste_types_form" - end - - context "when the registration's company is a charity" do - subject { build(:new_registration, workflow_state: "your_tier_form", business_type: "charity", temp_check_your_tier: "unknown") } - - include_examples "has back transition", previous_state: "business_type_form" - end - - include_examples "has back transition", previous_state: "construction_demolition_form" - end end end end diff --git a/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_bank_transfer_form_spec.rb b/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_bank_transfer_form_spec.rb index e1af2c86c..9166a2852 100644 --- a/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_bank_transfer_form_spec.rb +++ b/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_bank_transfer_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "copy_cards_order_completed_form" end - - context "on back" do - include_examples "has back transition", previous_state: "copy_cards_payment_form" - end end end end diff --git a/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_payment_form_spec.rb b/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_payment_form_spec.rb index 5938d2538..b87b2e7e5 100644 --- a/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_payment_form_spec.rb +++ b/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/copy_cards_payment_form_spec.rb @@ -21,10 +21,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "copy_cards_bank_transfer_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "copy_cards_form" - end end end end diff --git a/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/wordpay_form_spec.rb b/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/wordpay_form_spec.rb index 8680e7f42..65d79ee4e 100644 --- a/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/wordpay_form_spec.rb +++ b/spec/models/waste_carriers_engine/order_copy_cards_registration_workflow_state/wordpay_form_spec.rb @@ -11,10 +11,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "copy_cards_order_completed_form" end - - context "on back" do - include_examples "has back transition", previous_state: "copy_cards_payment_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/business_type_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/business_type_form_spec.rb index 740ab3775..4f95d7799 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/business_type_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/business_type_form_spec.rb @@ -45,22 +45,6 @@ module WasteCarriersEngine end end end - - context "on back" do - { - # Permutation table of location and the state that should result - "england" => :location_form, - "northern_ireland" => :register_in_northern_ireland_form, - "scotland" => :register_in_scotland_form, - "wales" => :register_in_wales_form - }.each do |location, expected_previous_state| - context "when the location is #{location}" do - before { subject.location = location } - - include_examples "has back transition", previous_state: expected_previous_state - end - end - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/cannot_renew_type_change_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/cannot_renew_type_change_form_spec.rb index d79e18730..607ac3bc0 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/cannot_renew_type_change_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/cannot_renew_type_change_form_spec.rb @@ -17,10 +17,6 @@ module WasteCarriersEngine expect(subject).to_not allow_event :next end end - - context "on back" do - include_examples "has back transition", previous_state: "business_type_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/cards_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/cards_form_spec.rb index 431748c90..940e0ee15 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/cards_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/cards_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "payment_summary_form" end - - context "on back" do - include_examples "has back transition", previous_state: "declaration_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/cbd_type_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/cbd_type_form_spec.rb index 47defc4fc..939d586a9 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/cbd_type_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/cbd_type_form_spec.rb @@ -15,20 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "renewal_information_form" end - - context "on back" do - context "when the registration is not overseas" do - before { subject.location = "england" } - - include_examples "has back transition", previous_state: "business_type_form" - end - - context "when the registration is overseas" do - before { subject.location = "overseas" } - - include_examples "has back transition", previous_state: "location_form" - end - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/check_registered_company_name_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/check_registered_company_name_form_spec.rb index 7668523ad..6268ab512 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/check_registered_company_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/check_registered_company_name_form_spec.rb @@ -21,10 +21,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "incorrect_company_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "renewal_information_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/check_your_answers_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/check_your_answers_form_spec.rb index 2e082b888..e91c5b9db 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/check_your_answers_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/check_your_answers_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "declaration_form" end - - context "on back" do - include_examples "has back transition", previous_state: "contact_address_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/company_address_manual_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/company_address_manual_form_spec.rb index 372a36434..8ef27f218 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/company_address_manual_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/company_address_manual_form_spec.rb @@ -9,7 +9,6 @@ module WasteCarriersEngine let(:tier) { WasteCarriersEngine::Registration::UPPER_TIER } it_behaves_like "a manual address transition", - previous_state_if_overseas: :company_name_form, next_state: :declare_convictions_form, address_type: "company", factory: :renewing_registration @@ -19,7 +18,6 @@ module WasteCarriersEngine let(:tier) { WasteCarriersEngine::Registration::LOWER_TIER } it_behaves_like "a manual address transition", - previous_state_if_overseas: :company_name_form, next_state: :contact_name_form, address_type: "company", factory: :renewing_registration diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/company_name_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/company_name_form_spec.rb index b4756a246..af8e93df0 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/company_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/company_name_form_spec.rb @@ -27,57 +27,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "company_address_manual_form" end end - - context "on back" do - - shared_examples "main_people_form or renewal_information_form depending on tier" do - context "when the registraton is upper tier" do - let(:tier) { WasteCarriersEngine::Registration::UPPER_TIER } - include_examples "has back transition", previous_state: "main_people_form" - end - - context "when the registration is lower tier" do - let(:tier) { WasteCarriersEngine::Registration::LOWER_TIER } - include_examples "has back transition", previous_state: "renewal_information_form" - end - end - - context "when the business type is partnership" do - let(:business_type) { "partnership" } - - it_behaves_like "main_people_form or renewal_information_form depending on tier" - end - - context "when the business type is soleTrader" do - let(:business_type) { "soleTrader" } - - it_behaves_like "main_people_form or renewal_information_form depending on tier" - end - - context "when the business type is localAuthority" do - let(:business_type) { "localAuthority" } - - it_behaves_like "main_people_form or renewal_information_form depending on tier" - end - - context "when the location is overseas" do - let(:location) { "overseas" } - - it_behaves_like "main_people_form or renewal_information_form depending on tier" - end - - context "when the business type is limitedCompany" do - let(:business_type) { "limitedCompany" } - - include_examples "has back transition", previous_state: "check_registered_company_name_form" - end - - context "when the business type is limitedLiabilityPartnership" do - let(:business_type) { "limitedLiabilityPartnership" } - - include_examples "has back transition", previous_state: "check_registered_company_name_form" - end - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/company_postcode_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/company_postcode_form_spec.rb index bb801e2fe..f351f9081 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/company_postcode_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/company_postcode_form_spec.rb @@ -7,7 +7,6 @@ module WasteCarriersEngine describe "#workflow_state" do it_behaves_like "a postcode transition", - previous_state: :company_name_form, address_type: "company", factory: :renewing_registration diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/confirm_bank_transfer_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/confirm_bank_transfer_form_spec.rb index 05572f6ab..e6eecf937 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/confirm_bank_transfer_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/confirm_bank_transfer_form_spec.rb @@ -25,10 +25,6 @@ module WasteCarriersEngine subject.next! end end - - context "on back" do - include_examples "has back transition", previous_state: "payment_summary_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_address_manual_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_address_manual_form_spec.rb index 145fc705b..eca80d930 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_address_manual_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_address_manual_form_spec.rb @@ -6,7 +6,6 @@ module WasteCarriersEngine RSpec.describe RenewingRegistration do describe "#workflow_state" do it_behaves_like "a manual address transition", - previous_state_if_overseas: :contact_email_form, next_state: :check_your_answers_form, address_type: "contact", factory: :renewing_registration diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_email_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_email_form_spec.rb index f3d94991b..fc798134a 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_email_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_email_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_postcode_form" end - - context "on back" do - include_examples "has back transition", previous_state: "contact_phone_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_name_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_name_form_spec.rb index 02d7e7101..845e410c0 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_name_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_name_form_spec.rb @@ -17,20 +17,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_phone_form" end - - context "on back" do - context "when declared_convictions is no" do - let(:declared_convictions) { "no" } - - include_examples "has back transition", previous_state: "declare_convictions_form" - end - - context "when declared_convictions is yes" do - let(:declared_convictions) { "yes" } - - include_examples "has back transition", previous_state: "conviction_details_form" - end - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_phone_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_phone_form_spec.rb index 527794b19..154c91dd2 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_phone_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_phone_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_email_form" end - - context "on back" do - include_examples "has back transition", previous_state: "contact_name_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_postcode_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_postcode_form_spec.rb index 6a86f5be6..de766ad80 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_postcode_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/contact_postcode_form_spec.rb @@ -6,7 +6,6 @@ module WasteCarriersEngine RSpec.describe RenewingRegistration do describe "#workflow_state" do it_behaves_like "a postcode transition", - previous_state: :contact_email_form, address_type: "contact", factory: :renewing_registration end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/conviction_details_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/conviction_details_form_spec.rb index f0929eecb..6fd726e28 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/conviction_details_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/conviction_details_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "contact_name_form" end - - context "on back" do - include_examples "has back transition", previous_state: "declare_convictions_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/declaration_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/declaration_form_spec.rb index ad65e846a..501433832 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/declaration_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/declaration_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "cards_form" end - - context "on back" do - include_examples "has back transition", previous_state: "check_your_answers_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/declare_convictions_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/declare_convictions_form_spec.rb index 2733e2839..dd4d01292 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/declare_convictions_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/declare_convictions_form_spec.rb @@ -28,17 +28,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "contact_name_form" end end - - context "on back" do - context "when the registered address was manually entered" do - let(:registered_address) { build(:address, :registered, :manual_foreign) } - subject { build(:renewing_registration, workflow_state: "declare_convictions_form", registered_address: registered_address) } - - include_examples "has back transition", previous_state: "company_address_manual_form" - end - - include_examples "has back transition", previous_state: "company_address_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/incorrect_company_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/incorrect_company_form_spec.rb deleted file mode 100644 index 16c616c67..000000000 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/incorrect_company_form_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -module WasteCarriersEngine - RSpec.describe RenewingRegistration, type: :model do - subject do - build(:renewing_registration, :has_required_data, workflow_state: "incorrect_company_form") - end - - describe "#workflow_state" do - context ":incorrect_company_form state transitions" do - context "on back" do - include_examples "has back transition", previous_state: "check_registered_company_name_form" - end - end - end - end -end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/location_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/location_form_spec.rb index fc279bf75..23cd5bcc9 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/location_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/location_form_spec.rb @@ -30,10 +30,6 @@ module WasteCarriersEngine end end end - - context "on back" do - include_examples "has back transition", previous_state: "renewal_start_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/main_people_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/main_people_form_spec.rb index da850048e..e76129aca 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/main_people_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/main_people_form_spec.rb @@ -19,20 +19,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "company_name_form" end - - context "on back" do - context "when the business type is limited company" do - let(:business_type) { "limitedCompany" } - - include_examples "has back transition", previous_state: "check_registered_company_name_form" - end - - context "when the business type is sole trader" do - let(:business_type) { "soleTrader" } - - include_examples "has back transition", previous_state: "cbd_type_form" - end - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/payment_summary_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/payment_summary_form_spec.rb index fef74e62c..b195ff23c 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/payment_summary_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/payment_summary_form_spec.rb @@ -27,10 +27,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "confirm_bank_transfer_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "cards_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_northern_ireland_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_northern_ireland_form_spec.rb index c3607ba52..20853abcc 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_northern_ireland_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_northern_ireland_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "business_type_form" end - - context "on back" do - include_examples "has back transition", previous_state: "location_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_scotland_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_scotland_form_spec.rb index dffeba043..72ef64a16 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_scotland_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_scotland_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "business_type_form" end - - context "on back" do - include_examples "has back transition", previous_state: "location_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_wales_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_wales_form_spec.rb index c67d732fb..576f699c1 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_wales_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/register_in_wales_form_spec.rb @@ -15,10 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "business_type_form" end - - context "on back" do - include_examples "has back transition", previous_state: "location_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_information_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_information_form_spec.rb index 378e4c0a6..b7a2238a0 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_information_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_information_form_spec.rb @@ -68,10 +68,6 @@ module WasteCarriersEngine include_examples "has next transition", next_state: "check_registered_company_name_form" end end - - context "on back" do - include_examples "has back transition", previous_state: "cbd_type_form" - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_start_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_start_form_spec.rb index 552f36a35..45f64cae3 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_start_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/renewal_start_form_spec.rb @@ -15,12 +15,6 @@ module WasteCarriersEngine context "on next" do include_examples "has next transition", next_state: "location_form" end - - context "on back" do - it "does not respond to the 'back' event" do - expect(subject).to_not allow_event :back - end - end end end end diff --git a/spec/models/waste_carriers_engine/renewing_registration_workflow/worldpay_form_spec.rb b/spec/models/waste_carriers_engine/renewing_registration_workflow/worldpay_form_spec.rb index 4db38a787..6d25efd06 100644 --- a/spec/models/waste_carriers_engine/renewing_registration_workflow/worldpay_form_spec.rb +++ b/spec/models/waste_carriers_engine/renewing_registration_workflow/worldpay_form_spec.rb @@ -74,10 +74,6 @@ module WasteCarriersEngine end end end - - context "on back" do - include_examples "has back transition", previous_state: "payment_summary_form" - end end end end diff --git a/spec/models/waste_carriers_engine/transient_registration_spec.rb b/spec/models/waste_carriers_engine/transient_registration_spec.rb index 387b47b34..98500c6e6 100644 --- a/spec/models/waste_carriers_engine/transient_registration_spec.rb +++ b/spec/models/waste_carriers_engine/transient_registration_spec.rb @@ -181,5 +181,112 @@ module WasteCarriersEngine expect { transient_registration.registration }.to raise_error(NotImplementedError) end end + + describe "#next_state!" do + let(:new_registration) { build(:new_registration, :has_required_data) } + + subject { new_registration.next_state! } + + context "with no available next state" do + before { new_registration.workflow_state = "registration_completed_form" } + + it "does not change the state" do + expect { subject }.not_to change { new_registration.workflow_state } + end + + it "does not add to workflow history" do + expect { subject }.not_to change { new_registration.workflow_history } + end + end + + context "with an invalid state" do + before { new_registration.workflow_state = "not_valid" } + + it "does not change the state" do + expect { subject }.not_to change { new_registration.workflow_state } + end + + it "does not add to workflow history" do + expect { subject }.not_to change { new_registration.workflow_history } + end + end + + context "with a valid state" do + before { new_registration.workflow_state = "location_form" } + + it "changes the state" do + expect { subject }.to change { new_registration.workflow_state }.to("business_type_form") + end + + it "adds to workflow history" do + expect { subject }.to change { new_registration.workflow_history.length }.from(0).to(1) + end + + it "adds the previous state to workflow history" do + expect { subject }.to change { new_registration.workflow_history }.to(["location_form"]) + end + end + end + + describe "#previous_valid_state!" do + let(:new_registration) { build(:new_registration, :has_required_data) } + + subject { new_registration.previous_valid_state! } + + context "with no workflow history" do + before { new_registration.workflow_history = [] } + before { new_registration.workflow_state = "location_form" } + + it "uses the default state" do + expect { subject }.to change { new_registration.workflow_state }.to("start_form") + end + + it "does not modify workflow history" do + expect { subject }.not_to change { new_registration.workflow_history } + end + end + + context "with partially invalid workflow history" do + before { new_registration.workflow_history = %w[another_form location_form not_valid] } + + it "skips the invalid state" do + expect { subject }.to change { new_registration.workflow_state }.to("location_form") + end + + it "deletes multiple items workflow history" do + expect { subject }.to change { new_registration.workflow_history.length }.by(-2) + end + end + + context "with fully invalid workflow history" do + before do + new_registration.workflow_state = "location_form" + new_registration.workflow_history = %w[no_start_form not_valid] + end + + it "uses the default state" do + expect { subject }.to change { new_registration.workflow_state }.to("start_form") + end + + it "deletes all items from workflow history" do + expect { subject }.to change { new_registration.workflow_history.length }.to(0) + end + end + + context "with valid workflow history" do + before do + new_registration.workflow_history = %w[start_form location_form] + new_registration.workflow_state = "business_type_form" + end + + it "changes the state" do + expect { subject }.to change { new_registration.workflow_state }.to("location_form") + end + + it "deletes from workflow history" do + expect { subject }.to change { new_registration.workflow_history.length }.by(-1) + end + end + end end end diff --git a/spec/requests/waste_carriers_engine/business_type_forms_spec.rb b/spec/requests/waste_carriers_engine/business_type_forms_spec.rb index f7fbfe340..cbfc42c3b 100644 --- a/spec/requests/waste_carriers_engine/business_type_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/business_type_forms_spec.rb @@ -62,50 +62,5 @@ module WasteCarriersEngine end end end - - describe "GET back_business_type_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "business_type_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the location form" do - get back_business_type_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "location_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_business_type_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/cannot_renew_type_change_forms_spec.rb b/spec/requests/waste_carriers_engine/cannot_renew_type_change_forms_spec.rb index 1ec78709d..0c4ec4f20 100644 --- a/spec/requests/waste_carriers_engine/cannot_renew_type_change_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/cannot_renew_type_change_forms_spec.rb @@ -5,50 +5,5 @@ module WasteCarriersEngine RSpec.describe "CannotRenewTypeChangeForms", type: :request do include_examples "GET flexible form", "cannot_renew_type_change_form" - - describe "GET back_cannot_renew_type_change_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "cannot_renew_type_change_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the business_type form" do - get back_cannot_renew_type_change_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_business_type_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_cannot_renew_type_change_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/cards_forms_spec.rb b/spec/requests/waste_carriers_engine/cards_forms_spec.rb index 98c642b41..79ad0fcf8 100644 --- a/spec/requests/waste_carriers_engine/cards_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/cards_forms_spec.rb @@ -24,50 +24,5 @@ module WasteCarriersEngine invalid_params: { temp_cards: 999_999 } end end - - describe "GET back_cards_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "cards_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the declaration form" do - get back_cards_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_declaration_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_cards_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/cbd_type_forms_spec.rb b/spec/requests/waste_carriers_engine/cbd_type_forms_spec.rb index 5d8fdb35b..575b92fa4 100644 --- a/spec/requests/waste_carriers_engine/cbd_type_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/cbd_type_forms_spec.rb @@ -24,103 +24,5 @@ module WasteCarriersEngine invalid_params: { registration_type: "foo" } end end - - describe "GET back_cbd_type_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when the back action is triggered" do - - context "for a new registration" do - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - temp_check_your_tier: temp_check_your_tier, - workflow_state: "cbd_type_form") - end - - context "when the answer to check your tier is upper" do - let(:temp_check_your_tier) { "upper" } - - it "returns a 302 response and redirects to the check_your_tier form" do - get back_cbd_type_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_check_your_tier_form_path(transient_registration.token)) - end - end - - context "when the answer to check your tier is not upper" do - let(:temp_check_your_tier) { "unknown" } - - it "returns a 302 response and redirects to the your_tier form" do - get back_cbd_type_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_your_tier_form_path(transient_registration.token)) - end - end - end - end - - context "for a renewing registration" do - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - location: location, - workflow_state: "cbd_type_form") - end - - context "when the business is not based overseas" do - let(:location) { "england" } - - it "returns a 302 response and redirects to the business_type form" do - get back_cbd_type_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_business_type_form_path(transient_registration.token)) - end - end - - context "when the business is based overseas" do - let(:location) { "overseas" } - - it "returns a 302 response and redirects to the location_tier form" do - get back_cbd_type_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration.token)) - end - end - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_cbd_type_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/check_registered_company_name_forms_spec.rb b/spec/requests/waste_carriers_engine/check_registered_company_name_forms_spec.rb index 8f683dcfc..c5b422bc3 100644 --- a/spec/requests/waste_carriers_engine/check_registered_company_name_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/check_registered_company_name_forms_spec.rb @@ -60,46 +60,5 @@ module WasteCarriersEngine invalid_params: { temp_use_registered_company_details: "foo", company_no: "09360070" } end end - - describe "GET back_check_registered_company_name_form_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "for a new registration" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "check_registered_company_name_form") - end - - it "returns a 302 response and redirects to the registration_number_form" do - get back_check_registered_company_name_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(registration_number_forms_path(transient_registration[:token])) - end - end - - context "for a registration renewal" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "check_registered_company_name_form") - end - - it "returns a 302 response and redirects to the renewal_information_form" do - get back_check_registered_company_name_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(renewal_information_forms_path(transient_registration[:token])) - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/check_your_answers_forms_spec.rb b/spec/requests/waste_carriers_engine/check_your_answers_forms_spec.rb index d2fbc56ee..ef8a8801c 100644 --- a/spec/requests/waste_carriers_engine/check_your_answers_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/check_your_answers_forms_spec.rb @@ -11,50 +11,5 @@ module WasteCarriersEngine include_examples "GET flexible form", "check_your_answers_form" include_examples "POST without params form", "check_your_answers_form" - - describe "GET back_check_your_answers_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "check_your_answers_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the contact_address form" do - get back_check_your_answers_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_address_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered and redirects to the correct form for the state" do - it "returns a 302 response" do - get back_check_your_answers_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/check_your_tier_forms_spec.rb b/spec/requests/waste_carriers_engine/check_your_tier_forms_spec.rb index 56682e673..7ae1bbbc3 100644 --- a/spec/requests/waste_carriers_engine/check_your_tier_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/check_your_tier_forms_spec.rb @@ -46,41 +46,5 @@ module WasteCarriersEngine valid_params: { temp_check_your_tier: "lower" }, invalid_params: { temp_check_your_tier: "foo" } end - - describe "GET back_check_your_tier_forms_path" do - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - workflow_state: "check_your_tier_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the business_type form" do - get back_check_your_tier_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_business_type_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - workflow_state: "location_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_check_your_tier_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration.token)) - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/company_address_forms_spec.rb b/spec/requests/waste_carriers_engine/company_address_forms_spec.rb index f50607c5b..9e89652dc 100644 --- a/spec/requests/waste_carriers_engine/company_address_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/company_address_forms_spec.rb @@ -120,53 +120,6 @@ module WasteCarriersEngine end end - describe "GET back_company_address_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - :has_postcode, - account_email: user.email, - workflow_state: "company_address_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the company_postcode form" do - get back_company_address_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_company_postcode_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - :has_postcode, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_company_address_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end - describe "GET skip_to_manual_address_company_address_forms_path" do context "when a valid user is signed in" do let(:user) { create(:user) } diff --git a/spec/requests/waste_carriers_engine/company_address_manual_forms_spec.rb b/spec/requests/waste_carriers_engine/company_address_manual_forms_spec.rb index dfb0e4f70..be08ec51d 100644 --- a/spec/requests/waste_carriers_engine/company_address_manual_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/company_address_manual_forms_spec.rb @@ -114,65 +114,5 @@ module WasteCarriersEngine end end end - - describe "GET back_company_address_manual_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "company_address_manual_form") - end - - context "when the back action is triggered" do - context "when the location is 'overseas'" do - before(:each) { transient_registration.update_attributes(location: "overseas") } - - it "returns a 302 response and redirects to the company_name form" do - get back_company_address_manual_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_company_name_form_path(transient_registration.token)) - end - end - - context "when the location is not 'overseas'" do - before(:each) { transient_registration.update_attributes(location: "england") } - - it "returns a 302 response and redirects to the company_postcode form" do - get back_company_address_manual_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_company_postcode_form_path(transient_registration.token)) - end - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_company_address_manual_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/company_name_forms_spec.rb b/spec/requests/waste_carriers_engine/company_name_forms_spec.rb index 9695d97e6..fb93219ee 100644 --- a/spec/requests/waste_carriers_engine/company_name_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/company_name_forms_spec.rb @@ -24,114 +24,5 @@ module WasteCarriersEngine invalid_params: { company_name: "" } end end - - describe "GET back_company_name_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:tier) { WasteCarriersEngine::Registration::UPPER_TIER } - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - tier: tier, - workflow_state: "company_name_form") - end - - context "when the back action is triggered" do - - shared_examples "redirects to renewal_information or main_people form based on tier" do - context "when upper tier" do - let(:tier) { WasteCarriersEngine::Registration::UPPER_TIER } - it "returns a 302 response and redirects to the main_people form" do - get back_company_name_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_main_people_form_path(transient_registration[:token])) - end - end - - context "when lower tier" do - let(:tier) { WasteCarriersEngine::Registration::LOWER_TIER } - it "returns a 302 response and redirects to the renewal_information form" do - get back_company_name_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:token])) - end - end - end - - context "when the business type is localAuthority" do - before(:each) { transient_registration.update_attributes(business_type: "localAuthority") } - - it_behaves_like "redirects to renewal_information or main_people form based on tier" - end - - context "when the business type is partnership" do - before(:each) { transient_registration.update_attributes(business_type: "partnership") } - - it_behaves_like "redirects to renewal_information or main_people form based on tier" - end - - context "when the business type is soleTrader" do - before(:each) { transient_registration.update_attributes(business_type: "soleTrader") } - - it_behaves_like "redirects to renewal_information or main_people form based on tier" - end - - context "when the location is overseas" do - before(:each) { transient_registration.update_attributes(location: "overseas") } - - it_behaves_like "redirects to renewal_information or main_people form based on tier" - end - - context "when the business type is limitedCompany" do - before(:each) { transient_registration.update_attributes(business_type: "limitedCompany") } - - it "returns a 302 response and redirects to the check_registered_company_name form" do - get back_company_name_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_check_registered_company_name_form_path(transient_registration[:token])) - end - end - - context "when the business type is limitedLiabilityPartnership" do - before(:each) { transient_registration.update_attributes(business_type: "limitedLiabilityPartnership") } - - it "returns a 302 response and redirects to the check_registered_company_name form" do - get back_company_name_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_check_registered_company_name_form_path(transient_registration[:token])) - end - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_company_name_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/company_postcode_forms_spec.rb b/spec/requests/waste_carriers_engine/company_postcode_forms_spec.rb index 5d3ac36a3..4ec2976ad 100644 --- a/spec/requests/waste_carriers_engine/company_postcode_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/company_postcode_forms_spec.rb @@ -83,56 +83,6 @@ module WasteCarriersEngine end end - describe "GET back_company_postcode_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "company_postcode_form") - end - - context "when the back action is triggered" do - it "returns a 302 response" do - get back_company_postcode_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - end - end - - it "redirects to the company_name form" do - get back_company_postcode_forms_path(transient_registration[:token]) - - expect(response).to redirect_to(new_company_name_form_path(transient_registration[:token])) - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_company_postcode_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end - describe "GET skip_to_manual_address_company_postcode_forms_path" do context "when a valid user is signed in" do let(:user) { create(:user) } diff --git a/spec/requests/waste_carriers_engine/confirm_bank_transfer_forms_spec.rb b/spec/requests/waste_carriers_engine/confirm_bank_transfer_forms_spec.rb index 537459c14..6eb982fde 100644 --- a/spec/requests/waste_carriers_engine/confirm_bank_transfer_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/confirm_bank_transfer_forms_spec.rb @@ -102,52 +102,5 @@ module WasteCarriersEngine end end end - - describe "GET back_confirm_bank_transfer_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - :has_unpaid_balance, - account_email: user.email, - workflow_state: "confirm_bank_transfer_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the payment_summary form" do - get back_confirm_bank_transfer_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_payment_summary_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - :has_unpaid_balance, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_confirm_bank_transfer_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/confirm_edit_cancelled_forms_spec.rb b/spec/requests/waste_carriers_engine/confirm_edit_cancelled_forms_spec.rb index ccd0cc581..c7cde4bb7 100644 --- a/spec/requests/waste_carriers_engine/confirm_edit_cancelled_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/confirm_edit_cancelled_forms_spec.rb @@ -63,44 +63,5 @@ module WasteCarriersEngine end end end - - describe "GET back_confirm_edit_cancelled_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:edit_registration, - workflow_state: "confirm_edit_cancelled_form") - end - - context "when the back action is triggered" do - it "redirects to the edit form" do - get back_confirm_edit_cancelled_forms_path(transient_registration[:token]) - - expect(response).to redirect_to(new_edit_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:edit_registration, - workflow_state: "location_form") - end - - context "when the back action is triggered" do - it "redirects to the correct form for the state" do - get back_confirm_edit_cancelled_forms_path(transient_registration[:token]) - - expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/construction_demolition_forms_spec.rb b/spec/requests/waste_carriers_engine/construction_demolition_forms_spec.rb index 0a82669c8..9ac7f3442 100644 --- a/spec/requests/waste_carriers_engine/construction_demolition_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/construction_demolition_forms_spec.rb @@ -18,65 +18,5 @@ module WasteCarriersEngine invalid_params: { construction_waste: "foo" } end end - - describe "GET back_construction_demolition_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "construction_demolition_form") - end - - context "when the back action is triggered" do - context "when the business does not carry waste for other businesses or households" do - before(:each) { transient_registration.update_attributes(other_businesses: "no") } - - it "returns a 302 response and redirects to the other_businesses form" do - get back_construction_demolition_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_other_businesses_form_path(transient_registration.token)) - end - end - - context "when the business does carry waste for other businesses or households" do - before(:each) { transient_registration.update_attributes(other_businesses: "yes") } - - it "returns a 302 response and redirects to the service_provided form" do - get back_construction_demolition_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_service_provided_form_path(transient_registration.token)) - end - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_construction_demolition_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/contact_address_forms_spec.rb b/spec/requests/waste_carriers_engine/contact_address_forms_spec.rb index 4dbdd16da..c062f4294 100644 --- a/spec/requests/waste_carriers_engine/contact_address_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_address_forms_spec.rb @@ -87,53 +87,6 @@ module WasteCarriersEngine end end - describe "GET back_contact_address_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - :has_postcode, - account_email: user.email, - workflow_state: "contact_address_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the contact_postcode form" do - get back_contact_address_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_postcode_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - :has_postcode, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_contact_address_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end - describe "GET skip_to_manual_address_contact_address_forms_path" do context "when a valid user is signed in" do let(:user) { create(:user) } diff --git a/spec/requests/waste_carriers_engine/contact_address_manual_forms_spec.rb b/spec/requests/waste_carriers_engine/contact_address_manual_forms_spec.rb index 8f8b4b0af..867a1a48b 100644 --- a/spec/requests/waste_carriers_engine/contact_address_manual_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_address_manual_forms_spec.rb @@ -95,59 +95,5 @@ module WasteCarriersEngine end end end - - describe "GET back_contact_address_manual_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "contact_address_manual_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the contact_postcode form" do - get back_contact_address_manual_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_postcode_form_path(transient_registration[:token])) - end - - context "when the location is 'overseas'" do - before(:each) { transient_registration.update_attributes(location: "overseas") } - - it "redirects to the contact_email form" do - get back_contact_address_manual_forms_path(transient_registration[:token]) - expect(response).to redirect_to(new_contact_email_form_path(transient_registration[:token])) - end - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_contact_address_manual_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/contact_address_reuse_forms_spec.rb b/spec/requests/waste_carriers_engine/contact_address_reuse_forms_spec.rb index 890f6d396..2f82f7a4a 100644 --- a/spec/requests/waste_carriers_engine/contact_address_reuse_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_address_reuse_forms_spec.rb @@ -56,27 +56,5 @@ module WasteCarriersEngine end end end - - describe "GET back_contact_address_reuse_form_path" do - context "when a valid user is signed in" do - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "contact_address_reuse_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the contact_email form" do - get back_contact_address_reuse_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_email_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/contact_email_forms_spec.rb b/spec/requests/waste_carriers_engine/contact_email_forms_spec.rb index d96142680..2d2be1025 100644 --- a/spec/requests/waste_carriers_engine/contact_email_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_email_forms_spec.rb @@ -24,50 +24,5 @@ module WasteCarriersEngine invalid_params: { contact_email: "bar", confirmed_email: "baz" } end end - - describe "GET back_contact_email_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "contact_email_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the contact_phone form" do - get back_contact_email_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_phone_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_contact_email_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/contact_name_forms_spec.rb b/spec/requests/waste_carriers_engine/contact_name_forms_spec.rb index ab2d33a67..55a98ea55 100644 --- a/spec/requests/waste_carriers_engine/contact_name_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_name_forms_spec.rb @@ -24,50 +24,5 @@ module WasteCarriersEngine invalid_params: { first_name: "", last_name: "" } end end - - describe "GET back_contact_name_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "contact_name_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the declare_convictions form" do - get back_contact_name_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_contact_name_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/contact_phone_forms_spec.rb b/spec/requests/waste_carriers_engine/contact_phone_forms_spec.rb index 4e0ff78b0..9169d9e24 100644 --- a/spec/requests/waste_carriers_engine/contact_phone_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_phone_forms_spec.rb @@ -24,50 +24,5 @@ module WasteCarriersEngine invalid_params: { phone_number: "foo" } end end - - describe "GET back_contact_phone_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "contact_phone_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the contact_name form" do - get back_contact_phone_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_name_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_contact_phone_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/contact_postcode_forms_spec.rb b/spec/requests/waste_carriers_engine/contact_postcode_forms_spec.rb index bb728c4ed..281079f7f 100644 --- a/spec/requests/waste_carriers_engine/contact_postcode_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_postcode_forms_spec.rb @@ -96,51 +96,6 @@ module WasteCarriersEngine end end - describe "GET back_contact_postcode_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "contact_postcode_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the contact_email form" do - get back_contact_postcode_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_email_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_contact_postcode_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end - describe "GET skip_to_manual_address_contact_postcode_forms_path" do context "when a valid user is signed in" do let(:user) { create(:user) } diff --git a/spec/requests/waste_carriers_engine/conviction_details_forms_spec.rb b/spec/requests/waste_carriers_engine/conviction_details_forms_spec.rb index 6d3e8f39d..2e7a06be8 100644 --- a/spec/requests/waste_carriers_engine/conviction_details_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/conviction_details_forms_spec.rb @@ -174,51 +174,6 @@ module WasteCarriersEngine end end - describe "GET back_conviction_details_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "conviction_details_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the declare_convictions form" do - get back_conviction_details_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_conviction_details_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end - describe "DELETE delete_person_conviction_details_forms_path" do context "when a valid user is signed in" do let(:user) { create(:user) } diff --git a/spec/requests/waste_carriers_engine/copy_cards_bank_transfer_forms_spec.rb b/spec/requests/waste_carriers_engine/copy_cards_bank_transfer_forms_spec.rb index 746b9fc37..08f710cf8 100644 --- a/spec/requests/waste_carriers_engine/copy_cards_bank_transfer_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/copy_cards_bank_transfer_forms_spec.rb @@ -66,44 +66,5 @@ module WasteCarriersEngine end end end - - describe "GET back_copy_cards_bank_transfer_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:order_copy_cards_registration, workflow_state: :copy_cards_bank_transfer_form) - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the payment_summary form" do - get back_copy_cards_bank_transfer_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_copy_cards_payment_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:order_copy_cards_registration, workflow_state: :copy_cards_bank_transfer_form) - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_copy_cards_bank_transfer_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_copy_cards_payment_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/declaration_forms_spec.rb b/spec/requests/waste_carriers_engine/declaration_forms_spec.rb index c3e0d0ea5..ef8e6130a 100644 --- a/spec/requests/waste_carriers_engine/declaration_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/declaration_forms_spec.rb @@ -56,50 +56,5 @@ module WasteCarriersEngine end end end - - describe "GET back_declaration_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "declaration_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the check_your_answers form" do - get back_declaration_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_check_your_answers_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_declaration_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/declare_convictions_forms_spec.rb b/spec/requests/waste_carriers_engine/declare_convictions_forms_spec.rb index 7bf9bb60a..97d00d2bc 100644 --- a/spec/requests/waste_carriers_engine/declare_convictions_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/declare_convictions_forms_spec.rb @@ -24,50 +24,5 @@ module WasteCarriersEngine invalid_params: { declared_convictions: "foo" } end end - - describe "GET back_declare_convictions_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "declare_convictions_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the company_address form" do - get back_declare_convictions_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_company_address_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_declare_convictions_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/edit_bank_transfer_forms_spec.rb b/spec/requests/waste_carriers_engine/edit_bank_transfer_forms_spec.rb index e44274ed2..b389f6a3a 100644 --- a/spec/requests/waste_carriers_engine/edit_bank_transfer_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/edit_bank_transfer_forms_spec.rb @@ -66,44 +66,5 @@ module WasteCarriersEngine end end end - - describe "GET back_edit_bank_transfer_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:edit_registration, workflow_state: :edit_bank_transfer_form) - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the payment_summary form" do - get back_edit_bank_transfer_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_edit_payment_summary_form_path(transient_registration.token)) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:edit_registration, workflow_state: :location_form) - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_edit_bank_transfer_forms_path(transient_registration.token) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration.token)) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/incorrect_company_forms_spec.rb b/spec/requests/waste_carriers_engine/incorrect_company_forms_spec.rb index fecb0cbd8..da5697f14 100644 --- a/spec/requests/waste_carriers_engine/incorrect_company_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/incorrect_company_forms_spec.rb @@ -18,32 +18,5 @@ module WasteCarriersEngine expect(response).to redirect_to(new_registration_number_form_path(transient_registration.token)) end end - - describe "GET back_incorrect_company_form_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "incorrect_company_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the check_registered_company_name" do - get back_incorrect_company_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(check_registered_company_name_forms_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/location_forms_spec.rb b/spec/requests/waste_carriers_engine/location_forms_spec.rb index 44d943e63..35e3fd28d 100644 --- a/spec/requests/waste_carriers_engine/location_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/location_forms_spec.rb @@ -50,50 +50,5 @@ module WasteCarriersEngine end end end - - describe "GET back_location_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "location_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the renewal_start form" do - get back_location_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "company_name_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_location_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_company_name_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/main_people_forms_spec.rb b/spec/requests/waste_carriers_engine/main_people_forms_spec.rb index 71225cf85..131972f2a 100644 --- a/spec/requests/waste_carriers_engine/main_people_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/main_people_forms_spec.rb @@ -196,66 +196,6 @@ module WasteCarriersEngine end end - describe "GET back_main_people_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - business_type: defined?(business_type) ? business_type : "limitedCompany", - workflow_state: "main_people_form") - end - - context "when the back action is triggered" do - it "returns a 302 response" do - get back_main_people_forms_path(transient_registration[:token]) - expect(response).to have_http_status(302) - end - - context "when the business type is limitedCompany" do - let(:business_type) { "limitedCompany" } - it "redirects to the check_registered_company_name form" do - get back_main_people_forms_path(transient_registration[:token]) - expect(response).to redirect_to(new_check_registered_company_name_form_path(transient_registration[:token])) - end - end - - context "when the business type is soleTrader" do - let(:business_type) { "soleTrader" } - it "redirects to the cbd_type form" do - get back_main_people_forms_path(transient_registration[:token]) - expect(response).to redirect_to(new_cbd_type_form_path(transient_registration[:token])) - end - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_main_people_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end - describe "DELETE delete_person_main_people_forms_path" do context "when a valid user is signed in" do let(:user) { create(:user) } diff --git a/spec/requests/waste_carriers_engine/other_businesses_forms_spec.rb b/spec/requests/waste_carriers_engine/other_businesses_forms_spec.rb index e20cbc459..30d9b3d7c 100644 --- a/spec/requests/waste_carriers_engine/other_businesses_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/other_businesses_forms_spec.rb @@ -19,50 +19,5 @@ module WasteCarriersEngine invalid_params: { other_businesses: "foo" } end end - - describe "GET back_other_businesses_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "other_businesses_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the check_your_tier form" do - get back_other_businesses_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_check_your_tier_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_other_businesses_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/payment_summary_forms_spec.rb b/spec/requests/waste_carriers_engine/payment_summary_forms_spec.rb index c632d1c03..168543c2c 100644 --- a/spec/requests/waste_carriers_engine/payment_summary_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/payment_summary_forms_spec.rb @@ -24,50 +24,5 @@ module WasteCarriersEngine invalid_params: { temp_payment_method: "foo" } end end - - describe "GET back_payment_summary_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "payment_summary_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the cards form" do - get back_payment_summary_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_cards_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_payment_summary_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb b/spec/requests/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb index f53146763..862037e60 100644 --- a/spec/requests/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb @@ -7,50 +7,5 @@ module WasteCarriersEngine include_examples "GET flexible form", "register_in_northern_ireland_form" include_examples "POST without params form", "register_in_northern_ireland_form" - - describe "GET back_register_in_northern_ireland_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "register_in_northern_ireland_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the location form" do - get back_register_in_northern_ireland_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_register_in_northern_ireland_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/register_in_scotland_forms_spec.rb b/spec/requests/waste_carriers_engine/register_in_scotland_forms_spec.rb index 809fd878a..396d74778 100644 --- a/spec/requests/waste_carriers_engine/register_in_scotland_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/register_in_scotland_forms_spec.rb @@ -7,50 +7,5 @@ module WasteCarriersEngine include_examples "GET flexible form", "register_in_scotland_form" include_examples "POST without params form", "register_in_scotland_form" - - describe "GET back_register_in_scotland_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "register_in_scotland_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the location form" do - get back_register_in_scotland_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_register_in_scotland_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/register_in_wales_forms_spec.rb b/spec/requests/waste_carriers_engine/register_in_wales_forms_spec.rb index b136c0f1a..e47b408e8 100644 --- a/spec/requests/waste_carriers_engine/register_in_wales_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/register_in_wales_forms_spec.rb @@ -7,50 +7,5 @@ module WasteCarriersEngine include_examples "GET flexible form", "register_in_wales_form" include_examples "POST without params form", "register_in_wales_form" - - describe "GET back_register_in_wales_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "register_in_wales_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the location form" do - get back_register_in_wales_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_register_in_wales_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb b/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb index b71063c63..131f99da1 100644 --- a/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb @@ -66,50 +66,5 @@ module WasteCarriersEngine end end end - - describe "GET back_registration_number_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "registration_number_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the renewal_information form" do - get back_registration_number_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_cbd_type_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response" do - get back_registration_number_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/renew_registration_forms_spec.rb b/spec/requests/waste_carriers_engine/renew_registration_forms_spec.rb index a975781d2..6477598fe 100644 --- a/spec/requests/waste_carriers_engine/renew_registration_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/renew_registration_forms_spec.rb @@ -126,46 +126,5 @@ module WasteCarriersEngine end end end - - describe "GET back_renew_registration_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - workflow_state: "renew_registration_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the start form" do - get back_renew_registration_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_start_form_path(params: { token: transient_registration[:token] })) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:new_registration, - workflow_state: "contact_name_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_renew_registration_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_contact_name_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/renewal_information_forms_spec.rb b/spec/requests/waste_carriers_engine/renewal_information_forms_spec.rb index 6fe166e1c..c41bd9833 100644 --- a/spec/requests/waste_carriers_engine/renewal_information_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/renewal_information_forms_spec.rb @@ -7,50 +7,5 @@ module WasteCarriersEngine include_examples "GET flexible form", "renewal_information_form" include_examples "POST without params form", "renewal_information_form" - - describe "GET back_renewal_information_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_information_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the cbd_type form" do - get back_renewal_information_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_cbd_type_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:renewing_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_renewal_information_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/service_provided_forms_spec.rb b/spec/requests/waste_carriers_engine/service_provided_forms_spec.rb index ad2a47387..4f6c6364a 100644 --- a/spec/requests/waste_carriers_engine/service_provided_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/service_provided_forms_spec.rb @@ -18,50 +18,5 @@ module WasteCarriersEngine invalid_params: { is_main_service: "foo" } end end - - describe "GET back_service_provided_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "service_provided_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the other_businesses form" do - get back_service_provided_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_other_businesses_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_service_provided_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/transient_registrations_spec.rb b/spec/requests/waste_carriers_engine/transient_registrations_spec.rb index 80bc1f010..ea6a98dec 100644 --- a/spec/requests/waste_carriers_engine/transient_registrations_spec.rb +++ b/spec/requests/waste_carriers_engine/transient_registrations_spec.rb @@ -38,5 +38,66 @@ module WasteCarriersEngine end end end + + describe "GET go_back_forms_path" do + context "when a valid transient registration exists" do + let(:tier) { WasteCarriersEngine::Registration::UPPER_TIER } + let(:workflow_state) { "company_name_form" } + let(:workflow_history) { %w[some_form check_registered_company_name_form] } + let(:transient_registration) do + create(:renewing_registration, + :has_required_data, + workflow_state: workflow_state, + workflow_history: workflow_history) + end + + it "returns a 302 response" do + get go_back_forms_path(transient_registration[:token]) + + expect(response).to have_http_status(302) + end + + it "redirects to the previous form in the workflow_history" do + get go_back_forms_path(transient_registration[:token]) + + expect(response).to redirect_to(new_check_registered_company_name_form_path(transient_registration[:token])) + end + + context "when the transient registration has a partially invalid workflow history" do + let(:workflow_history) { %w[check_registered_company_name_form not_a_valid_state] } + + it "redirects to the form for the most recent valid state" do + get go_back_forms_path(transient_registration[:token]) + + expect(response).to redirect_to(new_check_registered_company_name_form_path(transient_registration[:token])) + end + end + + context "when the transient registration has a fully invalid workflow history" do + let(:workflow_history) do + [ + "", + "not_a_valid_state" + ] + end + + it "redirects to the default form" do + get go_back_forms_path(transient_registration[:token]) + + expect(response).to redirect_to(new_start_form_path(token: transient_registration[:token])) + end + end + + context "when the transient registration has no workflow history" do + let(:workflow_history) { [] } + + it "redirects to the default form" do + get go_back_forms_path(transient_registration[:token]) + + expect(response).to redirect_to(new_start_form_path(token: transient_registration[:token])) + end + end + end + end end end diff --git a/spec/requests/waste_carriers_engine/waste_types_forms_spec.rb b/spec/requests/waste_carriers_engine/waste_types_forms_spec.rb index 62d21b28c..5deb8be65 100644 --- a/spec/requests/waste_carriers_engine/waste_types_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/waste_types_forms_spec.rb @@ -18,50 +18,5 @@ module WasteCarriersEngine invalid_params: { only_amf: "foo" } end end - - describe "GET back_waste_types_forms_path" do - context "when a valid user is signed in" do - let(:user) { create(:user) } - before(:each) do - sign_in(user) - end - - context "when a valid transient registration exists" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "waste_types_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the service_provided form" do - get back_waste_types_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_service_provided_form_path(transient_registration[:token])) - end - end - end - - context "when the transient registration is in the wrong state" do - let(:transient_registration) do - create(:new_registration, - :has_required_data, - account_email: user.email, - workflow_state: "renewal_start_form") - end - - context "when the back action is triggered" do - it "returns a 302 response and redirects to the correct form for the state" do - get back_waste_types_forms_path(transient_registration[:token]) - - expect(response).to have_http_status(302) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) - end - end - end - end - end end end diff --git a/spec/requests/waste_carriers_engine/worldpay_forms_spec.rb b/spec/requests/waste_carriers_engine/worldpay_forms_spec.rb index 5dc60aa29..5080bf243 100644 --- a/spec/requests/waste_carriers_engine/worldpay_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/worldpay_forms_spec.rb @@ -22,7 +22,8 @@ module WasteCarriersEngine :has_conviction_search_result, :has_key_people, account_email: user.email, - workflow_state: "worldpay_form") + workflow_state: "worldpay_form", + workflow_history: ["payment_summary_form"]) end let(:token) { transient_registration[:token] } diff --git a/spec/support/shared_examples/request_get_unsuccessful_worldpay_response.rb b/spec/support/shared_examples/request_get_unsuccessful_worldpay_response.rb index 544ab21cd..bbb30a2a3 100644 --- a/spec/support/shared_examples/request_get_unsuccessful_worldpay_response.rb +++ b/spec/support/shared_examples/request_get_unsuccessful_worldpay_response.rb @@ -15,7 +15,8 @@ :has_conviction_search_result, :has_key_people, account_email: user.email, - workflow_state: "worldpay_form") + workflow_state: "worldpay_form", + workflow_history: ["payment_summary_form"]) end let(:token) { transient_registration.token } diff --git a/spec/support/shared_examples/workflow_states/a_manual_address_transition.rb b/spec/support/shared_examples/workflow_states/a_manual_address_transition.rb index d30d8d66d..620c74d68 100644 --- a/spec/support/shared_examples/workflow_states/a_manual_address_transition.rb +++ b/spec/support/shared_examples/workflow_states/a_manual_address_transition.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.shared_examples "a manual address transition" do |previous_state_if_overseas:, next_state:, address_type:, factory:| +RSpec.shared_examples "a manual address transition" do |next_state:, address_type:, factory:| describe "#workflow_state" do current_state = "#{address_type}_address_manual_form".to_sym subject do @@ -9,17 +9,12 @@ end context "when subject.overseas? is false" do - previous_state_if_uk = "#{address_type}_postcode_form".to_sym let(:location) { "england" } - it "can only transition to either #{previous_state_if_uk} or #{next_state}" do + it "can only transition to either #{next_state}" do permitted_states = Helpers::WorkflowStates.permitted_states(subject) - expect(permitted_states).to match_array([previous_state_if_uk, next_state]) - end - - it "changes to #{previous_state_if_uk} after the 'back' event" do - expect(subject).to transition_from(current_state).to(previous_state_if_uk).on_event(:back) + expect(permitted_states).to match_array([next_state]) end it "changes to #{next_state} after the 'next' event" do @@ -30,14 +25,10 @@ context "when subject.overseas? is true" do let(:location) { "overseas" } - it "can only transition to #{previous_state_if_overseas} or #{next_state}" do + it "can only transition to #{next_state}" do permitted_states = Helpers::WorkflowStates.permitted_states(subject) - expect(permitted_states).to match_array([previous_state_if_overseas, next_state].uniq) - end - - it "changes to #{previous_state_if_overseas} after the 'back' event" do - expect(subject).to transition_from(current_state).to(previous_state_if_overseas).on_event(:back) + expect(permitted_states).to match_array([next_state].uniq) end it "changes to #{next_state} after the 'next' event" do diff --git a/spec/support/shared_examples/workflow_states/a_postcode_transition.rb b/spec/support/shared_examples/workflow_states/a_postcode_transition.rb index 80d4fdf41..37775ab72 100644 --- a/spec/support/shared_examples/workflow_states/a_postcode_transition.rb +++ b/spec/support/shared_examples/workflow_states/a_postcode_transition.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.shared_examples "a postcode transition" do |previous_state:, address_type:, factory:| +RSpec.shared_examples "a postcode transition" do |address_type:, factory:| describe "#workflow_state" do current_state = "#{address_type}_postcode_form".to_sym subject(:subject) do @@ -14,10 +14,10 @@ before(:each) { subject.temp_os_places_error = nil } - it "can only transition to either #{previous_state}, #{next_state}, or #{alt_state}" do + it "can only transition to either #{next_state} or #{alt_state}" do permitted_states = Helpers::WorkflowStates.permitted_states(subject) - expect(permitted_states).to match_array([previous_state, next_state, alt_state]) + expect(permitted_states).to match_array([next_state, alt_state]) end it "changes to #{next_state} after the 'next' event" do @@ -30,10 +30,6 @@ .to(alt_state) .on_event(:skip_to_manual_address) end - - it "changes to #{previous_state} after the 'back' event" do - expect(subject).to transition_from(current_state).to(previous_state).on_event(:back) - end end context "when subject.skip_to_manual_address? is true" do @@ -41,19 +37,15 @@ before(:each) { subject.temp_os_places_error = true } - it "can only transition to either #{previous_state} or #{next_state}" do + it "can only transition to either #{next_state}" do permitted_states = Helpers::WorkflowStates.permitted_states(subject) - expect(permitted_states).to match_array([previous_state, next_state]) + expect(permitted_states).to match_array([next_state]) end it "changes to #{next_state} after the 'next' event" do expect(subject).to transition_from(current_state).to(next_state).on_event(:next) end - - it "changes to #{previous_state} after the 'back' event" do - expect(subject).to transition_from(current_state).to(previous_state).on_event(:back) - end end end end diff --git a/spec/support/shared_examples/workflow_states/an_address_lookup_transition.rb b/spec/support/shared_examples/workflow_states/an_address_lookup_transition.rb index 5f8a2b672..8791d5bf8 100644 --- a/spec/support/shared_examples/workflow_states/an_address_lookup_transition.rb +++ b/spec/support/shared_examples/workflow_states/an_address_lookup_transition.rb @@ -2,7 +2,6 @@ RSpec.shared_examples "an address lookup transition" do |next_state_if_not_skipping_to_manual:, address_type:, factory:| describe "#workflow_state" do - previous_state = "#{address_type}_postcode_form".to_sym current_state = "#{address_type}_address_form".to_sym subject(:subject) do create(factory, workflow_state: current_state, @@ -26,10 +25,6 @@ .to(alt_state) .on_event(:skip_to_manual_address) end - - it "changes to #{previous_state} after the 'back' event" do - expect(subject).to transition_from(current_state).to(previous_state).on_event(:back) - end end context "when subject.skip_to_manual_address? is true" do @@ -47,10 +42,6 @@ .to(next_state) .on_event(:skip_to_manual_address) end - - it "changes to #{previous_state} after the 'back' event" do - expect(subject).to transition_from(current_state).to(previous_state).on_event(:back) - end end end end diff --git a/spec/support/shared_examples/workflow_states/has_back_transition.rb b/spec/support/shared_examples/workflow_states/has_back_transition.rb deleted file mode 100644 index 1f072e246..000000000 --- a/spec/support/shared_examples/workflow_states/has_back_transition.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -RSpec.shared_examples "has back transition" do |previous_state:| - it "can transition to #{previous_state}" do - current_state = subject.workflow_state - - expect(subject).to transition_from(current_state).to(previous_state).on_event(:back) - end -end