diff --git a/app/controllers/waste_carriers_engine/address_forms_controller.rb b/app/controllers/waste_carriers_engine/address_forms_controller.rb index 7f6abb0d9..5f59203b8 100644 --- a/app/controllers/waste_carriers_engine/address_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/address_forms_controller.rb @@ -3,7 +3,7 @@ module WasteCarriersEngine class AddressFormsController < FormsController def skip_to_manual_address - find_or_initialize_transient_registration(params[:reg_identifier]) + find_or_initialize_transient_registration(params[:token]) @transient_registration.skip_to_manual_address! if form_matches_state? redirect_to_correct_form diff --git a/app/controllers/waste_carriers_engine/bank_transfer_forms_controller.rb b/app/controllers/waste_carriers_engine/bank_transfer_forms_controller.rb index 1843edc85..04d0dad43 100644 --- a/app/controllers/waste_carriers_engine/bank_transfer_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/bank_transfer_forms_controller.rb @@ -17,11 +17,5 @@ def create def set_up_finance_details @transient_registration.prepare_for_payment(:bank_transfer, current_user) end - - def transient_registration_attributes - # TODO: Remvoe when default empty params - # Nothing to submit - params.fetch(:bank_transfer_form).permit - end end end diff --git a/app/controllers/waste_carriers_engine/business_type_forms_controller.rb b/app/controllers/waste_carriers_engine/business_type_forms_controller.rb index b3a419d37..970d35aef 100644 --- a/app/controllers/waste_carriers_engine/business_type_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/business_type_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.fetch(:business_type_form, {}).permit(:business_type, :reg_identifier) + params.fetch(:business_type_form, {}).permit(:business_type, :token) end end end diff --git a/app/controllers/waste_carriers_engine/copy_cards_forms_controller.rb b/app/controllers/waste_carriers_engine/copy_cards_forms_controller.rb index 3bfd48886..468051ec0 100644 --- a/app/controllers/waste_carriers_engine/copy_cards_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/copy_cards_forms_controller.rb @@ -16,9 +16,9 @@ def transient_registration_attributes params.fetch(:copy_cards_form).permit(:temp_cards) end - def find_or_initialize_transient_registration(reg_identifier) - @transient_registration = OrderCopyCardsRegistration.where(reg_identifier: reg_identifier).first || - OrderCopyCardsRegistration.new(reg_identifier: reg_identifier) + def find_or_initialize_transient_registration(token) + @transient_registration = OrderCopyCardsRegistration.where(token: token).first || + OrderCopyCardsRegistration.new(reg_identifier: token) end end end diff --git a/app/controllers/waste_carriers_engine/forms_controller.rb b/app/controllers/waste_carriers_engine/forms_controller.rb index 76c5b1202..ecefae6c3 100644 --- a/app/controllers/waste_carriers_engine/forms_controller.rb +++ b/app/controllers/waste_carriers_engine/forms_controller.rb @@ -6,21 +6,22 @@ class FormsController < ApplicationController before_action :authenticate_user! before_action :back_button_cache_buster + before_action :validate_token # Expects a form class name (eg BusinessTypeForm) and a snake_case name for the form (eg business_type_form) def new(form_class, form) - set_up_form(form_class, form, params[:reg_identifier], true) + set_up_form(form_class, form, params[:token], true) end # Expects a form class name (eg BusinessTypeForm) and a snake_case name for the form (eg business_type_form) def create(form_class, form) - return false unless set_up_form(form_class, form, params[form][:reg_identifier]) + return false unless set_up_form(form_class, form, params[:token]) submit_form(instance_variable_get("@#{form}"), transient_registration_attributes) end def go_back - find_or_initialize_transient_registration(params[:reg_identifier]) + find_or_initialize_transient_registration(params[:token]) @transient_registration.back! if form_matches_state? redirect_to_correct_form @@ -34,15 +35,23 @@ def transient_registration_attributes params.permit end - def find_or_initialize_transient_registration(reg_identifier) - @transient_registration = TransientRegistration.where(reg_identifier: reg_identifier).first || - RenewingRegistration.new(reg_identifier: reg_identifier) + def validate_token + return redirect_to(page_path("invalid")) unless find_or_initialize_transient_registration(params[:token]) end + # We're not really memoizing this instance variable here, so we don't think + # this cop is valid in this context + # rubocop:disable Naming/MemoizedInstanceVariableName + def find_or_initialize_transient_registration(token) + @transient_registration ||= TransientRegistration.where(token: token).first + end + # rubocop:enable Naming/MemoizedInstanceVariableName + # Expects a form class name (eg BusinessTypeForm), a snake_case name for the form (eg business_type_form), - # and the reg_identifier param - def set_up_form(form_class, form, reg_identifier, get_request = false) - find_or_initialize_transient_registration(reg_identifier) + # and the token param + def set_up_form(form_class, form, token, get_request = false) + find_or_initialize_transient_registration(token) + set_workflow_state if get_request return false unless setup_checks_pass? @@ -68,10 +77,10 @@ def redirect_to_correct_form redirect_to form_path end - # Get the path based on the workflow state, with reg_identifier as params, ie: - # new_state_name_path/:reg_identifier + # Get the path based on the workflow state, with token as params, ie: + # new_state_name_path/:token def form_path - send("new_#{@transient_registration.workflow_state}_path".to_sym, @transient_registration.reg_identifier) + send("new_#{@transient_registration.workflow_state}_path".to_sym, @transient_registration.token) end def setup_checks_pass? diff --git a/app/controllers/waste_carriers_engine/person_forms_controller.rb b/app/controllers/waste_carriers_engine/person_forms_controller.rb index 45b8e94fd..c3613333d 100644 --- a/app/controllers/waste_carriers_engine/person_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/person_forms_controller.rb @@ -11,7 +11,7 @@ def create(form_class, form) end def submit_and_add_another(form_class, form) - return unless set_up_form(form_class, form, params[form][:reg_identifier]) + return unless set_up_form(form_class, form, params[:token]) form_instance_variable = instance_variable_get("@#{form}") @@ -25,7 +25,7 @@ def submit_and_add_another(form_class, form) end def delete_person(form_class, form) - return unless set_up_form(form_class, form, params[:reg_identifier]) + return unless set_up_form(form_class, form, params[:token]) respond_to do |format| # Check if there are any matches first, to avoid a Mongoid error diff --git a/app/controllers/waste_carriers_engine/postcode_forms_controller.rb b/app/controllers/waste_carriers_engine/postcode_forms_controller.rb index 692104b80..eb9ceac3d 100644 --- a/app/controllers/waste_carriers_engine/postcode_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/postcode_forms_controller.rb @@ -3,7 +3,7 @@ module WasteCarriersEngine class PostcodeFormsController < FormsController def skip_to_manual_address - find_or_initialize_transient_registration(params[:reg_identifier]) + find_or_initialize_transient_registration(params[:token]) @transient_registration.skip_to_manual_address! if form_matches_state? redirect_to_correct_form diff --git a/app/controllers/waste_carriers_engine/renewal_start_forms_controller.rb b/app/controllers/waste_carriers_engine/renewal_start_forms_controller.rb index ee4cfbcb3..afb51f7eb 100644 --- a/app/controllers/waste_carriers_engine/renewal_start_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/renewal_start_forms_controller.rb @@ -9,5 +9,12 @@ def new def create super(RenewalStartForm, "renewal_start_form") end + + private + + def find_or_initialize_transient_registration(token) + @transient_registration = RenewingRegistration.where(token: token).first || + RenewingRegistration.new(reg_identifier: token) + end end end diff --git a/app/controllers/waste_carriers_engine/tier_check_forms_controller.rb b/app/controllers/waste_carriers_engine/tier_check_forms_controller.rb index 05661cd36..000e0ae62 100644 --- a/app/controllers/waste_carriers_engine/tier_check_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/tier_check_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:tier_check_form).permit(:temp_tier_check) + params.fetch(:tier_check_form, {}).permit(:temp_tier_check) end end end diff --git a/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb b/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb index abd06fea7..eebd7e392 100644 --- a/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/worldpay_forms_controller.rb @@ -46,7 +46,7 @@ def prepare_for_payment end def respond_to_acceptable_payment(action) - return unless valid_transient_registration?(params[:reg_identifier]) + return unless valid_transient_registration?(params[:token]) if response_is_valid?(action, params) log_and_send_worldpay_response(true, action) @@ -60,7 +60,7 @@ def respond_to_acceptable_payment(action) end def respond_to_unsuccessful_payment(action) - return unless valid_transient_registration?(params[:reg_identifier]) + return unless valid_transient_registration?(params[:token]) if response_is_valid?(action, params) log_and_send_worldpay_response(true, action) @@ -73,8 +73,8 @@ def respond_to_unsuccessful_payment(action) go_back end - def valid_transient_registration?(reg_identifier) - find_or_initialize_transient_registration(reg_identifier) + def valid_transient_registration?(token) + find_or_initialize_transient_registration(token) setup_checks_pass? end diff --git a/app/forms/waste_carriers_engine/base_form.rb b/app/forms/waste_carriers_engine/base_form.rb index 6f6fd1f07..13da520b1 100644 --- a/app/forms/waste_carriers_engine/base_form.rb +++ b/app/forms/waste_carriers_engine/base_form.rb @@ -9,9 +9,17 @@ class BaseForm attr_reader :transient_registration - delegate :reg_identifier, to: :transient_registration + delegate :token, :reg_identifier, to: :transient_registration + + # If the record is new, and not yet persisted (which it is when the start + # page is first submitted) then we have nothing to validate hence the check + validates :token, presence: true, if: -> { transient_registration&.persisted? } + validates( + :reg_identifier, + "waste_carriers_engine/reg_identifier": true, + if: -> { transient_registration&.persisted? } + ) - validates :reg_identifier, "waste_carriers_engine/reg_identifier": true validate :transient_registration_valid? define_model_callbacks :initialize diff --git a/app/forms/waste_carriers_engine/renewal_complete_form.rb b/app/forms/waste_carriers_engine/renewal_complete_form.rb index fa0e21aa6..79765f457 100644 --- a/app/forms/waste_carriers_engine/renewal_complete_form.rb +++ b/app/forms/waste_carriers_engine/renewal_complete_form.rb @@ -22,7 +22,7 @@ def initialize(transient_registration) private def build_certificate_link - registration = Registration.where(reg_identifier: reg_identifier).first + registration = @transient_registration.registration return unless registration.present? id = registration.id diff --git a/app/forms/waste_carriers_engine/renewal_start_form.rb b/app/forms/waste_carriers_engine/renewal_start_form.rb index 8b6c849db..478208f81 100644 --- a/app/forms/waste_carriers_engine/renewal_start_form.rb +++ b/app/forms/waste_carriers_engine/renewal_start_form.rb @@ -11,5 +11,11 @@ def submit(_params) super(attributes) end + + def find_or_initialize_transient_registration(token) + # TODO: Downtime at deploy when releasing token? + @transient_registration = RenewingRegistration.where(token: token).first || + RenewingRegistration.new(reg_identifier: token) + end end end diff --git a/app/models/concerns/waste_carriers_engine/can_have_secure_token.rb b/app/models/concerns/waste_carriers_engine/can_have_secure_token.rb new file mode 100644 index 000000000..f3437a4c6 --- /dev/null +++ b/app/models/concerns/waste_carriers_engine/can_have_secure_token.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module WasteCarriersEngine + module CanHaveSecureToken + extend ActiveSupport::Concern + include Mongoid::Document + + included do + field :token, type: String + + before_create :generate_unique_secure_token + + def generate_unique_secure_token + self.token = SecureTokenService.run + end + end + end +end diff --git a/app/models/waste_carriers_engine/transient_registration.rb b/app/models/waste_carriers_engine/transient_registration.rb index 4dd222d7a..f06be4a54 100644 --- a/app/models/waste_carriers_engine/transient_registration.rb +++ b/app/models/waste_carriers_engine/transient_registration.rb @@ -7,6 +7,7 @@ class TransientRegistration include CanCheckRegistrationStatus include CanFilterConvictionStatus include CanHaveRegistrationAttributes + include CanHaveSecureToken include CanStripWhitespace store_in collection: "transient_registrations" diff --git a/app/services/waste_carriers_engine/renewal_completion_service.rb b/app/services/waste_carriers_engine/renewal_completion_service.rb index a4b1a45f3..3c9a01188 100644 --- a/app/services/waste_carriers_engine/renewal_completion_service.rb +++ b/app/services/waste_carriers_engine/renewal_completion_service.rb @@ -78,6 +78,7 @@ def send_confirmation_email def copy_data_from_transient_registration registration_attributes = @registration.attributes.except("_id", "financeDetails", "past_registrations") renewal_attributes = @transient_registration.attributes.except("_id", + "token", "financeDetails", "temp_cards", "temp_company_postcode", diff --git a/app/services/waste_carriers_engine/worldpay_service.rb b/app/services/waste_carriers_engine/worldpay_service.rb index 4b295ab31..1c1d377a1 100644 --- a/app/services/waste_carriers_engine/worldpay_service.rb +++ b/app/services/waste_carriers_engine/worldpay_service.rb @@ -19,7 +19,7 @@ def prepare_for_payment reference = parse_response(response) if reference.present? - worldpay_url_service = WorldpayUrlService.new(@transient_registration.reg_identifier, reference[:link]) + worldpay_url_service = WorldpayUrlService.new(@transient_registration.token, reference[:link]) url = worldpay_url_service.format_link { diff --git a/app/services/waste_carriers_engine/worldpay_url_service.rb b/app/services/waste_carriers_engine/worldpay_url_service.rb index 962697379..f132ed16d 100644 --- a/app/services/waste_carriers_engine/worldpay_url_service.rb +++ b/app/services/waste_carriers_engine/worldpay_url_service.rb @@ -4,8 +4,8 @@ module WasteCarriersEngine # Builds the URL we use to redirect users to Worldpay. # This should include URLs for our own service, which Worldpay will redirect users to after payment. class WorldpayUrlService - def initialize(reg_identifier, base_url) - @reg_identifier = reg_identifier + def initialize(token, base_url) + @token = token @base_url = base_url end @@ -29,7 +29,7 @@ def redirect_url_for(action) def build_path_for(action) path = "#{action}_worldpay_forms_path" url = [Rails.configuration.host, - WasteCarriersEngine::Engine.routes.url_helpers.public_send(path, @reg_identifier)] + WasteCarriersEngine::Engine.routes.url_helpers.public_send(path, token: @token)] CGI.escape(url.join) end end diff --git a/app/views/waste_carriers_engine/bank_transfer_forms/new.html.erb b/app/views/waste_carriers_engine/bank_transfer_forms/new.html.erb index 26008d010..5a805e243 100644 --- a/app/views/waste_carriers_engine/bank_transfer_forms/new.html.erb +++ b/app/views/waste_carriers_engine/bank_transfer_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_bank_transfer_forms_path(@bank_transfer_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_bank_transfer_forms_path(@bank_transfer_form.token)) %>
<%= form_for(@bank_transfer_form) do |f| %> @@ -105,7 +105,6 @@
- <%= f.hidden_field :reg_identifier, value: @bank_transfer_form.reg_identifier %>
<%= f.submit t(".next_button"), class: "button" %>
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 4cfbd27fb..e928abc2a 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_business_type_forms_path(@business_type_form.token)) %>
<%= form_for(@business_type_form) do |f| %> @@ -45,7 +45,6 @@

<%= t(".help") %>

- <%= f.hidden_field :reg_identifier, value: @business_type_form.reg_identifier %>
<%= f.submit t(".next_button"), class: "button" %>
diff --git a/app/views/waste_carriers_engine/cannot_renew_company_no_change_forms/new.html.erb b/app/views/waste_carriers_engine/cannot_renew_company_no_change_forms/new.html.erb index 808df3fb4..e432b56c8 100644 --- a/app/views/waste_carriers_engine/cannot_renew_company_no_change_forms/new.html.erb +++ b/app/views/waste_carriers_engine/cannot_renew_company_no_change_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_cannot_renew_company_no_change_forms_path(@cannot_renew_company_no_change_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_cannot_renew_company_no_change_forms_path(@cannot_renew_company_no_change_form.token)) %>

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

diff --git a/app/views/waste_carriers_engine/cannot_renew_lower_tier_forms/new.html.erb b/app/views/waste_carriers_engine/cannot_renew_lower_tier_forms/new.html.erb index 7232c36dd..7f401ad4c 100644 --- a/app/views/waste_carriers_engine/cannot_renew_lower_tier_forms/new.html.erb +++ b/app/views/waste_carriers_engine/cannot_renew_lower_tier_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_cannot_renew_lower_tier_forms_path(@cannot_renew_lower_tier_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_cannot_renew_lower_tier_forms_path(@cannot_renew_lower_tier_form.token)) %>

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

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 cd0860ac2..f5746097f 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_cannot_renew_type_change_forms_path(@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 b83241bd2..00991dcfc 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_cards_forms_path(@cards_form.token)) %>
<%= form_for(@cards_form) do |f| %> @@ -30,8 +30,6 @@
- <%= f.hidden_field :reg_identifier, value: @cards_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 5ff80f8fd..d42f6d4e0 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_cbd_type_forms_path(@cbd_type_form.token)) %>
<%= form_for(@cbd_type_form) do |f| %> @@ -49,7 +49,6 @@
- <%= f.hidden_field :reg_identifier, value: @cbd_type_form.reg_identifier %>
<%= f.submit t(".next_button"), class: "button" %>
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 24b7cf899..350ba5a33 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_check_your_answers_forms_path(@check_your_answers_form.token)) %>
<% if @check_your_answers_form.errors.any? %> @@ -114,7 +114,6 @@
- <%= f.hidden_field :reg_identifier, value: @check_your_answers_form.reg_identifier %>
<%= f.submit t(".next_button"), class: "button" %>
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 7d38d7458..18687a656 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,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_company_address_forms_path(@company_address_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_company_address_forms_path(@company_address_form.token)) %>
<%= form_for(@company_address_form) do |f| %> @@ -20,7 +20,6 @@ <%= link_to(t(".manual_address_link"), skip_to_manual_address_company_address_forms_path(@company_address_form.reg_identifier)) %>
- <%= f.hidden_field :reg_identifier, value: @company_address_form.reg_identifier %>
<%= f.submit t(".next_button"), class: "button" %>
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 f18be4d59..54e85bb68 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,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_company_address_manual_forms_path(@company_address_manual_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_company_address_manual_forms_path(@company_address_manual_form.token)) %>
<%= form_for(@company_address_manual_form) do |f| %> @@ -25,8 +25,6 @@ <%= render("waste_carriers_engine/shared/manual_address", form: @company_address_manual_form, f: f, overseas: @company_address_manual_form.business_is_overseas?) %> <% end %> - <%= f.hidden_field :reg_identifier, value: @company_address_manual_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 c41128463..e8d39b81e 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,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_company_name_forms_path(@company_name_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_company_name_forms_path(@company_name_form.token)) %>
<%= form_for(@company_name_form) do |f| %> @@ -21,8 +21,6 @@
- <%= f.hidden_field :reg_identifier, value: @company_name_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 77bb0fbc2..29c7c6be1 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,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_company_postcode_forms_path(@company_postcode_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_company_postcode_forms_path(@company_postcode_form.token)) %>
<%= form_for(@company_postcode_form) do |f| %> @@ -25,8 +25,6 @@
- <%= f.hidden_field :reg_identifier, value: @company_postcode_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 b3908f26c..e7165366c 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_construction_demolition_forms_path(@construction_demolition_form.token)) %>
<%= form_for(@construction_demolition_form) do |f| %> @@ -40,8 +40,6 @@
- <%= f.hidden_field :reg_identifier, value: @construction_demolition_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 ff80b10e3..e269fed3b 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_contact_address_forms_path(@contact_address_form.token)) %>
<%= form_for(@contact_address_form) do |f| %> @@ -20,8 +20,6 @@ <%= link_to(t(".manual_address_link"), skip_to_manual_address_contact_address_forms_path(@contact_address_form.reg_identifier)) %>
- <%= f.hidden_field :reg_identifier, value: @contact_address_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 722aa7431..8a1c2d33a 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_contact_address_manual_forms_path(@contact_address_manual_form.token)) %>
<%= form_for(@contact_address_manual_form) do |f| %> @@ -25,8 +25,6 @@ <%= render("waste_carriers_engine/shared/manual_address", form: @contact_address_manual_form, f: f, overseas: @contact_address_manual_form.business_is_overseas?) %> <% end %> - <%= f.hidden_field :reg_identifier, value: @contact_address_manual_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 358cccd16..b9e7e3c59 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_contact_email_forms_path(@contact_email_form.token)) %>
<%= form_for(@contact_email_form) do |f| %> @@ -32,8 +32,6 @@
- <%= f.hidden_field :reg_identifier, value: @contact_email_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 e63150050..5770ca69e 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_contact_name_forms_path(@contact_name_form.token)) %>
<%= form_for(@contact_name_form) do |f| %> @@ -30,8 +30,6 @@
- <%= f.hidden_field :reg_identifier, value: @contact_name_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 714873486..074e53df6 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_contact_phone_forms_path(@contact_phone_form.token)) %>
<%= form_for(@contact_phone_form) do |f| %> @@ -21,8 +21,6 @@
- <%= f.hidden_field :reg_identifier, value: @contact_phone_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
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 023394bd1..6445cf089 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_contact_postcode_forms_path(@contact_postcode_form.token)) %>
<%= form_for(@contact_postcode_form) do |f| %> @@ -27,8 +27,6 @@
- <%= f.hidden_field :reg_identifier, value: @contact_postcode_form.reg_identifier %> -
<%= f.submit t(".next_button"), class: "button" %>
diff --git a/app/views/waste_carriers_engine/conviction_details_forms/_form.html.erb b/app/views/waste_carriers_engine/conviction_details_forms/_form.html.erb index 7dfb189c3..b8bedac90 100644 --- a/app/views/waste_carriers_engine/conviction_details_forms/_form.html.erb +++ b/app/views/waste_carriers_engine/conviction_details_forms/_form.html.erb @@ -19,7 +19,7 @@ <%= render("waste_carriers_engine/shared/dob", form: @conviction_details_form, f: f) %> - <%= f.hidden_field :reg_identifier, value: @conviction_details_form.reg_identifier %> + <%= f.hidden_field :token, value: @conviction_details_form.token %>
<%= f.submit t(".add_person_link"), class: "button-link" %> 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 334b61809..7ed5aee9c 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_conviction_details_forms_path(@conviction_details_form.token)) %>
@@ -13,10 +13,9 @@
  • <%= person.first_name %> <%= person.last_name %> <%= button_to(t(".delete_person_link"), - delete_person_conviction_details_forms_path(person.id), + delete_person_conviction_details_forms_path(token: @conviction_details_form.token, id: person.id), class: "button-link", - method: :delete, - params: { reg_identifier: @conviction_details_form.reg_identifier }) %> + method: :delete) %>
  • <% end %> 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 1733115d1..be9c103ca 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_declaration_forms_path(@declaration_form.token)) %>
    <%= form_for(@declaration_form) do |f| %> @@ -25,8 +25,6 @@

    <%= link_to t(".privacy_link_text"), page_path("privacy"), target: "_blank" %>

    - <%= f.hidden_field :reg_identifier, value: @declaration_form.reg_identifier %> -
    <%= f.submit t(".next_button"), class: "button" %>
    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 bfce2fa20..15849c80f 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_declare_convictions_forms_path(@declare_convictions_form.token)) %>
    <%= form_for(@declare_convictions_form) do |f| %> @@ -48,8 +48,6 @@
    - <%= f.hidden_field :reg_identifier, value: @declare_convictions_form.reg_identifier %> -
    <%= f.submit t(".next_button"), class: "button" %>
    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 b45a1ea29..28f958f6c 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_location_forms_path(@location_form.token)) %>
    <%= form_for(@location_form) do |f| %> @@ -50,8 +50,6 @@
    - <%= f.hidden_field :reg_identifier, value: @location_form.reg_identifier %> -
    <%= f.submit t(".next_button"), class: "button" %>
    diff --git a/app/views/waste_carriers_engine/main_people_forms/_form.html.erb b/app/views/waste_carriers_engine/main_people_forms/_form.html.erb index aa6fd790a..1fa1b255e 100644 --- a/app/views/waste_carriers_engine/main_people_forms/_form.html.erb +++ b/app/views/waste_carriers_engine/main_people_forms/_form.html.erb @@ -9,8 +9,6 @@ <%= render("waste_carriers_engine/shared/dob", form: @main_people_form, f: f) %> - <%= f.hidden_field :reg_identifier, value: @main_people_form.reg_identifier %> - <% if @main_people_form.can_only_have_one_main_person? %>
    <%= f.submit t(".next_button"), class: "button" %> 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 1da9014b7..aa9bb3b9d 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_main_people_forms_path(@main_people_form.token)) %> <% if @main_people_form.can_only_have_one_main_person? %>
    @@ -19,10 +19,9 @@
  • <%= person.first_name %> <%= person.last_name %> <%= button_to(t(".delete_person_link"), - delete_person_main_people_forms_path(person.id), + delete_person_main_people_forms_path(token: @main_people_form.token, id: person.id), class: "button-link", - method: :delete, - params: { reg_identifier: @main_people_form.reg_identifier }) %> + method: :delete) %>
  • <% end %> 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 7c44535fb..1a8ff9a15 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_other_businesses_forms_path(@other_businesses_form.token)) %>
    <%= form_for(@other_businesses_form) do |f| %> @@ -28,8 +28,6 @@
    - <%= f.hidden_field :reg_identifier, value: @other_businesses_form.reg_identifier %> -
    <%= f.submit t(".next_button"), class: "button" %>
    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 3a55ab2ad..a86dbd50e 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 @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_payment_summary_forms_path(@payment_summary_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_payment_summary_forms_path(@payment_summary_form.token)) %>
    <%= form_for(@payment_summary_form) do |f| %> @@ -75,8 +75,6 @@
    - <%= f.hidden_field :reg_identifier, value: @payment_summary_form.reg_identifier %> -
    <%= f.submit t(".next_button"), class: "button" %>
    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 7fb52d709..4fe68abbd 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_register_in_northern_ireland_forms_path(@register_in_northern_ireland_form.token)) %>
    <%= form_for(@register_in_northern_ireland_form) do |f| %> @@ -12,8 +12,6 @@

    <%= t(".paragraph_3") %>

    - <%= f.hidden_field :reg_identifier, value: @register_in_northern_ireland_form.reg_identifier %> -
    <%= f.submit t(".next_button"), class: "button" %>
    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 27ce49cb9..a3f4f2017 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_register_in_scotland_forms_path(@register_in_scotland_form.token)) %>
    <%= form_for(@register_in_scotland_form) do |f| %> @@ -12,7 +12,6 @@

    <%= t(".paragraph_3") %>

    - <%= f.hidden_field :reg_identifier, value: @register_in_scotland_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    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 26ecdb9b3..0388346ef 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_register_in_wales_forms_path(@register_in_wales_form.token)) %>
    <%= form_for(@register_in_wales_form) do |f| %> @@ -12,7 +12,6 @@

    <%= t(".paragraph_3") %>

    - <%= f.hidden_field :reg_identifier, value: @register_in_wales_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    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 54719c5d2..7645aa157 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,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_registration_number_forms_path(@registration_number_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_registration_number_forms_path(@registration_number_form.token)) %>
    <%= form_for(@registration_number_form) do |f| %> @@ -39,7 +39,6 @@

    <%= t(".explanation.#{@registration_number_form.business_type}") %>

    - <%= f.hidden_field :reg_identifier, value: @registration_number_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    diff --git a/app/views/waste_carriers_engine/renewal_complete_forms/new.html.erb b/app/views/waste_carriers_engine/renewal_complete_forms/new.html.erb index 1eaebb994..8a767a445 100644 --- a/app/views/waste_carriers_engine/renewal_complete_forms/new.html.erb +++ b/app/views/waste_carriers_engine/renewal_complete_forms/new.html.erb @@ -49,7 +49,6 @@

    <%= link_to(t(".survey_link_text"), t("layouts.application.feedback_url")) %> <%= t(".survey_link_hint") %>

    - <%= f.hidden_field :reg_identifier, value: @renewal_complete_form.reg_identifier %> <%= link_to t(".next_button"), dashboard_link(current_user), class: 'button' %> <% end %> <% end %> 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 e83783b85..ca2fa56d8 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_renewal_information_forms_path(@renewal_information_form.token)) %>
    <% if @renewal_information_form.errors.any? %> @@ -28,7 +28,6 @@

    <%= t(".paragraph_5", reg_identifier: @renewal_information_form.reg_identifier, total_charge: display_pence_as_pounds(@renewal_information_form.total_fee)) %>

    - <%= f.hidden_field :reg_identifier, value: @renewal_information_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    diff --git a/app/views/waste_carriers_engine/renewal_received_forms/new.html.erb b/app/views/waste_carriers_engine/renewal_received_forms/new.html.erb index f60418ec8..48d0479ec 100644 --- a/app/views/waste_carriers_engine/renewal_received_forms/new.html.erb +++ b/app/views/waste_carriers_engine/renewal_received_forms/new.html.erb @@ -40,7 +40,6 @@

    <%= link_to(t(".survey_link_text"), t("layouts.application.feedback_url")) %> <%= t(".survey_link_hint") %>

    - <%= f.hidden_field :reg_identifier, value: @renewal_received_form.reg_identifier %> <%= link_to t(".next_button"), dashboard_link(current_user), class: 'button' %> <% end %> diff --git a/app/views/waste_carriers_engine/renewal_start_forms/new.html.erb b/app/views/waste_carriers_engine/renewal_start_forms/new.html.erb index 8a441b2a2..8a39ca34c 100644 --- a/app/views/waste_carriers_engine/renewal_start_forms/new.html.erb +++ b/app/views/waste_carriers_engine/renewal_start_forms/new.html.erb @@ -24,7 +24,6 @@ <% end %> - <%= f.hidden_field :reg_identifier, value: @renewal_start_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    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 ff49b7110..d028a9154 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_service_provided_forms_path(@service_provided_form.token)) %>
    <%= form_for(@service_provided_form) do |f| %> @@ -27,8 +27,6 @@
    - <%= f.hidden_field :reg_identifier, value: @service_provided_form.reg_identifier %> -
    <%= f.submit t(".next_button"), class: "button" %>
    diff --git a/app/views/waste_carriers_engine/tier_check_forms/new.html.erb b/app/views/waste_carriers_engine/tier_check_forms/new.html.erb index 7a1979897..b3d9a49af 100644 --- a/app/views/waste_carriers_engine/tier_check_forms/new.html.erb +++ b/app/views/waste_carriers_engine/tier_check_forms/new.html.erb @@ -1,4 +1,4 @@ -<%= render("waste_carriers_engine/shared/back", back_path: back_tier_check_forms_path(@tier_check_form.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_tier_check_forms_path(@tier_check_form.token)) %>
    <%= form_for(@tier_check_form) do |f| %> @@ -31,7 +31,6 @@

    <%= t(".paragraph_2") %>

    - <%= f.hidden_field :reg_identifier, value: @tier_check_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    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 6b80260ec..2a03abddb 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_waste_types_forms_path(@waste_types_form.token)) %>
    <%= form_for(@waste_types_form) do |f| %> @@ -33,7 +33,6 @@
    - <%= f.hidden_field :reg_identifier, value: @waste_types_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    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 b69f7515d..bc4e104a5 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.reg_identifier)) %> +<%= render("waste_carriers_engine/shared/back", back_path: back_worldpay_forms_path(@worldpay_form.token)) %>
    <% if @worldpay_form.errors.any? %> @@ -18,7 +18,6 @@

    <%= t(".paragraph_3") %>

    <%= t(".paragraph_4") %>

    - <%= f.hidden_field :reg_identifier, value: @worldpay_form.reg_identifier %>
    <%= f.submit t(".next_button"), class: "button" %>
    diff --git a/config/routes.rb b/config/routes.rb index af2ea6f75..0c1fc5653 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,447 +4,449 @@ WasteCarriersEngine::Engine.routes.draw do resources :registrations, only: [:index] unless Rails.env.production? - resources :renewal_start_forms, - only: %i[new create], - path: "renew", - path_names: { new: "/:reg_identifier" } - - # Order copy cards flow - resources :copy_cards_forms, - only: %i[new create], - path: "order-copy-cards", - path_names: { new: "/:reg_identifier" } - - resources :copy_cards_payment_forms, - only: %i[new create], - path: "order-copy-cards-payment", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "copy_cards_payment_forms#go_back", - as: "back", - on: :collection - end - - resources :copy_cards_bank_transfer_forms, - only: %i[new create], - path: "order-copy-cards-bank-transfer", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "copy_cards_bank_transfer_forms#go_back", - as: "back", - on: :collection - end - # End of order copy cards flow - - resources :location_forms, - only: %i[new create], - path: "location", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "location_forms#go_back", - as: "back", - on: :collection - end - - resources :register_in_northern_ireland_forms, - only: %i[new create], - path: "register-in-northern-ireland", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "register_in_northern_ireland_forms#go_back", - as: "back", - on: :collection - end - - resources :register_in_scotland_forms, - only: %i[new create], - path: "register-in-scotland", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "register_in_scotland_forms#go_back", - as: "back", - on: :collection - end - - resources :register_in_wales_forms, - only: %i[new create], - path: "register-in-wales", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "register_in_wales_forms#go_back", - as: "back", - on: :collection - end - - resources :business_type_forms, - only: %i[new create], - path: "business-type", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "business_type_forms#go_back", - as: "back", - on: :collection - end - - resources :tier_check_forms, - only: %i[new create], - path: "tier-check", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "tier_check_forms#go_back", - as: "back", - on: :collection - end - - resources :other_businesses_forms, - only: %i[new create], - path: "other-businesses", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "other_businesses_forms#go_back", - as: "back", - on: :collection - end - - resources :service_provided_forms, - only: %i[new create], - path: "service-provided", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "service_provided_forms#go_back", - as: "back", - on: :collection - end - - resources :construction_demolition_forms, - only: %i[new create], - path: "construction-demolition", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "construction_demolition_forms#go_back", - as: "back", - on: :collection - end - - resources :waste_types_forms, - only: %i[new create], - path: "waste-types", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "waste_types_forms#go_back", - as: "back", - on: :collection - end - - resources :cbd_type_forms, - only: %i[new create], - path: "cbd-type", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "cbd_type_forms#go_back", - as: "back", - on: :collection - end - - resources :renewal_information_forms, - only: %i[new create], - path: "renewal-information", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "renewal_information_forms#go_back", - as: "back", - on: :collection - end - - resources :registration_number_forms, - only: %i[new create], - path: "registration-number", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "registration_number_forms#go_back", - as: "back", - on: :collection - end - - resources :company_name_forms, - only: %i[new create], - path: "company-name", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "company_name_forms#go_back", - as: "back", - on: :collection - end - - resources :company_postcode_forms, - only: %i[new create], - path: "company-postcode", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "company_postcode_forms#go_back", - as: "back", - on: :collection - - get "skip_to_manual_address/:reg_identifier", - to: "company_postcode_forms#skip_to_manual_address", - as: "skip_to_manual_address", - on: :collection - end - - resources :company_address_forms, - only: %i[new create], - path: "company-address", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "company_address_forms#go_back", - as: "back", - on: :collection - - get "skip_to_manual_address/:reg_identifier", - to: "company_address_forms#skip_to_manual_address", - as: "skip_to_manual_address", - on: :collection - end - - resources :company_address_manual_forms, - only: %i[new create], - path: "company-address-manual", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "company_address_manual_forms#go_back", - as: "back", - on: :collection - end - - resources :main_people_forms, - only: %i[new create], - path: "main-people", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "main_people_forms#go_back", - as: "back", - on: :collection - - delete "delete_person/:id", - to: "main_people_forms#delete_person", - as: "delete_person", - on: :collection - end - - resources :declare_convictions_forms, - only: %i[new create], - path: "declare-convictions", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "declare_convictions_forms#go_back", - as: "back", - on: :collection - end - - resources :conviction_details_forms, - only: %i[new create], - path: "conviction-details", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "conviction_details_forms#go_back", - as: "back", - on: :collection - - delete "delete_person/:id", - to: "conviction_details_forms#delete_person", - as: "delete_person", - on: :collection - end - - resources :contact_name_forms, - only: %i[new create], - path: "contact-name", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "contact_name_forms#go_back", - as: "back", - on: :collection - end - - resources :contact_phone_forms, - only: %i[new create], - path: "contact-phone", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "contact_phone_forms#go_back", - as: "back", - on: :collection - end - - resources :contact_email_forms, - only: %i[new create], - path: "contact-email", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "contact_email_forms#go_back", - as: "back", - on: :collection - end - - resources :contact_postcode_forms, - only: %i[new create], - path: "contact-postcode", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "contact_postcode_forms#go_back", - as: "back", - on: :collection - - get "skip_to_manual_address/:reg_identifier", - to: "contact_postcode_forms#skip_to_manual_address", - as: "skip_to_manual_address", - on: :collection - end - - resources :contact_address_forms, - only: %i[new create], - path: "contact-address", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "contact_address_forms#go_back", - as: "back", - on: :collection - - get "skip_to_manual_address/:reg_identifier", - to: "contact_address_forms#skip_to_manual_address", - as: "skip_to_manual_address", - on: :collection - end - - resources :contact_address_manual_forms, - only: %i[new create], - path: "contact-address-manual", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "contact_address_manual_forms#go_back", - as: "back", - on: :collection - end - - resources :check_your_answers_forms, - only: %i[new create], - path: "check-your-answers", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "check_your_answers_forms#go_back", - as: "back", - on: :collection - end - - resources :declaration_forms, - only: %i[new create], - path: "declaration", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "declaration_forms#go_back", - as: "back", - on: :collection - end - - resources :cards_forms, - only: %i[new create], - path: "cards", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "cards_forms#go_back", - as: "back", - on: :collection - end - - resources :payment_summary_forms, - only: %i[new create], - path: "payment-summary", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "payment_summary_forms#go_back", - as: "back", - on: :collection - end - - resources :worldpay_forms, - only: %i[new create], - path: "worldpay", - path_names: { new: "/:reg_identifier" } do - get "success/:reg_identifier", - to: "worldpay_forms#success", - as: "success", - on: :collection - - get "failure/:reg_identifier", - to: "worldpay_forms#failure", - as: "failure", - on: :collection - - get "cancel/:reg_identifier", - to: "worldpay_forms#cancel", - as: "cancel", - on: :collection - - get "error/:reg_identifier", - to: "worldpay_forms#error", - as: "error", - on: :collection - - get "pending/:reg_identifier", - to: "worldpay_forms#pending", - as: "pending", - on: :collection - end - - resources :bank_transfer_forms, - only: %i[new create], - path: "bank-transfer", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "bank_transfer_forms#go_back", - as: "back", - on: :collection - end - - resources :renewal_complete_forms, - only: %i[new create], - path: "renewal-complete", - path_names: { new: "/:reg_identifier" } - - resources :renewal_received_forms, - only: %i[new create], - path: "renewal-received", - path_names: { new: "/:reg_identifier" } - - resources :cannot_renew_lower_tier_forms, - only: %i[new create], - path: "cannot-renew-lower-tier", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "cannot_renew_lower_tier_forms#go_back", - as: "back", - on: :collection - end - - resources :cannot_renew_type_change_forms, - only: %i[new create], - path: "cannot-renew-type-change", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "cannot_renew_type_change_forms#go_back", - as: "back", - on: :collection - end - - resources :cannot_renew_company_no_change_forms, - only: %i[new create], - path: "cannot-renew-company-no-change", - path_names: { new: "/:reg_identifier" } do - get "back/:reg_identifier", - to: "cannot_renew_company_no_change_forms#go_back", - as: "back", - on: :collection - end + scope "/:token" do + # Order copy cards flow + resources :copy_cards_forms, + only: %i[new create], + path: "order-copy-cards", + path_names: { new: "" } + + resources :copy_cards_payment_forms, + only: %i[new create], + path: "order-copy-cards-payment", + path_names: { new: "" } do + get "back", + to: "copy_cards_payment_forms#go_back", + as: "back", + on: :collection + end + + 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 + # End of order copy cards flow + + resources :renewal_start_forms, + only: %i[new create], + path: "renew", + path_names: { new: "" } + + 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 + + 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 + + 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 + + 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 + + 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 + + resources :tier_check_forms, + only: %i[new create], + path: "tier-check", + path_names: { new: "" } do + get "back", + to: "tier_check_forms#go_back", + as: "back", + on: :collection + end + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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", + on: :collection + end + + resources :company_address_forms, + 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", + on: :collection + end + + 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 + + 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", + on: :collection + end + + 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 + + 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", + on: :collection + end + + 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 + + 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 + + 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 + + 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", + on: :collection + end + + resources :contact_address_forms, + 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", + on: :collection + end + + 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 + + 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 + + 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 + + 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 + + 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 + + resources :worldpay_forms, + only: %i[new create], + path: "worldpay", + path_names: { new: "" } do + get "success", + to: "worldpay_forms#success", + as: "success", + on: :collection + + get "failure", + to: "worldpay_forms#failure", + as: "failure", + on: :collection + + get "cancel", + to: "worldpay_forms#cancel", + as: "cancel", + on: :collection + + get "error", + to: "worldpay_forms#error", + as: "error", + on: :collection + + get "pending", + to: "worldpay_forms#pending", + as: "pending", + on: :collection + end + + resources :bank_transfer_forms, + only: %i[new create], + path: "bank-transfer", + path_names: { new: "" } do + get "back", + to: "bank_transfer_forms#go_back", + as: "back", + on: :collection + end + + resources :renewal_complete_forms, + only: %i[new create], + path: "renewal-complete", + path_names: { new: "" } + + resources :renewal_received_forms, + only: %i[new create], + path: "renewal-received", + path_names: { new: "" } + + resources :cannot_renew_lower_tier_forms, + only: %i[new create], + path: "cannot-renew-lower-tier", + path_names: { new: "" } do + get "back", + to: "cannot_renew_lower_tier_forms#go_back", + as: "back", + on: :collection + end + + 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 + + resources :cannot_renew_company_no_change_forms, + only: %i[new create], + path: "cannot-renew-company-no-change", + path_names: { new: "" } do + get "back", + to: "cannot_renew_company_no_change_forms#go_back", + as: "back", + on: :collection + end + end # See http://patrickperey.com/railscast-053-handling-exceptions/ get "(errors)/:status", diff --git a/spec/forms/waste_carriers_engine/bank_transfer_forms_spec.rb b/spec/forms/waste_carriers_engine/bank_transfer_forms_spec.rb index 13a3c5b5d..59ff8d659 100644 --- a/spec/forms/waste_carriers_engine/bank_transfer_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/bank_transfer_forms_spec.rb @@ -8,7 +8,7 @@ module WasteCarriersEngine let(:bank_transfer_form) { build(:bank_transfer_form, :has_required_data) } context "when the form is valid" do - let(:valid_params) { { reg_identifier: bank_transfer_form.reg_identifier } } + let(:valid_params) { { token: bank_transfer_form.token } } it "should submit" do expect(bank_transfer_form.submit(valid_params)).to eq(true) diff --git a/spec/forms/waste_carriers_engine/base_forms_spec.rb b/spec/forms/waste_carriers_engine/base_forms_spec.rb index 8cc9f4ccc..96cbc8a08 100644 --- a/spec/forms/waste_carriers_engine/base_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/base_forms_spec.rb @@ -29,28 +29,12 @@ module WasteCarriersEngine end end - describe "#reg_identifier" do + describe "#token" do let(:base_form) { build(:base_form, :has_required_data) } - context "when the reg_identifier meets the requirements" do - it "is valid" do - expect(base_form).to be_valid - end - end - - context "when a reg_identifier is blank" do - before do - base_form.transient_registration.reg_identifier = nil - end - - it "is not valid" do - expect(base_form).to_not be_valid - end - end - - context "when a reg_identifier is in the wrong format" do + context "when a token is blank" do before do - base_form.transient_registration.reg_identifier = "foo" + base_form.transient_registration.token = nil end it "is not valid" do @@ -69,7 +53,7 @@ module WasteCarriersEngine let(:form) { BusinessTypeForm.new(transient_registration) } before do - # Make reg_identifier valid for the form, but not the transient object + # Make reg_identifier invalid for the transient object transient_registration.reg_identifier = "foo" end diff --git a/spec/forms/waste_carriers_engine/business_type_forms_spec.rb b/spec/forms/waste_carriers_engine/business_type_forms_spec.rb index 6256710f3..f3c41010f 100644 --- a/spec/forms/waste_carriers_engine/business_type_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/business_type_forms_spec.rb @@ -7,7 +7,7 @@ module WasteCarriersEngine describe "#submit" do context "when the form is valid" do let(:business_type_form) { build(:business_type_form, :has_required_data) } - let(:valid_params) { { reg_identifier: business_type_form.reg_identifier, business_type: "limitedCompany" } } + let(:valid_params) { { token: business_type_form.token, business_type: "limitedCompany" } } it "should submit" do expect(business_type_form.submit(valid_params)).to eq(true) @@ -16,7 +16,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:business_type_form) { build(:business_type_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo", business_type: "foo" } } + let(:invalid_params) { { token: "foo", business_type: "foo" } } it "should not submit" do expect(business_type_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/cards_forms_spec.rb b/spec/forms/waste_carriers_engine/cards_forms_spec.rb index 4baf54424..ea9440d84 100644 --- a/spec/forms/waste_carriers_engine/cards_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/cards_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:cards_form) { build(:cards_form, :has_required_data) } let(:valid_params) do { - reg_identifier: cards_form.reg_identifier, + token: cards_form.token, temp_cards: cards_form.temp_cards } end @@ -34,10 +34,10 @@ module WasteCarriersEngine context "when temp_cards is blank" do let(:cards_form) { build(:cards_form, :has_required_data) } - let(:transient_registration) { RenewingRegistration.where(reg_identifier: cards_form.reg_identifier).first } + let(:transient_registration) { RenewingRegistration.where(token: cards_form.token).first } let(:blank_params) do { - reg_identifier: cards_form.reg_identifier, + token: cards_form.token, temp_cards: "" } end @@ -50,10 +50,10 @@ module WasteCarriersEngine context "when temp_cards is more than 999" do let(:cards_form) { build(:cards_form, :has_required_data) } - let(:transient_registration) { RenewingRegistration.where(reg_identifier: cards_form.reg_identifier).first } + let(:transient_registration) { RenewingRegistration.where(token: cards_form.token).first } let(:outside_range_params) do { - reg_identifier: cards_form.reg_identifier, + token: cards_form.token, temp_cards: "1000" } end diff --git a/spec/forms/waste_carriers_engine/cbd_type_forms_spec.rb b/spec/forms/waste_carriers_engine/cbd_type_forms_spec.rb index ba268a402..f23841593 100644 --- a/spec/forms/waste_carriers_engine/cbd_type_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/cbd_type_forms_spec.rb @@ -7,7 +7,7 @@ module WasteCarriersEngine describe "#submit" do context "when the form is valid" do let(:cbd_type_form) { build(:cbd_type_form, :has_required_data) } - let(:valid_params) { { reg_identifier: cbd_type_form.reg_identifier, registration_type: cbd_type_form.registration_type } } + let(:valid_params) { { token: cbd_type_form.token, registration_type: cbd_type_form.registration_type } } it "should submit" do expect(cbd_type_form.submit(valid_params)).to eq(true) @@ -16,7 +16,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:cbd_type_form) { build(:cbd_type_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo", registration_type: "bar" } } + let(:invalid_params) { { token: "foo", registration_type: "bar" } } it "should not submit" do expect(cbd_type_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/check_your_answers_forms_spec.rb b/spec/forms/waste_carriers_engine/check_your_answers_forms_spec.rb index 0dd6da6ef..e04837ef7 100644 --- a/spec/forms/waste_carriers_engine/check_your_answers_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/check_your_answers_forms_spec.rb @@ -11,7 +11,7 @@ module WasteCarriersEngine describe "#submit" do let(:check_your_answers_form) { build(:check_your_answers_form, :has_required_data) } context "when the form is valid" do - let(:valid_params) { { reg_identifier: check_your_answers_form.reg_identifier } } + let(:valid_params) { { token: check_your_answers_form.token } } it "should submit" do expect(check_your_answers_form.submit(valid_params)).to be_truthy diff --git a/spec/forms/waste_carriers_engine/company_address_forms_spec.rb b/spec/forms/waste_carriers_engine/company_address_forms_spec.rb index d4b51188b..71f4e41d9 100644 --- a/spec/forms/waste_carriers_engine/company_address_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/company_address_forms_spec.rb @@ -13,7 +13,7 @@ module WasteCarriersEngine let(:company_address_form) { build(:company_address_form, :has_required_data) } let(:valid_params) do { - reg_identifier: company_address_form.reg_identifier, + token: company_address_form.token, company_address: { uprn: "340116" } @@ -27,7 +27,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:company_address_form) { build(:company_address_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(company_address_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/company_address_manual_forms_spec.rb b/spec/forms/waste_carriers_engine/company_address_manual_forms_spec.rb index 0c7ec90c6..3f42a647d 100644 --- a/spec/forms/waste_carriers_engine/company_address_manual_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/company_address_manual_forms_spec.rb @@ -69,7 +69,7 @@ module WasteCarriersEngine let(:company_address_manual_form) { build(:company_address_manual_form, :has_required_data) } let(:valid_params) do { - reg_identifier: company_address_manual_form.reg_identifier, + token: company_address_manual_form.token, company_address: { house_number: "32", address_line_1: "My House Road", @@ -87,7 +87,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:company_address_manual_form) { build(:company_address_manual_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(company_address_manual_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/company_name_forms_spec.rb b/spec/forms/waste_carriers_engine/company_name_forms_spec.rb index 651112c5a..f983a33a5 100644 --- a/spec/forms/waste_carriers_engine/company_name_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/company_name_forms_spec.rb @@ -8,7 +8,7 @@ module WasteCarriersEngine context "when the form is valid" do let(:company_name_form) { build(:company_name_form, :has_required_data) } let(:valid_params) do - { reg_identifier: company_name_form.reg_identifier, company_name: company_name_form.company_name } + { token: company_name_form.token, company_name: company_name_form.company_name } end it "should submit" do @@ -18,7 +18,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:company_name_form) { build(:company_name_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { company_name: "" } } it "should not submit" do expect(company_name_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/company_postcode_forms_spec.rb b/spec/forms/waste_carriers_engine/company_postcode_forms_spec.rb index b05330532..ae1f4d835 100644 --- a/spec/forms/waste_carriers_engine/company_postcode_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/company_postcode_forms_spec.rb @@ -12,7 +12,7 @@ module WasteCarriersEngine describe "#submit" do context "when the form is valid" do let(:company_postcode_form) { build(:company_postcode_form, :has_required_data) } - let(:valid_params) { { reg_identifier: company_postcode_form.reg_identifier, temp_company_postcode: "BS1 5AH" } } + let(:valid_params) { { token: company_postcode_form.token, temp_company_postcode: "BS1 5AH" } } it "should submit" do expect(company_postcode_form.submit(valid_params)).to eq(true) @@ -43,7 +43,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:company_postcode_form) { build(:company_postcode_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(company_postcode_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/construction_demolition_forms_spec.rb b/spec/forms/waste_carriers_engine/construction_demolition_forms_spec.rb index 9ecdcfaf2..92f435199 100644 --- a/spec/forms/waste_carriers_engine/construction_demolition_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/construction_demolition_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:construction_demolition_form) { build(:construction_demolition_form, :has_required_data) } let(:valid_params) do { - reg_identifier: construction_demolition_form.reg_identifier, + token: construction_demolition_form.token, construction_waste: construction_demolition_form.construction_waste } end @@ -21,7 +21,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:construction_demolition_form) { build(:construction_demolition_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { construction_waste: "foo" } } it "should not submit" do expect(construction_demolition_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/contact_address_forms_spec.rb b/spec/forms/waste_carriers_engine/contact_address_forms_spec.rb index 95b2c2416..feb238df3 100644 --- a/spec/forms/waste_carriers_engine/contact_address_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/contact_address_forms_spec.rb @@ -13,7 +13,7 @@ module WasteCarriersEngine let(:contact_address_form) { build(:contact_address_form, :has_required_data) } let(:valid_params) do { - reg_identifier: contact_address_form.reg_identifier, + token: contact_address_form.token, contact_address: { uprn: "340116" } @@ -27,7 +27,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:contact_address_form) { build(:contact_address_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(contact_address_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/contact_address_manual_forms_spec.rb b/spec/forms/waste_carriers_engine/contact_address_manual_forms_spec.rb index e0c4b5543..072d1964f 100644 --- a/spec/forms/waste_carriers_engine/contact_address_manual_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/contact_address_manual_forms_spec.rb @@ -68,7 +68,7 @@ module WasteCarriersEngine let(:contact_address_manual_form) { build(:contact_address_manual_form, :has_required_data) } let(:valid_params) do { - reg_identifier: contact_address_manual_form.reg_identifier, + token: contact_address_manual_form.token, contact_address: { house_number: "12", address_line_1: "My house road", @@ -87,7 +87,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:contact_address_manual_form) { build(:contact_address_manual_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(contact_address_manual_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/contact_email_forms_spec.rb b/spec/forms/waste_carriers_engine/contact_email_forms_spec.rb index eeab4725a..925c4710e 100644 --- a/spec/forms/waste_carriers_engine/contact_email_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/contact_email_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:contact_email_form) { build(:contact_email_form, :has_required_data) } let(:valid_params) do { - reg_identifier: contact_email_form.reg_identifier, + token: contact_email_form.token, contact_email: contact_email_form.contact_email, confirmed_email: contact_email_form.contact_email } diff --git a/spec/forms/waste_carriers_engine/contact_name_forms_spec.rb b/spec/forms/waste_carriers_engine/contact_name_forms_spec.rb index c94bfb300..0f9492ab0 100644 --- a/spec/forms/waste_carriers_engine/contact_name_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/contact_name_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:contact_name_form) { build(:contact_name_form, :has_required_data) } let(:valid_params) do { - reg_identifier: contact_name_form.reg_identifier, + token: contact_name_form.token, first_name: contact_name_form.first_name, last_name: contact_name_form.last_name } @@ -22,7 +22,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:contact_name_form) { build(:contact_name_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { first_name: "", last_name: "" } } it "should not submit" do expect(contact_name_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/contact_phone_forms_spec.rb b/spec/forms/waste_carriers_engine/contact_phone_forms_spec.rb index 793631e10..fb8287a7b 100644 --- a/spec/forms/waste_carriers_engine/contact_phone_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/contact_phone_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:contact_phone_form) { build(:contact_phone_form, :has_required_data) } let(:valid_params) do { - reg_identifier: contact_phone_form.reg_identifier, + token: contact_phone_form.token, phone_number: contact_phone_form.phone_number } end @@ -23,7 +23,7 @@ module WasteCarriersEngine let(:contact_phone_form) { build(:contact_phone_form, :has_required_data) } let(:invalid_params) do { - reg_identifier: "foo", + token: "foo", phone_number: "foo" } end diff --git a/spec/forms/waste_carriers_engine/contact_postcode_forms_spec.rb b/spec/forms/waste_carriers_engine/contact_postcode_forms_spec.rb index 0b43641f6..dc53f883f 100644 --- a/spec/forms/waste_carriers_engine/contact_postcode_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/contact_postcode_forms_spec.rb @@ -12,7 +12,7 @@ module WasteCarriersEngine describe "#submit" do context "when the form is valid" do let(:contact_postcode_form) { build(:contact_postcode_form, :has_required_data) } - let(:valid_params) { { reg_identifier: contact_postcode_form.reg_identifier, temp_contact_postcode: "BS1 5AH" } } + let(:valid_params) { { token: contact_postcode_form.token, temp_contact_postcode: "BS1 5AH" } } it "should submit" do expect(contact_postcode_form.submit(valid_params)).to eq(true) @@ -43,7 +43,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:contact_postcode_form) { build(:contact_postcode_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(contact_postcode_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/conviction_details_forms_spec.rb b/spec/forms/waste_carriers_engine/conviction_details_forms_spec.rb index f6e2ac184..51194a808 100644 --- a/spec/forms/waste_carriers_engine/conviction_details_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/conviction_details_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine context "when the form is valid" do let(:valid_params) do - { reg_identifier: conviction_details_form.reg_identifier, + { token: conviction_details_form.token, first_name: conviction_details_form.first_name, last_name: conviction_details_form.last_name, position: conviction_details_form.position, @@ -29,7 +29,7 @@ module WasteCarriersEngine end context "when the form is not valid" do - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(conviction_details_form.submit(invalid_params)).to eq(false) @@ -38,7 +38,7 @@ module WasteCarriersEngine context "when the form is blank" do let(:blank_params) do - { reg_identifier: conviction_details_form.reg_identifier, + { token: conviction_details_form.token, first_name: "", last_name: "", position: "", diff --git a/spec/forms/waste_carriers_engine/declaration_forms_spec.rb b/spec/forms/waste_carriers_engine/declaration_forms_spec.rb index ecc328468..6e90da8db 100644 --- a/spec/forms/waste_carriers_engine/declaration_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/declaration_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:declaration_form) { build(:declaration_form, :has_required_data) } let(:valid_params) do { - reg_identifier: declaration_form.reg_identifier, + token: declaration_form.token, declaration: 1 } end @@ -23,7 +23,7 @@ module WasteCarriersEngine let(:declaration_form) { build(:declaration_form, :has_required_data) } let(:invalid_params) do { - reg_identifier: "foo", + token: "foo", declaration: "foo" } end diff --git a/spec/forms/waste_carriers_engine/declare_convictions_forms_spec.rb b/spec/forms/waste_carriers_engine/declare_convictions_forms_spec.rb index faf94dc94..fcffb064b 100644 --- a/spec/forms/waste_carriers_engine/declare_convictions_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/declare_convictions_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:declare_convictions_form) { build(:declare_convictions_form, :has_required_data) } let(:valid_params) do { - reg_identifier: declare_convictions_form.reg_identifier, + token: declare_convictions_form.token, declared_convictions: declare_convictions_form.declared_convictions } end @@ -23,7 +23,7 @@ module WasteCarriersEngine let(:declare_convictions_form) { build(:declare_convictions_form, :has_required_data) } let(:invalid_params) do { - reg_identifier: declare_convictions_form.reg_identifier, + token: declare_convictions_form.token, declared_convictions: "foo" } end diff --git a/spec/forms/waste_carriers_engine/location_forms_spec.rb b/spec/forms/waste_carriers_engine/location_forms_spec.rb index 9dde5edb3..6d890409a 100644 --- a/spec/forms/waste_carriers_engine/location_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/location_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:location_form) { build(:location_form, :has_required_data) } let(:valid_params) do { - reg_identifier: location_form.reg_identifier, + token: location_form.token, location: location_form.location } end @@ -21,7 +21,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:location_form) { build(:location_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { location: "foo" } } it "should not submit" do expect(location_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/main_people_forms_spec.rb b/spec/forms/waste_carriers_engine/main_people_forms_spec.rb index 94a58f810..e924f1a60 100644 --- a/spec/forms/waste_carriers_engine/main_people_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/main_people_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine context "when the form is valid" do let(:valid_params) do - { reg_identifier: main_people_form.reg_identifier, + { token: main_people_form.token, first_name: main_people_form.first_name, last_name: main_people_form.last_name, dob_year: main_people_form.dob_year, @@ -28,7 +28,7 @@ module WasteCarriersEngine end context "when the form is not valid" do - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { token: "foo" } } it "should not submit" do expect(main_people_form.submit(invalid_params)).to eq(false) @@ -37,7 +37,7 @@ module WasteCarriersEngine context "when the form is blank" do let(:blank_params) do - { reg_identifier: main_people_form.reg_identifier, + { token: main_people_form.token, first_name: "", last_name: "", dob_year: "", diff --git a/spec/forms/waste_carriers_engine/other_businesses_forms_spec.rb b/spec/forms/waste_carriers_engine/other_businesses_forms_spec.rb index 6aa69e660..acf6847a5 100644 --- a/spec/forms/waste_carriers_engine/other_businesses_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/other_businesses_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:other_businesses_form) { build(:other_businesses_form, :has_required_data) } let(:valid_params) do { - reg_identifier: other_businesses_form.reg_identifier, + token: other_businesses_form.token, other_businesses: other_businesses_form.other_businesses } end @@ -21,7 +21,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:other_businesses_form) { build(:other_businesses_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { other_businesses: "foo" } } it "should not submit" do expect(other_businesses_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/payment_summary_forms_spec.rb b/spec/forms/waste_carriers_engine/payment_summary_forms_spec.rb index cb5fa7d30..db501b6ef 100644 --- a/spec/forms/waste_carriers_engine/payment_summary_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/payment_summary_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:payment_summary_form) { build(:payment_summary_form, :has_required_data) } let(:valid_params) do { - reg_identifier: payment_summary_form.reg_identifier, + token: payment_summary_form.token, temp_payment_method: payment_summary_form.temp_payment_method } end @@ -21,7 +21,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:payment_summary_form) { build(:payment_summary_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { temp_payment_method: "foo" } } it "should not submit" do expect(payment_summary_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb b/spec/forms/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb index ecf98b5cb..2c3bf903a 100644 --- a/spec/forms/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/register_in_northern_ireland_forms_spec.rb @@ -10,7 +10,7 @@ module WasteCarriersEngine context "when the form is valid" do let(:valid_params) do { - reg_identifier: register_in_northern_ireland_form.reg_identifier + token: register_in_northern_ireland_form.token } end diff --git a/spec/forms/waste_carriers_engine/register_in_scotland_forms_spec.rb b/spec/forms/waste_carriers_engine/register_in_scotland_forms_spec.rb index 26d679d9d..b63cb7c7b 100644 --- a/spec/forms/waste_carriers_engine/register_in_scotland_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/register_in_scotland_forms_spec.rb @@ -10,7 +10,7 @@ module WasteCarriersEngine context "when the form is valid" do let(:valid_params) do { - reg_identifier: register_in_scotland_form.reg_identifier + token: register_in_scotland_form.token } end diff --git a/spec/forms/waste_carriers_engine/register_in_wales_forms_spec.rb b/spec/forms/waste_carriers_engine/register_in_wales_forms_spec.rb index 861296384..fefb054d9 100644 --- a/spec/forms/waste_carriers_engine/register_in_wales_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/register_in_wales_forms_spec.rb @@ -10,7 +10,7 @@ module WasteCarriersEngine context "when the form is valid" do let(:valid_params) do { - reg_identifier: register_in_wales_form.reg_identifier + token: register_in_wales_form.token } end diff --git a/spec/forms/waste_carriers_engine/registration_number_forms_spec.rb b/spec/forms/waste_carriers_engine/registration_number_forms_spec.rb index fcee3e229..049d1317a 100644 --- a/spec/forms/waste_carriers_engine/registration_number_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/registration_number_forms_spec.rb @@ -11,13 +11,13 @@ module WasteCarriersEngine describe "#submit" do context "when the form is valid" do let(:registration_number_form) { build(:registration_number_form, :has_required_data) } - let(:valid_params) { { reg_identifier: registration_number_form.reg_identifier, company_no: "09360070" } } + let(:valid_params) { { token: registration_number_form.token, company_no: "09360070" } } it "should submit" do expect(registration_number_form.submit(valid_params)).to eq(true) end - context "when the reg_identifier is less than 8 characters" do + context "when the token is less than 8 characters" do before(:each) { valid_params[:company_no] = "946107" } it "should increase the length" do @@ -33,7 +33,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:registration_number_form) { build(:registration_number_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo", company_no: "foo" } } + let(:invalid_params) { { token: "foo", company_no: "foo" } } it "should not submit" do expect(registration_number_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/renewal_information_forms_spec.rb b/spec/forms/waste_carriers_engine/renewal_information_forms_spec.rb index 8f7808b24..f950526b8 100644 --- a/spec/forms/waste_carriers_engine/renewal_information_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/renewal_information_forms_spec.rb @@ -8,7 +8,7 @@ module WasteCarriersEngine let(:renewal_information_form) { build(:renewal_information_form, :has_required_data) } context "when the form is valid" do - let(:valid_params) { { reg_identifier: renewal_information_form.reg_identifier } } + let(:valid_params) { { token: renewal_information_form.token } } it "should submit" do expect(renewal_information_form.submit(valid_params)).to eq(true) diff --git a/spec/forms/waste_carriers_engine/renewal_start_forms_spec.rb b/spec/forms/waste_carriers_engine/renewal_start_forms_spec.rb index b1bfb56e0..00a557d7b 100644 --- a/spec/forms/waste_carriers_engine/renewal_start_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/renewal_start_forms_spec.rb @@ -6,7 +6,7 @@ module WasteCarriersEngine RSpec.describe RenewalStartForm, type: :model do describe "#submit" do let(:renewal_start_form) { build(:renewal_start_form, :has_required_data) } - let(:valid_params) { { reg_identifier: renewal_start_form.reg_identifier } } + let(:valid_params) { { token: renewal_start_form.token } } it "should submit" do expect(renewal_start_form.submit(valid_params)).to eq(true) diff --git a/spec/forms/waste_carriers_engine/service_provided_forms_spec.rb b/spec/forms/waste_carriers_engine/service_provided_forms_spec.rb index 6921879c4..be5d3ff54 100644 --- a/spec/forms/waste_carriers_engine/service_provided_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/service_provided_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:service_provided_form) { build(:service_provided_form, :has_required_data) } let(:valid_params) do { - reg_identifier: service_provided_form.reg_identifier, + token: service_provided_form.token, is_main_service: service_provided_form.is_main_service } end @@ -21,7 +21,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:service_provided_form) { build(:service_provided_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { is_main_service: "foo" } } it "should not submit" do expect(service_provided_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/tier_check_forms_spec.rb b/spec/forms/waste_carriers_engine/tier_check_forms_spec.rb index c9f9265bc..f32c7b62d 100644 --- a/spec/forms/waste_carriers_engine/tier_check_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/tier_check_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:tier_check_form) { build(:tier_check_form, :has_required_data) } let(:valid_params) do { - reg_identifier: tier_check_form.reg_identifier, + token: tier_check_form.token, temp_tier_check: tier_check_form.temp_tier_check } end @@ -21,7 +21,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:tier_check_form) { build(:tier_check_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { temp_tier_check: "foo" } } it "should not submit" do expect(tier_check_form.submit(invalid_params)).to eq(false) diff --git a/spec/forms/waste_carriers_engine/waste_types_forms_spec.rb b/spec/forms/waste_carriers_engine/waste_types_forms_spec.rb index 3825dcccc..67976496b 100644 --- a/spec/forms/waste_carriers_engine/waste_types_forms_spec.rb +++ b/spec/forms/waste_carriers_engine/waste_types_forms_spec.rb @@ -9,7 +9,7 @@ module WasteCarriersEngine let(:waste_types_form) { build(:waste_types_form, :has_required_data) } let(:valid_params) do { - reg_identifier: waste_types_form.reg_identifier, + token: waste_types_form.token, only_amf: waste_types_form.only_amf } end @@ -21,7 +21,7 @@ module WasteCarriersEngine context "when the form is not valid" do let(:waste_types_form) { build(:waste_types_form, :has_required_data) } - let(:invalid_params) { { reg_identifier: "foo" } } + let(:invalid_params) { { only_amf: "foo" } } it "should not submit" do expect(waste_types_form.submit(invalid_params)).to eq(false) diff --git a/spec/models/waste_carriers_engine/transient_registration_spec.rb b/spec/models/waste_carriers_engine/transient_registration_spec.rb index 7c2642cd3..32ccc4d7a 100644 --- a/spec/models/waste_carriers_engine/transient_registration_spec.rb +++ b/spec/models/waste_carriers_engine/transient_registration_spec.rb @@ -25,6 +25,10 @@ module WasteCarriersEngine factory: :transient_registration end + describe "secure token" do + it_should_behave_like "Having a secure token" + end + describe "registration attributes" do it_should_behave_like "Can have registration attributes", factory: :transient_registration diff --git a/spec/requests/waste_carriers_engine/bank_transfer_forms_spec.rb b/spec/requests/waste_carriers_engine/bank_transfer_forms_spec.rb index a8be22f52..c715fb20c 100644 --- a/spec/requests/waste_carriers_engine/bank_transfer_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/bank_transfer_forms_spec.rb @@ -23,7 +23,7 @@ module WasteCarriersEngine end it "creates a new order" do - get new_bank_transfer_form_path(transient_registration[:reg_identifier]) + get new_bank_transfer_form_path(transient_registration.token) expect(transient_registration.reload.finance_details.orders.count).to eq(1) end @@ -34,13 +34,13 @@ module WasteCarriersEngine end it "replaces the old order" do - get new_bank_transfer_form_path(transient_registration[:reg_identifier]) + get new_bank_transfer_form_path(transient_registration.token) expect(transient_registration.reload.finance_details.orders.first.world_pay_status).to eq(nil) end it "does not increase the order count" do old_order_count = transient_registration.finance_details.orders.count - get new_bank_transfer_form_path(transient_registration[:reg_identifier]) + get new_bank_transfer_form_path(transient_registration.token) expect(transient_registration.reload.finance_details.orders.count).to eq(old_order_count) end end @@ -79,7 +79,7 @@ module WasteCarriersEngine expect(transient_registration.reload.metaData.route).to be_nil - post_form_with_params(:bank_transfer_form, reg_identifier: transient_registration.reg_identifier) + post_form_with_params(:bank_transfer_form, transient_registration.token) expect(transient_registration.reload.metaData.route).to eq("ASSISTED_DIGITAL") end @@ -107,13 +107,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_bank_transfer_forms_path(transient_registration[:reg_identifier]) + get back_bank_transfer_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the payment_summary form" do - get back_bank_transfer_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_payment_summary_form_path(transient_registration[:reg_identifier])) + get back_bank_transfer_forms_path(transient_registration.token) + expect(response).to redirect_to(new_payment_summary_form_path(transient_registration.token)) end end end @@ -129,13 +129,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_bank_transfer_forms_path(transient_registration[:reg_identifier]) + get back_bank_transfer_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_bank_transfer_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_bank_transfer_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 f475be8b7..b9aa0bc50 100644 --- a/spec/requests/waste_carriers_engine/business_type_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/business_type_forms_spec.rb @@ -29,13 +29,15 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_business_type_forms_path(transient_registration[:reg_identifier]) + get back_business_type_forms_path(transient_registration.token) + expect(response).to have_http_status(302) end it "redirects to the location form" do - get back_business_type_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_location_form_path(transient_registration[:reg_identifier])) + get back_business_type_forms_path(transient_registration.token) + + expect(response).to redirect_to(new_location_form_path(transient_registration.token)) end end end @@ -50,13 +52,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_business_type_forms_path(transient_registration[:reg_identifier]) + get back_business_type_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_business_type_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_location_form_path(transient_registration[:reg_identifier])) + get back_business_type_forms_path(transient_registration.token) + expect(response).to redirect_to(new_location_form_path(transient_registration.token)) end end end diff --git a/spec/requests/waste_carriers_engine/cannot_renew_company_no_change_forms_spec.rb b/spec/requests/waste_carriers_engine/cannot_renew_company_no_change_forms_spec.rb index 62ed0b36e..8f9f4b6bb 100644 --- a/spec/requests/waste_carriers_engine/cannot_renew_company_no_change_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/cannot_renew_company_no_change_forms_spec.rb @@ -23,13 +23,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cannot_renew_company_no_change_forms_path(transient_registration[:reg_identifier]) + get back_cannot_renew_company_no_change_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the registration_number form" do - get back_cannot_renew_company_no_change_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_registration_number_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_company_no_change_forms_path(transient_registration.token) + expect(response).to redirect_to(new_registration_number_form_path(transient_registration.token)) end end end @@ -44,13 +44,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cannot_renew_company_no_change_forms_path(transient_registration[:reg_identifier]) + get back_cannot_renew_company_no_change_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_cannot_renew_company_no_change_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_company_no_change_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) end end end diff --git a/spec/requests/waste_carriers_engine/cannot_renew_lower_tier_forms_spec.rb b/spec/requests/waste_carriers_engine/cannot_renew_lower_tier_forms_spec.rb index 7ceff668e..84ef32d55 100644 --- a/spec/requests/waste_carriers_engine/cannot_renew_lower_tier_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/cannot_renew_lower_tier_forms_spec.rb @@ -23,7 +23,7 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cannot_renew_lower_tier_forms_path(transient_registration[:reg_identifier]) + get back_cannot_renew_lower_tier_forms_path(transient_registration.token) expect(response).to have_http_status(302) end @@ -31,8 +31,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(business_type: "charity") } it "redirects to the business_type form" do - get back_cannot_renew_lower_tier_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_business_type_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_lower_tier_forms_path(transient_registration.token) + expect(response).to redirect_to(new_business_type_form_path(transient_registration.token)) end end @@ -44,8 +44,8 @@ module WasteCarriersEngine end it "redirects to the waste_types form" do - get back_cannot_renew_lower_tier_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_waste_types_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_lower_tier_forms_path(transient_registration.token) + expect(response).to redirect_to(new_waste_types_form_path(transient_registration.token)) end end @@ -56,8 +56,8 @@ module WasteCarriersEngine end it "redirects to the construction_demolition form" do - get back_cannot_renew_lower_tier_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_construction_demolition_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_lower_tier_forms_path(transient_registration.token) + expect(response).to redirect_to(new_construction_demolition_form_path(transient_registration.token)) end end end @@ -73,13 +73,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cannot_renew_lower_tier_forms_path(transient_registration[:reg_identifier]) + get back_cannot_renew_lower_tier_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_cannot_renew_lower_tier_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_lower_tier_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 bc955f74a..4cfc207cd 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 @@ -23,13 +23,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cannot_renew_type_change_forms_path(transient_registration[:reg_identifier]) + get back_cannot_renew_type_change_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the business_type form" do - get back_cannot_renew_type_change_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_business_type_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_type_change_forms_path(transient_registration.token) + expect(response).to redirect_to(new_business_type_form_path(transient_registration.token)) end end end @@ -44,13 +44,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cannot_renew_type_change_forms_path(transient_registration[:reg_identifier]) + get back_cannot_renew_type_change_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_cannot_renew_type_change_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_cannot_renew_type_change_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 cc1efe1b5..83a759cf3 100644 --- a/spec/requests/waste_carriers_engine/cards_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/cards_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cards_forms_path(transient_registration[:reg_identifier]) + get back_cards_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the declaration form" do - get back_cards_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_declaration_form_path(transient_registration[:reg_identifier])) + get back_cards_forms_path(transient_registration.token) + expect(response).to redirect_to(new_declaration_form_path(transient_registration.token)) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cards_forms_path(transient_registration[:reg_identifier]) + get back_cards_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_cards_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_cards_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 d95cdf60b..542af2bd1 100644 --- a/spec/requests/waste_carriers_engine/cbd_type_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/cbd_type_forms_spec.rb @@ -29,7 +29,7 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cbd_type_forms_path(transient_registration[:reg_identifier]) + get back_cbd_type_forms_path(transient_registration.token) expect(response).to have_http_status(302) end @@ -37,8 +37,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(other_businesses: "no") } it "redirects to the construction_demolition form" do - get back_cbd_type_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_construction_demolition_form_path(transient_registration[:reg_identifier])) + get back_cbd_type_forms_path(transient_registration.token) + expect(response).to redirect_to(new_construction_demolition_form_path(transient_registration.token)) end end @@ -49,8 +49,8 @@ module WasteCarriersEngine end it "redirects to the waste_types form" do - get back_cbd_type_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_waste_types_form_path(transient_registration[:reg_identifier])) + get back_cbd_type_forms_path(transient_registration.token) + expect(response).to redirect_to(new_waste_types_form_path(transient_registration.token)) end end @@ -61,8 +61,8 @@ module WasteCarriersEngine end it "redirects to the construction_demolition form" do - get back_cbd_type_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_construction_demolition_form_path(transient_registration[:reg_identifier])) + get back_cbd_type_forms_path(transient_registration.token) + expect(response).to redirect_to(new_construction_demolition_form_path(transient_registration.token)) end end end @@ -78,13 +78,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_cbd_type_forms_path(transient_registration[:reg_identifier]) + get back_cbd_type_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_cbd_type_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_cbd_type_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 bc13d733c..8edfe4987 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 @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_check_your_answers_forms_path(transient_registration[:reg_identifier]) + get back_check_your_answers_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the contact_address form" do - get back_check_your_answers_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_contact_address_form_path(transient_registration[:reg_identifier])) + get back_check_your_answers_forms_path(transient_registration.token) + expect(response).to redirect_to(new_contact_address_form_path(transient_registration.token)) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_check_your_answers_forms_path(transient_registration[:reg_identifier]) + get back_check_your_answers_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_check_your_answers_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_check_your_answers_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 bec4ed860..27c3a1970 100644 --- a/spec/requests/waste_carriers_engine/company_address_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/company_address_forms_spec.rb @@ -29,7 +29,7 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], + token: transient_registration[:token], company_address: { uprn: "340116" } @@ -37,18 +37,18 @@ module WasteCarriersEngine end it "updates the transient registration" do - post company_address_forms_path, company_address_form: valid_params + post company_address_forms_path(transient_registration.token), company_address_form: valid_params expect(transient_registration.reload.company_address.uprn.to_s).to eq("340116") end it "returns a 302 response" do - post company_address_forms_path, company_address_form: valid_params + post company_address_forms_path(transient_registration.token), company_address_form: valid_params expect(response).to have_http_status(302) end it "redirects to the main_people form" do - post company_address_forms_path, company_address_form: valid_params - expect(response).to redirect_to(new_main_people_form_path(transient_registration[:reg_identifier])) + post company_address_forms_path(transient_registration.token), company_address_form: valid_params + expect(response).to redirect_to(new_main_people_form_path(transient_registration[:token])) end context "when the transient registration already has addresses" do @@ -63,7 +63,7 @@ module WasteCarriersEngine it "should have have the same number of addresses before and after submitting" do number_of_addresses = transient_registration.addresses.count - post company_address_forms_path, company_address_form: valid_params + post company_address_forms_path(transient_registration.token), company_address_form: valid_params expect(transient_registration.reload.addresses.count).to eq(number_of_addresses) end @@ -71,7 +71,7 @@ module WasteCarriersEngine it "updates the old contact address" do transient_registration.company_address.update_attributes(uprn: "123456") - post company_address_forms_path, company_address_form: valid_params + post company_address_forms_path(transient_registration.token), company_address_form: valid_params expect(transient_registration.reload.company_address.uprn).to eq(340_116) end @@ -79,21 +79,10 @@ module WasteCarriersEngine end context "when invalid params are submitted" do - let(:invalid_params) do - { - reg_identifier: "foo" - } - end - it "returns a 302 response" do - post company_address_forms_path, company_address_form: invalid_params + post company_address_forms_path("foo"), company_address_form: {} expect(response).to have_http_status(302) end - - it "does not update the transient registration" do - post company_address_forms_path, company_address_form: invalid_params - expect(transient_registration.reload[:reg_identifier]).to_not eq(invalid_params[:reg_identifier]) - end end end @@ -108,23 +97,23 @@ module WasteCarriersEngine let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier] + token: transient_registration[:token] } end it "does not update the transient registration" do - post company_address_forms_path, company_address_form: valid_params + post company_address_forms_path(transient_registration.token), company_address_form: valid_params expect(transient_registration.reload.addresses.count).to eq(0) end it "returns a 302 response" do - post company_address_forms_path, company_address_form: valid_params + post company_address_forms_path(transient_registration.token), company_address_form: valid_params expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - post company_address_forms_path, company_address_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post company_address_forms_path(transient_registration.token), company_address_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -148,13 +137,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_address_forms_path(transient_registration[:reg_identifier]) + get back_company_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the company_postcode form" do - get back_company_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_postcode_form_path(transient_registration[:reg_identifier])) + get back_company_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_company_postcode_form_path(transient_registration[:token])) end end end @@ -170,13 +159,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_address_forms_path(transient_registration[:reg_identifier]) + get back_company_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_company_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_company_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -201,13 +190,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_company_address_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_company_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the company_address_manual form" do - get skip_to_manual_address_company_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_company_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:token])) end end end @@ -223,13 +212,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_company_address_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_company_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get skip_to_manual_address_company_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_company_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end 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 09c0e4326..825015b8b 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 @@ -24,7 +24,6 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], company_address: { house_number: "42", address_line_1: "Foo Terrace", @@ -34,18 +33,18 @@ module WasteCarriersEngine end it "updates the transient registration" do - post company_address_manual_forms_path, company_address_manual_form: valid_params + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params expect(transient_registration.reload.registered_address.house_number).to eq("42") end it "returns a 302 response" do - post company_address_manual_forms_path, company_address_manual_form: valid_params + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params expect(response).to have_http_status(302) end it "redirects to the main_people form" do - post company_address_manual_forms_path, company_address_manual_form: valid_params - expect(response).to redirect_to(new_main_people_form_path(transient_registration[:reg_identifier])) + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params + expect(response).to redirect_to(new_main_people_form_path(transient_registration.token)) end context "when the transient registration already has addresses" do @@ -59,46 +58,28 @@ module WasteCarriersEngine it "should have have the same number of addresses before and after submitting" do number_of_addresses = transient_registration.addresses.count - post company_address_manual_forms_path, company_address_manual_form: valid_params + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params expect(transient_registration.reload.addresses.count).to eq(number_of_addresses) end it "removes the old registered address" do old_registered_address = transient_registration.registered_address - post company_address_manual_forms_path, company_address_manual_form: valid_params + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params expect(transient_registration.reload.registered_address).to_not eq(old_registered_address) end it "adds the new registered address" do - post company_address_manual_forms_path, company_address_manual_form: valid_params + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params expect(transient_registration.reload.registered_address.address_line_1).to eq("Foo Terrace") end it "does not modify the existing contact address" do old_contact_address = transient_registration.contact_address - post company_address_manual_forms_path, company_address_manual_form: valid_params + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params expect(transient_registration.reload.contact_address).to eq(old_contact_address) end end end - - context "when invalid params are submitted" do - let(:invalid_params) do - { - reg_identifier: "foo" - } - end - - it "returns a 302 response" do - post company_address_manual_forms_path, company_address_manual_form: invalid_params - expect(response).to have_http_status(302) - end - - it "does not update the transient registration" do - post company_address_manual_forms_path, company_address_manual_form: invalid_params - expect(transient_registration.reload[:reg_identifier]).to_not eq(invalid_params[:reg_identifier]) - end - end end context "when the transient registration is in the wrong state" do @@ -111,7 +92,6 @@ module WasteCarriersEngine let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], company_address: { house_number: "42", address_line_1: "Foo Terrace", @@ -121,18 +101,18 @@ module WasteCarriersEngine end it "does not update the transient registration" do - post company_address_forms_path, company_address_form: valid_params + post company_address_forms_path(transient_registration.token), company_address_form: valid_params expect(transient_registration.reload.addresses.count).to eq(0) end it "returns a 302 response" do - post company_address_manual_forms_path, company_address_manual_form: valid_params + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - post company_address_manual_forms_path, company_address_manual_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post company_address_manual_forms_path(transient_registration.token), company_address_manual_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) end end end @@ -155,7 +135,7 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_address_manual_forms_path(transient_registration[:reg_identifier]) + get back_company_address_manual_forms_path(transient_registration.token) expect(response).to have_http_status(302) end @@ -163,8 +143,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(location: "overseas") } it "redirects to the company_name form" do - get back_company_address_manual_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_name_form_path(transient_registration[:reg_identifier])) + get back_company_address_manual_forms_path(transient_registration.token) + expect(response).to redirect_to(new_company_name_form_path(transient_registration.token)) end end @@ -172,8 +152,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(location: "england") } it "redirects to the company_postcode form" do - get back_company_address_manual_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_postcode_form_path(transient_registration[:reg_identifier])) + get back_company_address_manual_forms_path(transient_registration.token) + expect(response).to redirect_to(new_company_postcode_form_path(transient_registration.token)) end end end @@ -189,13 +169,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_address_manual_forms_path(transient_registration[:reg_identifier]) + get back_company_address_manual_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_company_address_manual_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_company_address_manual_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 e497600f2..69c3b65e9 100644 --- a/spec/requests/waste_carriers_engine/company_name_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/company_name_forms_spec.rb @@ -29,7 +29,7 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) + get back_company_name_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end @@ -37,8 +37,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(business_type: "localAuthority") } it "redirects to the renewal_information form" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:reg_identifier])) + get back_company_name_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:token])) end end @@ -46,8 +46,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(business_type: "limitedCompany") } it "redirects to the registration_number form" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_registration_number_form_path(transient_registration[:reg_identifier])) + get back_company_name_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_registration_number_form_path(transient_registration[:token])) end end @@ -55,8 +55,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(business_type: "limitedLiabilityPartnership") } it "redirects to the registration_number form" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_registration_number_form_path(transient_registration[:reg_identifier])) + get back_company_name_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_registration_number_form_path(transient_registration[:token])) end end @@ -64,8 +64,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(location: "overseas") } it "redirects to the renewal_information form" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:reg_identifier])) + get back_company_name_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:token])) end end @@ -73,8 +73,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(business_type: "partnership") } it "redirects to the renewal_information form" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:reg_identifier])) + get back_company_name_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:token])) end end @@ -82,8 +82,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(business_type: "soleTrader") } it "redirects to the renewal_information form" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:reg_identifier])) + get back_company_name_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:token])) end end end @@ -99,13 +99,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) + get back_company_name_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_company_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_company_name_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 0be0d3064..e7fedf574 100644 --- a/spec/requests/waste_carriers_engine/company_postcode_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/company_postcode_forms_spec.rb @@ -24,7 +24,7 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], + token: transient_registration[:token], temp_company_postcode: "BS1 6AH" } end @@ -35,18 +35,18 @@ module WasteCarriersEngine end it "returns a 302 response" do - post company_postcode_forms_path, company_postcode_form: valid_params + post company_postcode_forms_path(transient_registration.token), company_postcode_form: valid_params expect(response).to have_http_status(302) end it "updates the transient registration" do - post company_postcode_forms_path, company_postcode_form: valid_params + post company_postcode_forms_path(transient_registration.token), company_postcode_form: valid_params expect(transient_registration.reload[:temp_company_postcode]).to eq(valid_params[:temp_company_postcode]) end it "redirects to the company_address form" do - post company_postcode_forms_path, company_postcode_form: valid_params - expect(response).to redirect_to(new_company_address_form_path(transient_registration[:reg_identifier])) + post company_postcode_forms_path(transient_registration.token), company_postcode_form: valid_params + expect(response).to redirect_to(new_company_address_form_path(transient_registration[:token])) end context "when a postcode search returns an error" do @@ -55,30 +55,11 @@ module WasteCarriersEngine end it "redirects to the company_address_manual form" do - post company_postcode_forms_path, company_postcode_form: valid_params - expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:reg_identifier])) + post company_postcode_forms_path(transient_registration.token), company_postcode_form: valid_params + expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:token])) end end end - - context "when invalid params are submitted" do - let(:invalid_params) do - { - reg_identifier: "foo", - temp_company_postcode: "ABC123DEF456" - } - end - - it "returns a 302 response" do - post company_postcode_forms_path, company_postcode_form: invalid_params - expect(response).to have_http_status(302) - end - - it "does not update the transient registration" do - post company_postcode_forms_path, company_postcode_form: invalid_params - expect(transient_registration.reload[:temp_company_postcode]).to_not eq(invalid_params[:temp_company_postcode]) - end - end end context "when the transient registration is in the wrong state" do @@ -92,24 +73,23 @@ module WasteCarriersEngine let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], temp_company_postcode: "BS1 5AH" } end it "returns a 302 response" do - post company_postcode_forms_path, company_postcode_form: valid_params + post company_postcode_forms_path(transient_registration.token), company_postcode_form: valid_params expect(response).to have_http_status(302) end it "does not update the transient registration" do - post company_postcode_forms_path, company_postcode_form: valid_params + post company_postcode_forms_path(transient_registration.token), company_postcode_form: valid_params expect(transient_registration.reload[:temp_company_postcode]).to_not eq(valid_params[:temp_company_postcode]) end it "redirects to the correct form for the state" do - post company_postcode_forms_path, company_postcode_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post company_postcode_forms_path(transient_registration.token), company_postcode_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -132,13 +112,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_postcode_forms_path(transient_registration[:reg_identifier]) + get back_company_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the company_name form" do - get back_company_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_name_form_path(transient_registration[:reg_identifier])) + get back_company_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_company_name_form_path(transient_registration[:token])) end end end @@ -153,13 +133,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_company_postcode_forms_path(transient_registration[:reg_identifier]) + get back_company_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_company_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_company_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -184,13 +164,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_company_postcode_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_company_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the company_address_manual form" do - get skip_to_manual_address_company_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_company_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:token])) end end end @@ -206,13 +186,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_company_postcode_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_company_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get skip_to_manual_address_company_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_company_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 845a0b9da..097c5fe8a 100644 --- a/spec/requests/waste_carriers_engine/construction_demolition_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/construction_demolition_forms_spec.rb @@ -29,7 +29,7 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_construction_demolition_forms_path(transient_registration[:reg_identifier]) + get back_construction_demolition_forms_path(transient_registration.token) expect(response).to have_http_status(302) end @@ -37,8 +37,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(other_businesses: "no") } it "redirects to the other_businesses form" do - get back_construction_demolition_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_other_businesses_form_path(transient_registration[:reg_identifier])) + get back_construction_demolition_forms_path(transient_registration.token) + expect(response).to redirect_to(new_other_businesses_form_path(transient_registration.token)) end end @@ -46,8 +46,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(other_businesses: "yes") } it "redirects to the service_provided form" do - get back_construction_demolition_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_service_provided_form_path(transient_registration[:reg_identifier])) + get back_construction_demolition_forms_path(transient_registration.token) + expect(response).to redirect_to(new_service_provided_form_path(transient_registration.token)) end end end @@ -63,13 +63,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_construction_demolition_forms_path(transient_registration[:reg_identifier]) + get back_construction_demolition_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_construction_demolition_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_construction_demolition_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 2097c4351..f215c5786 100644 --- a/spec/requests/waste_carriers_engine/contact_address_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_address_forms_spec.rb @@ -30,7 +30,7 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], + token: transient_registration[:token], contact_address: { uprn: "340116" } @@ -38,19 +38,19 @@ module WasteCarriersEngine end it "updates the transient registration" do - post contact_address_forms_path, contact_address_form: valid_params + post contact_address_forms_path(transient_registration.token), contact_address_form: valid_params expect(transient_registration.reload.contact_address.uprn.to_s).to eq("340116") end it "returns a 302 response" do - post contact_address_forms_path, contact_address_form: valid_params + post contact_address_forms_path(transient_registration.token), contact_address_form: valid_params expect(response).to have_http_status(302) end it "redirects to the check_your_answers form" do - post contact_address_forms_path, contact_address_form: valid_params - expect(response).to redirect_to(new_check_your_answers_form_path(transient_registration[:reg_identifier])) + post contact_address_forms_path(transient_registration.token), contact_address_form: valid_params + expect(response).to redirect_to(new_check_your_answers_form_path(transient_registration[:token])) end context "when the transient registration already has addresses" do @@ -64,37 +64,19 @@ module WasteCarriersEngine it "should have have the same number of addresses before and after submitting" do number_of_addresses = transient_registration.addresses.count - post contact_address_forms_path, contact_address_form: valid_params + post contact_address_forms_path(transient_registration.token), contact_address_form: valid_params expect(transient_registration.reload.addresses.count).to eq(number_of_addresses) end it "updates the old contact address" do transient_registration.contact_address.update_attributes(uprn: "123456") - post contact_address_forms_path, contact_address_form: valid_params + post contact_address_forms_path(transient_registration.token), contact_address_form: valid_params expect(transient_registration.reload.contact_address.uprn).to eq(340_116) end end end - - context "when invalid params are submitted" do - let(:invalid_params) do - { - reg_identifier: "foo" - } - end - - it "returns a 302 response" do - post contact_address_forms_path, contact_address_form: invalid_params - expect(response).to have_http_status(302) - end - - it "does not update the transient registration" do - post contact_address_forms_path, contact_address_form: invalid_params - expect(transient_registration.reload[:reg_identifier]).to_not eq(invalid_params[:reg_identifier]) - end - end end context "when the transient registration is in the wrong state" do @@ -106,25 +88,19 @@ module WasteCarriersEngine workflow_state: "renewal_start_form") end - let(:valid_params) do - { - reg_identifier: transient_registration[:reg_identifier] - } - end - it "does not update the transient registration" do - post contact_address_forms_path, contact_address_form: valid_params + post contact_address_forms_path(transient_registration.token) expect(transient_registration.reload.addresses.count).to eq(0) end it "returns a 302 response" do - post contact_address_forms_path, contact_address_form: valid_params + post contact_address_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - post contact_address_forms_path, contact_address_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post contact_address_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -148,13 +124,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_address_forms_path(transient_registration[:reg_identifier]) + get back_contact_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the contact_postcode form" do - get back_contact_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_contact_postcode_form_path(transient_registration[:reg_identifier])) + get back_contact_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_contact_postcode_form_path(transient_registration[:token])) end end end @@ -170,13 +146,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_address_forms_path(transient_registration[:reg_identifier]) + get back_contact_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_contact_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_contact_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -201,13 +177,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_contact_address_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_contact_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the contact_address_manual form" do - get skip_to_manual_address_contact_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_contact_address_manual_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_contact_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_contact_address_manual_form_path(transient_registration[:token])) end end end @@ -223,13 +199,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_contact_address_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_contact_address_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get skip_to_manual_address_contact_address_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_contact_address_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end 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 390569935..7985ff82a 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 @@ -24,7 +24,7 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], + token: transient_registration[:token], contact_address: { house_number: "42", address_line_1: "Foo Terrace", @@ -34,18 +34,18 @@ module WasteCarriersEngine end it "updates the transient registration" do - post contact_address_manual_forms_path, contact_address_manual_form: valid_params + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params expect(transient_registration.reload.contact_address.house_number).to eq("42") end it "returns a 302 response" do - post contact_address_manual_forms_path, contact_address_manual_form: valid_params + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params expect(response).to have_http_status(302) end it "redirects to the check_your_answers form" do - post contact_address_manual_forms_path, contact_address_manual_form: valid_params - expect(response).to redirect_to(new_check_your_answers_form_path(transient_registration[:reg_identifier])) + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params + expect(response).to redirect_to(new_check_your_answers_form_path(transient_registration[:token])) end context "when the transient registration already has addresses" do @@ -59,46 +59,28 @@ module WasteCarriersEngine it "should have have the same number of addresses before and after submitting" do number_of_addresses = transient_registration.addresses.count - post contact_address_manual_forms_path, contact_address_manual_form: valid_params + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params expect(transient_registration.reload.addresses.count).to eq(number_of_addresses) end it "removes the old contact address" do old_contact_address = transient_registration.contact_address - post contact_address_manual_forms_path, contact_address_manual_form: valid_params + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params expect(transient_registration.reload.contact_address).to_not eq(old_contact_address) end it "adds the new contact address" do - post contact_address_manual_forms_path, contact_address_manual_form: valid_params + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params expect(transient_registration.reload.contact_address.address_line_1).to eq("Foo Terrace") end it "does not modify the existing registered address" do old_registered_address = transient_registration.registered_address - post contact_address_manual_forms_path, contact_address_manual_form: valid_params + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params expect(transient_registration.reload.registered_address).to eq(old_registered_address) end end end - - context "when invalid params are submitted" do - let(:invalid_params) do - { - reg_identifier: "foo" - } - end - - it "returns a 302 response" do - post contact_address_manual_forms_path, contact_address_manual_form: invalid_params - expect(response).to have_http_status(302) - end - - it "does not update the transient registration" do - post contact_address_manual_forms_path, contact_address_manual_form: invalid_params - expect(transient_registration.reload[:reg_identifier]).to_not eq(invalid_params[:reg_identifier]) - end - end end context "when the transient registration is in the wrong state" do @@ -111,7 +93,7 @@ module WasteCarriersEngine let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], + token: transient_registration[:token], contact_address: { house_number: "42", address_line_1: "Foo Terrace", @@ -121,18 +103,18 @@ module WasteCarriersEngine end it "does not update the transient registration" do - post contact_address_forms_path, contact_address_form: valid_params + post contact_address_forms_path(transient_registration.token), contact_address_form: valid_params expect(transient_registration.reload.addresses.count).to eq(0) end it "returns a 302 response" do - post contact_address_manual_forms_path, contact_address_manual_form: valid_params + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - post contact_address_manual_forms_path, contact_address_manual_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post contact_address_manual_forms_path(transient_registration.token), contact_address_manual_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -155,7 +137,7 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_address_manual_forms_path(transient_registration[:reg_identifier]) + get back_contact_address_manual_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end @@ -163,8 +145,8 @@ module WasteCarriersEngine 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[:reg_identifier]) - expect(response).to redirect_to(new_contact_email_form_path(transient_registration[:reg_identifier])) + 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 @@ -172,8 +154,8 @@ module WasteCarriersEngine # before(:each) { transient_registration.update_attributes(location: "england") } # # it "redirects to the contact_postcode form" do - # get back_contact_address_manual_forms_path(transient_registration[:reg_identifier]) - # expect(response).to redirect_to(new_contact_postcode_form_path(transient_registration[:reg_identifier])) + # get back_contact_address_manual_forms_path(transient_registration[:token]) + # expect(response).to redirect_to(new_contact_postcode_form_path(transient_registration[:token])) # end # end end @@ -189,13 +171,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_address_manual_forms_path(transient_registration[:reg_identifier]) + get back_contact_address_manual_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_contact_address_manual_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_contact_address_manual_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 017d626dc..8b4e1fa9d 100644 --- a/spec/requests/waste_carriers_engine/contact_email_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_email_forms_spec.rb @@ -31,13 +31,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_email_forms_path(transient_registration[:reg_identifier]) + get back_contact_email_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the contact_phone form" do - get back_contact_email_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_contact_phone_form_path(transient_registration[:reg_identifier])) + get back_contact_email_forms_path(transient_registration.token) + expect(response).to redirect_to(new_contact_phone_form_path(transient_registration.token)) end end end @@ -52,13 +52,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_email_forms_path(transient_registration[:reg_identifier]) + get back_contact_email_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_contact_email_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_contact_email_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 4341d77e7..7075ffc9f 100644 --- a/spec/requests/waste_carriers_engine/contact_name_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_name_forms_spec.rb @@ -31,13 +31,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_name_forms_path(transient_registration[:reg_identifier]) + get back_contact_name_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the declare_convictions form" do - get back_contact_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration[:reg_identifier])) + get back_contact_name_forms_path(transient_registration.token) + expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration.token)) end end end @@ -52,13 +52,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_name_forms_path(transient_registration[:reg_identifier]) + get back_contact_name_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_contact_name_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_contact_name_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 86f1521b7..b0f31291d 100644 --- a/spec/requests/waste_carriers_engine/contact_phone_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_phone_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_phone_forms_path(transient_registration[:reg_identifier]) + get back_contact_phone_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the contact_name form" do - get back_contact_phone_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_contact_name_form_path(transient_registration[:reg_identifier])) + get back_contact_phone_forms_path(transient_registration.token) + expect(response).to redirect_to(new_contact_name_form_path(transient_registration.token)) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_phone_forms_path(transient_registration[:reg_identifier]) + get back_contact_phone_forms_path(transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_contact_phone_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_contact_phone_forms_path(transient_registration.token) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration.token)) 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 8edb45fae..b8ecb83ea 100644 --- a/spec/requests/waste_carriers_engine/contact_postcode_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/contact_postcode_forms_spec.rb @@ -24,7 +24,6 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], temp_contact_postcode: "BS1 6AH" } end @@ -35,18 +34,18 @@ module WasteCarriersEngine end it "returns a 302 response" do - post contact_postcode_forms_path, contact_postcode_form: valid_params + post contact_postcode_forms_path(transient_registration.token), contact_postcode_form: valid_params expect(response).to have_http_status(302) end it "updates the transient registration" do - post contact_postcode_forms_path, contact_postcode_form: valid_params + post contact_postcode_forms_path(transient_registration.token), contact_postcode_form: valid_params expect(transient_registration.reload[:temp_contact_postcode]).to eq(valid_params[:temp_contact_postcode]) end it "redirects to the contact_address form" do - post contact_postcode_forms_path, contact_postcode_form: valid_params - expect(response).to redirect_to(new_contact_address_form_path(transient_registration[:reg_identifier])) + post contact_postcode_forms_path(transient_registration.token), contact_postcode_form: valid_params + expect(response).to redirect_to(new_contact_address_form_path(transient_registration[:token])) end context "when a postcode search returns an error" do @@ -55,8 +54,8 @@ module WasteCarriersEngine end it "redirects to the contact_address_manual form" do - post contact_postcode_forms_path, contact_postcode_form: valid_params - expect(response).to redirect_to(new_contact_address_manual_form_path(transient_registration[:reg_identifier])) + post contact_postcode_forms_path(transient_registration.token), contact_postcode_form: valid_params + expect(response).to redirect_to(new_contact_address_manual_form_path(transient_registration[:token])) end end end @@ -64,18 +63,17 @@ module WasteCarriersEngine context "when invalid params are submitted" do let(:invalid_params) do { - reg_identifier: "foo", temp_contact_postcode: "ABC123DEF456" } end it "returns a 302 response" do - post contact_postcode_forms_path, contact_postcode_form: invalid_params + post contact_postcode_forms_path("foo"), contact_postcode_form: invalid_params expect(response).to have_http_status(302) end it "does not update the transient registration" do - post contact_postcode_forms_path, contact_postcode_form: invalid_params + post contact_postcode_forms_path("foo"), contact_postcode_form: invalid_params expect(transient_registration.reload[:temp_contact_postcode]).to_not eq(invalid_params[:temp_contact_postcode]) end end @@ -91,24 +89,23 @@ module WasteCarriersEngine let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], temp_contact_postcode: "BS3 6AH" } end it "returns a 302 response" do - post contact_postcode_forms_path, contact_postcode_form: valid_params + post contact_postcode_forms_path(transient_registration[:token]), contact_postcode_form: valid_params expect(response).to have_http_status(302) end it "does not update the transient registration" do - post contact_postcode_forms_path, contact_postcode_form: valid_params + post contact_postcode_forms_path(transient_registration[:token]), contact_postcode_form: valid_params expect(transient_registration.reload[:temp_contact_postcode]).to_not eq(valid_params[:temp_contact_postcode]) end it "redirects to the correct form for the state" do - post contact_postcode_forms_path, contact_postcode_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post contact_postcode_forms_path(transient_registration[:token]), contact_postcode_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -131,13 +128,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_postcode_forms_path(transient_registration[:reg_identifier]) + get back_contact_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the contact_email form" do - get back_contact_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_contact_email_form_path(transient_registration[:reg_identifier])) + get back_contact_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_contact_email_form_path(transient_registration[:token])) end end end @@ -152,13 +149,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_contact_postcode_forms_path(transient_registration[:reg_identifier]) + get back_contact_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_contact_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_contact_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -183,13 +180,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the contact_address_manual form" do - get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_contact_address_manual_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_contact_address_manual_form_path(transient_registration[:token])) end end end @@ -205,13 +202,13 @@ module WasteCarriersEngine context "when the skip_to_manual_address action is triggered" do it "returns a 302 response" do - get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:reg_identifier]) + get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get skip_to_manual_address_contact_postcode_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end 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 8f982b55f..30c89dc74 100644 --- a/spec/requests/waste_carriers_engine/conviction_details_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/conviction_details_forms_spec.rb @@ -24,7 +24,6 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], first_name: "Foo", last_name: "Bar", position: "Baz", @@ -36,23 +35,23 @@ module WasteCarriersEngine it "increases the total number of people" do total_people_count = transient_registration.key_people.count - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(transient_registration.reload.key_people.count).to eq(total_people_count + 1) end it "updates the transient registration" do - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(transient_registration.reload.key_people.last.position).to eq(valid_params[:position]) end it "returns a 302 response" do - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(response).to have_http_status(302) end it "redirects to the contact_name form" do - post conviction_details_forms_path, conviction_details_form: valid_params - expect(response).to redirect_to(new_contact_name_form_path(transient_registration[:reg_identifier])) + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params + expect(response).to redirect_to(new_contact_name_form_path(transient_registration[:token])) end context "when there is already a relevant conviction person" do @@ -64,12 +63,12 @@ module WasteCarriersEngine it "increases the total number of people" do total_people_count = transient_registration.key_people.count - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(transient_registration.reload.key_people.count).to eq(total_people_count + 1) end it "does not replace the existing relevant conviction person" do - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(transient_registration.reload.key_people.first.first_name).to eq(relevant_conviction_person.first_name) end end @@ -83,20 +82,20 @@ module WasteCarriersEngine it "increases the total number of people" do total_people_count = transient_registration.key_people.count - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(transient_registration.reload.key_people.count).to eq(total_people_count + 1) end it "does not replace the existing main person" do - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(transient_registration.reload.key_people.first.first_name).to eq(main_person.first_name) end end context "when the submit params say to add another" do it "redirects to the conviction_details form" do - post conviction_details_forms_path, conviction_details_form: valid_params, commit: "Add another person" - expect(response).to redirect_to(new_conviction_details_form_path(transient_registration[:reg_identifier])) + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params, commit: "Add another person" + expect(response).to redirect_to(new_conviction_details_form_path(transient_registration[:token])) end end end @@ -104,7 +103,6 @@ module WasteCarriersEngine context "when invalid params are submitted" do let(:invalid_params) do { - reg_identifier: "foo", first_name: "", last_name: "", dob_day: "31", @@ -113,14 +111,9 @@ module WasteCarriersEngine } end - it "returns a 302 response" do - post conviction_details_forms_path, conviction_details_form: invalid_params - expect(response).to have_http_status(302) - end - it "does not increase the total number of people" do total_people_count = transient_registration.key_people.count - post conviction_details_forms_path, conviction_details_form: invalid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: invalid_params expect(transient_registration.reload.key_people.count).to eq(total_people_count) end @@ -132,23 +125,15 @@ module WasteCarriersEngine end it "does not replace the existing main person" do - post conviction_details_forms_path, conviction_details_form: invalid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: invalid_params expect(transient_registration.reload.key_people.first.first_name).to eq(existing_main_person.first_name) end end - - context "when the submit params say to add another" do - it "returns a 302 response" do - post conviction_details_forms_path, conviction_details_form: invalid_params, commit: "Add another person" - expect(response).to have_http_status(302) - end - end end context "when blank params are submitted" do let(:blank_params) do { - reg_identifier: "foo", first_name: "", last_name: "", position: "", @@ -160,7 +145,7 @@ module WasteCarriersEngine it "does not increase the total number of people" do total_people_count = transient_registration.key_people.count - post conviction_details_forms_path, conviction_details_form: blank_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: blank_params expect(transient_registration.reload.key_people.count).to eq(total_people_count) end end @@ -176,7 +161,6 @@ module WasteCarriersEngine let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], first_name: "Foo", last_name: "Bar", position: "Baz", @@ -187,18 +171,18 @@ module WasteCarriersEngine end it "does not update the transient registration" do - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(transient_registration.reload.key_people).to_not exist end it "returns a 302 response" do - post conviction_details_forms_path, conviction_details_form: valid_params + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - post conviction_details_forms_path, conviction_details_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post conviction_details_forms_path(transient_registration.token), conviction_details_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -221,13 +205,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_conviction_details_forms_path(transient_registration[:reg_identifier]) + get back_conviction_details_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the declare_convictions form" do - get back_conviction_details_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration[:reg_identifier])) + get back_conviction_details_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration[:token])) end end end @@ -242,13 +226,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_conviction_details_forms_path(transient_registration[:reg_identifier]) + get back_conviction_details_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_conviction_details_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_conviction_details_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -280,28 +264,28 @@ module WasteCarriersEngine context "when the delete person action is triggered" do it "returns a 302 response" do - delete delete_person_conviction_details_forms_path(relevant_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_conviction_details_forms_path(id: relevant_person_a[:id], token: transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the conviction details form" do - delete delete_person_conviction_details_forms_path(relevant_person_a[:id]), reg_identifier: transient_registration.reg_identifier - expect(response).to redirect_to(new_conviction_details_form_path(transient_registration[:reg_identifier])) + delete delete_person_conviction_details_forms_path(id: relevant_person_a[:id], token: transient_registration.token) + expect(response).to redirect_to(new_conviction_details_form_path(transient_registration[:token])) end it "reduces the total number of people" do total_people_count = transient_registration.key_people.count - delete delete_person_conviction_details_forms_path(relevant_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_conviction_details_forms_path(id: relevant_person_a[:id], token: transient_registration.token) expect(transient_registration.reload.key_people.count).to eq(total_people_count - 1) end it "removes the person" do - delete delete_person_conviction_details_forms_path(relevant_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_conviction_details_forms_path(id: relevant_person_a[:id], token: transient_registration.token) expect(transient_registration.reload.key_people.where(id: relevant_person_a[:id]).count).to eq(0) end it "does not modify the other people" do - delete delete_person_conviction_details_forms_path(relevant_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_conviction_details_forms_path(id: relevant_person_a[:id], token: transient_registration.token) expect(transient_registration.reload.key_people.where(id: relevant_person_b[:id]).count).to eq(1) end end diff --git a/spec/requests/waste_carriers_engine/copy_cards_forms_spec.rb b/spec/requests/waste_carriers_engine/copy_cards_forms_spec.rb index d07dc034b..e14c5dc49 100644 --- a/spec/requests/waste_carriers_engine/copy_cards_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/copy_cards_forms_spec.rb @@ -13,15 +13,17 @@ module WasteCarriersEngine end context "when no matching registration exists" do - it "redirects to the invalid reg_identifier error page" do + it "redirects to the invalid token error page" do get new_copy_cards_form_path("CBDU999999999") + expect(response).to redirect_to(page_path("invalid")) end end - context "when the reg_identifier doesn't match the format" do - it "redirects to the invalid reg_identifier error page" do + context "when the token doesn't match the format" do + it "redirects to the invalid token error page" do get new_copy_cards_form_path("foo") + expect(response).to redirect_to(page_path("invalid")) end end @@ -40,15 +42,10 @@ module WasteCarriersEngine context "when the given registration is active" do let(:registration) { create(:registration, :has_required_data, :is_active) } - it "renders the appropriate template" do + it "responds to the GET request with a 200 status code and renders the appropriate template" do get new_copy_cards_form_path(registration.reg_identifier) expect(response).to render_template("waste_carriers_engine/copy_cards_forms/new") - end - - it "responds to the GET request with a 200 status code" do - get new_copy_cards_form_path(registration.reg_identifier) - expect(response.code).to eq("200") end end @@ -61,13 +58,10 @@ module WasteCarriersEngine sign_out(user) end - it "returns a 302 response" do + it "returns a 302 response and redirects to the sign in page" do get new_copy_cards_form_path("foo") - expect(response).to have_http_status(302) - end - it "redirects to the sign in page" do - get new_copy_cards_form_path("foo") + expect(response).to have_http_status(302) expect(response).to redirect_to(new_user_session_path) end end @@ -82,36 +76,24 @@ module WasteCarriersEngine end context "when no matching registration exists" do - let(:invalid_params) { { reg_identifier: "CBDU99999" } } - - it "redirects to the invalid reg_identifier error page" do - post copy_cards_forms_path, copy_cards_form: invalid_params - expect(response).to redirect_to(page_path("invalid")) - end - - it "does not create a new transient registration" do + it "redirects to the invalid token error page and does not create a new transient registration" do original_tr_count = OrderCopyCardsRegistration.count - post copy_cards_forms_path, copy_cards_form: invalid_params - updated_tr_count = OrderCopyCardsRegistration.count - expect(original_tr_count).to eq(updated_tr_count) - end - end - - context "when the reg_identifier doesn't match the format" do - let(:invalid_params) { { reg_identifier: "foo" } } + post copy_cards_forms_path("CBDU99999") - it "redirects to the invalid reg_identifier error page" do - post copy_cards_forms_path, copy_cards_form: invalid_params expect(response).to redirect_to(page_path("invalid")) + expect(OrderCopyCardsRegistration.count).to eq(original_tr_count) end + end - it "does not create a new transient registration" do + context "when the token doesn't match the format" do + it "redirects to the invalid token error page and does not create a new transient registration" do original_tr_count = OrderCopyCardsRegistration.count - post copy_cards_forms_path, copy_cards_form: invalid_params - updated_tr_count = OrderCopyCardsRegistration.count - expect(original_tr_count).to eq(updated_tr_count) + post copy_cards_forms_path("foo") + + expect(OrderCopyCardsRegistration.count).to eq(original_tr_count) + expect(response).to redirect_to(page_path("invalid")) end end @@ -119,27 +101,27 @@ module WasteCarriersEngine let(:registration) { create(:registration, :has_required_data, :is_active) } context "when valid params are submitted" do - let(:valid_params) { { reg_identifier: registration.reg_identifier, temp_cards: 3 } } + let(:valid_params) { { token: registration.reg_identifier, temp_cards: 3 } } it "creates a transient registration with correct data, returns a 302 response and redirects to the copy cards payment form" do expected_tr_count = OrderCopyCardsRegistration.count + 1 - post copy_cards_forms_path, copy_cards_form: valid_params + post copy_cards_forms_path(registration.reg_identifier), copy_cards_form: valid_params transient_registration = OrderCopyCardsRegistration.find_by(reg_identifier: registration.reg_identifier) expect(expected_tr_count).to eq(OrderCopyCardsRegistration.count) expect(transient_registration.temp_cards).to eq(3) expect(response).to have_http_status(302) - expect(response).to redirect_to(new_copy_cards_payment_form_path(valid_params[:reg_identifier])) + expect(response).to redirect_to(new_copy_cards_payment_form_path(transient_registration.token)) end end context "when invalid params are submitted" do - let(:invalid_params) { { reg_identifier: registration.reg_identifier, temp_cards: 0 } } + let(:invalid_params) { { token: registration.reg_identifier, temp_cards: 0 } } it "returns a 200 response and render the new copy cards form" do - post copy_cards_forms_path, copy_cards_form: invalid_params + post copy_cards_forms_path(registration.reg_identifier), copy_cards_form: invalid_params expect(response).to have_http_status(200) expect(response).to render_template("waste_carriers_engine/copy_cards_forms/new") @@ -150,31 +132,21 @@ module WasteCarriersEngine context "when a user is not signed in" do let(:registration) { create(:registration, :has_required_data) } - let(:valid_params) { { reg_identifier: registration[:reg_identifier] } } + let(:valid_params) { { token: registration.reg_identifier } } before(:each) do user = create(:user) sign_out(user) end - it "returns a 302 response" do - post copy_cards_forms_path, renewal_start_form: valid_params - - expect(response).to have_http_status(302) - end + it "returns a 302 response, redirects to the login page and does not create a new transient registration" do + original_tr_count = OrderCopyCardsRegistration.count - it "redirects to the sign in page" do - post copy_cards_forms_path, renewal_start_form: valid_params + post copy_cards_forms_path(registration.reg_identifier), renewal_start_form: valid_params expect(response).to redirect_to(new_user_session_path) - end - - it "does not create a new transient registration" do - original_tr_count = OrderCopyCardsRegistration.count - post copy_cards_forms_path, renewal_start_form: valid_params - updated_tr_count = OrderCopyCardsRegistration.count - - expect(original_tr_count).to eq(updated_tr_count) + expect(response).to have_http_status(302) + expect(OrderCopyCardsRegistration.count).to eq(original_tr_count) end end end diff --git a/spec/requests/waste_carriers_engine/copy_cards_payment_forms_spec.rb b/spec/requests/waste_carriers_engine/copy_cards_payment_forms_spec.rb index 8bb42f7b3..5b0ecc858 100644 --- a/spec/requests/waste_carriers_engine/copy_cards_payment_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/copy_cards_payment_forms_spec.rb @@ -13,50 +13,20 @@ module WasteCarriersEngine end context "when no matching registration exists" do - it "redirects to the invalid reg_identifier error page" do + it "redirects to the invalid token error page" do get new_copy_cards_payment_form_path("CBDU999999999") expect(response).to redirect_to(page_path("invalid")) end end - context "when the reg_identifier doesn't match the format" do - it "redirects to the invalid reg_identifier error page" do - get new_copy_cards_payment_form_path("foo") - expect(response).to redirect_to(page_path("invalid")) - end - end - context "when a matching registration exists" do - before do - order_copy_cards_registration = OrderCopyCardsRegistration.new(reg_identifier: registration.reg_identifier) - order_copy_cards_registration.workflow_state = "copy_cards_payment_form" - order_copy_cards_registration.save - end - - context "when the given registration is not active" do - let(:registration) { create(:registration, :has_required_data, :is_pending) } - - it "redirects to the page" do - get new_copy_cards_payment_form_path(registration.reg_identifier) - - expect(response).to redirect_to(page_path("invalid")) - end - end - - context "when the given registration is active" do - let(:registration) { create(:registration, :has_required_data, :is_active) } - - it "renders the appropriate template" do - get new_copy_cards_payment_form_path(registration.reg_identifier) - - expect(response).to render_template("waste_carriers_engine/copy_cards_payment_forms/new") - end + let(:order_copy_cards_registration) { create(:order_copy_cards_registration, workflow_state: "copy_cards_payment_form") } - it "responds to the GET request with a 200 status code" do - get new_copy_cards_payment_form_path(registration.reg_identifier) + it "renders the appropriate template and responds with a 200 status code" do + get new_copy_cards_payment_form_path(order_copy_cards_registration.token) - expect(response.code).to eq("200") - end + expect(response).to render_template("waste_carriers_engine/copy_cards_payment_forms/new") + expect(response.code).to eq("200") end end end @@ -88,61 +58,33 @@ module WasteCarriersEngine end context "when no matching registration exists" do - let(:invalid_params) { { reg_identifier: "CBDU99999" } } - - it "redirects to the invalid reg_identifier error page" do - post copy_cards_payment_forms_path, copy_cards_payment_form: invalid_params - expect(response).to redirect_to(page_path("invalid")) - end - - it "does not create a new transient registration" do + it "does not create a new transient registration and redirects to the invalid page" do original_tr_count = OrderCopyCardsRegistration.count - post copy_cards_payment_forms_path, copy_cards_payment_form: invalid_params - updated_tr_count = OrderCopyCardsRegistration.count - - expect(original_tr_count).to eq(updated_tr_count) - end - end - context "when the reg_identifier doesn't match the format" do - let(:invalid_params) { { reg_identifier: "foo" } } + post copy_cards_payment_forms_path(token: "CBDU222") - it "redirects to the invalid reg_identifier error page" do - post copy_cards_payment_forms_path, copy_cards_payment_form: invalid_params expect(response).to redirect_to(page_path("invalid")) - end - - it "does not create a new transient registration" do - original_tr_count = OrderCopyCardsRegistration.count - post copy_cards_payment_forms_path, copy_cards_payment_form: invalid_params - updated_tr_count = OrderCopyCardsRegistration.count - - expect(original_tr_count).to eq(updated_tr_count) + expect(OrderCopyCardsRegistration.count).to eq(original_tr_count) end end context "when a matching registration exists" do - let(:transient_registration) { create(:order_copy_cards_registration) } - - before do - transient_registration.workflow_state = "copy_cards_payment_form" - transient_registration.save - end + let(:order_copy_cards_registration) { create(:order_copy_cards_registration, workflow_state: "copy_cards_payment_form") } context "when valid params are submitted" do - let(:valid_params) { { reg_identifier: transient_registration.reg_identifier, temp_payment_method: temp_payment_method } } + let(:valid_params) { { temp_payment_method: temp_payment_method } } context "when the temp payment method is `card`" do let(:temp_payment_method) { "card" } it "updates the transient registration with correct data, returns a 302 response and redirects to the worldpay form" do - post copy_cards_payment_forms_path, copy_cards_payment_form: valid_params + post copy_cards_payment_forms_path(token: order_copy_cards_registration.token), copy_cards_payment_form: valid_params - transient_registration.reload + order_copy_cards_registration.reload - expect(transient_registration.temp_payment_method).to eq("card") + expect(order_copy_cards_registration.temp_payment_method).to eq("card") expect(response).to have_http_status(302) - expect(response).to redirect_to(new_worldpay_form_path(valid_params[:reg_identifier])) + expect(response).to redirect_to(new_worldpay_form_path(order_copy_cards_registration.token)) end end @@ -150,22 +92,22 @@ module WasteCarriersEngine let(:temp_payment_method) { "bank_transfer" } it "updates the transient registration with correct data, returns a 302 response and redirects to the bank transfer form" do - post copy_cards_payment_forms_path, copy_cards_payment_form: valid_params + post copy_cards_payment_forms_path(token: order_copy_cards_registration.token), copy_cards_payment_form: valid_params - transient_registration.reload + order_copy_cards_registration.reload - expect(transient_registration.temp_payment_method).to eq("bank_transfer") + expect(order_copy_cards_registration.temp_payment_method).to eq("bank_transfer") expect(response).to have_http_status(302) - expect(response).to redirect_to(new_copy_cards_bank_transfer_form_path(valid_params[:reg_identifier])) + expect(response).to redirect_to(new_copy_cards_bank_transfer_form_path(order_copy_cards_registration.token)) end end end context "when invalid params are submitted" do - let(:invalid_params) { { reg_identifier: transient_registration.reg_identifier, temp_payment_method: "foo" } } + let(:invalid_params) { { temp_payment_method: "foo" } } it "returns a 200 response and render the new copy cards form" do - post copy_cards_payment_forms_path, copy_cards_payment_form: invalid_params + post copy_cards_payment_forms_path(token: order_copy_cards_registration.token), copy_cards_payment_form: invalid_params expect(response).to have_http_status(200) expect(response).to render_template("waste_carriers_engine/copy_cards_payment_forms/new") @@ -175,22 +117,19 @@ module WasteCarriersEngine end context "when a user is not signed in" do - let(:registration) { create(:registration, :has_required_data) } - let(:valid_params) { { reg_identifier: registration[:reg_identifier] } } - before(:each) do user = create(:user) sign_out(user) end it "returns a 302 response" do - post copy_cards_payment_forms_path, renewal_start_form: valid_params + post copy_cards_payment_forms_path(token: "1234") expect(response).to have_http_status(302) end it "redirects to the sign in page" do - post copy_cards_payment_forms_path, renewal_start_form: valid_params + post copy_cards_payment_forms_path(token: "1234") expect(response).to redirect_to(new_user_session_path) end diff --git a/spec/requests/waste_carriers_engine/declaration_forms_spec.rb b/spec/requests/waste_carriers_engine/declaration_forms_spec.rb index 35cb5e8b7..378af13be 100644 --- a/spec/requests/waste_carriers_engine/declaration_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/declaration_forms_spec.rb @@ -32,20 +32,15 @@ module WasteCarriersEngine workflow_state: "declaration_form") end - let(:params) do - { - reg_identifier: transient_registration.reg_identifier, - declaration: 1 - } - end + let(:params) { { declaration: 1 } } it "creates a new conviction_search_result for the registration" do - post declaration_forms_path, declaration_form: params + post_form_with_params("declaration_form", transient_registration.token, params) expect(transient_registration.reload.conviction_search_result).to_not eq(nil) end it "creates a new conviction_search_result for the key people" do - post declaration_forms_path, declaration_form: params + post_form_with_params("declaration_form", transient_registration.token, params) expect(transient_registration.reload.key_people.first.conviction_search_result).to_not eq(nil) end end @@ -69,13 +64,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_declaration_forms_path(transient_registration[:reg_identifier]) + get back_declaration_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the check_your_answers form" do - get back_declaration_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_check_your_answers_form_path(transient_registration[:reg_identifier])) + get back_declaration_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_check_your_answers_form_path(transient_registration[:token])) end end end @@ -90,13 +85,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_declaration_forms_path(transient_registration[:reg_identifier]) + get back_declaration_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_declaration_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_declaration_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 ac95a892e..c81f819e6 100644 --- a/spec/requests/waste_carriers_engine/declare_convictions_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/declare_convictions_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_declare_convictions_forms_path(transient_registration[:reg_identifier]) + get back_declare_convictions_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the main_people form" do - get back_declare_convictions_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_main_people_form_path(transient_registration[:reg_identifier])) + get back_declare_convictions_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_main_people_form_path(transient_registration[:token])) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_declare_convictions_forms_path(transient_registration[:reg_identifier]) + get back_declare_convictions_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_declare_convictions_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_declare_convictions_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 29b1d18f7..cd36cf1e5 100644 --- a/spec/requests/waste_carriers_engine/location_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/location_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_location_forms_path(transient_registration[:reg_identifier]) + get back_location_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the renewal_start form" do - get back_location_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_location_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_location_forms_path(transient_registration[:reg_identifier]) + get back_location_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_location_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_name_form_path(transient_registration[:reg_identifier])) + get back_location_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_company_name_form_path(transient_registration[:token])) 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 6ac5d82dc..fc8cc3c53 100644 --- a/spec/requests/waste_carriers_engine/main_people_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/main_people_forms_spec.rb @@ -24,7 +24,6 @@ module WasteCarriersEngine context "when valid params are submitted" do let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], first_name: "Foo", last_name: "Bar", dob_day: "1", @@ -35,23 +34,23 @@ module WasteCarriersEngine it "increases the number of key_people" do key_people_count = transient_registration.key_people.count - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.count).to eq(key_people_count + 1) end it "updates the transient registration" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.last.first_name).to eq(valid_params[:first_name]) end it "returns a 302 response" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(response).to have_http_status(302) end it "redirects to the declare_convictions form" do - post main_people_forms_path, main_people_form: valid_params - expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration[:reg_identifier])) + post main_people_forms_path(transient_registration.token), main_people_form: valid_params + expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration[:token])) end context "when there is already a main person" do @@ -63,7 +62,7 @@ module WasteCarriersEngine context "when there can be multiple main people" do it "does not replace the existing main person" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.first.first_name).to eq(existing_main_person.first_name) end end @@ -75,12 +74,12 @@ module WasteCarriersEngine it "does not increase the number of key_people" do key_people_count = transient_registration.key_people.count - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.count).to eq(key_people_count) end it "replaces the existing main person" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.first.first_name).to_not eq(existing_main_person.first_name) end end @@ -96,12 +95,12 @@ module WasteCarriersEngine context "when there can be multiple key people" do it "increases the number of key people" do key_people_count = transient_registration.key_people.count - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.count).to eq(key_people_count + 1) end it "does not replace the relevant conviction person" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.first.first_name).to eq(relevant_conviction_person.first_name) end end @@ -113,17 +112,17 @@ module WasteCarriersEngine it "increases the number of key_people" do key_people_count = transient_registration.key_people.count - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.count).to eq(key_people_count + 1) end it "adds the new main person" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.last.first_name).to eq(valid_params[:first_name]) end it "does not replace the relevant conviction person" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people.first.first_name).to eq(relevant_conviction_person.first_name) end end @@ -131,8 +130,8 @@ module WasteCarriersEngine context "when the submit params say to add another" do it "redirects to the main_people form" do - post main_people_forms_path, main_people_form: valid_params, commit: "Add another person" - expect(response).to redirect_to(new_main_people_form_path(transient_registration[:reg_identifier])) + post main_people_forms_path(transient_registration.token), main_people_form: valid_params, commit: "Add another person" + expect(response).to redirect_to(new_main_people_form_path(transient_registration[:token])) end end end @@ -140,7 +139,6 @@ module WasteCarriersEngine context "when invalid params are submitted" do let(:invalid_params) do { - reg_identifier: "foo", first_name: "", last_name: "", dob_day: "31", @@ -149,14 +147,9 @@ module WasteCarriersEngine } end - it "returns a 302 response" do - post main_people_forms_path, main_people_form: invalid_params - expect(response).to have_http_status(302) - end - it "does not increase the number of key_people" do key_people_count = transient_registration.key_people.count - post main_people_forms_path, main_people_form: invalid_params + post main_people_forms_path(transient_registration.token), main_people_form: invalid_params expect(transient_registration.reload.key_people.count).to eq(key_people_count) end @@ -168,23 +161,15 @@ module WasteCarriersEngine end it "does not replace the existing main person" do - post main_people_forms_path, main_people_form: invalid_params + post main_people_forms_path(transient_registration.token), main_people_form: invalid_params expect(transient_registration.reload.key_people.first.first_name).to eq(existing_main_person.first_name) end end - - context "when the submit params say to add another" do - it "returns a 302 response" do - post main_people_forms_path, main_people_form: invalid_params, commit: "Add another person" - expect(response).to have_http_status(302) - end - end end context "when blank params are submitted" do let(:blank_params) do { - reg_identifier: "foo", first_name: "", last_name: "", dob_day: "", @@ -195,7 +180,7 @@ module WasteCarriersEngine it "does not increase the number of key people" do key_people_count = transient_registration.key_people.count - post main_people_forms_path, main_people_form: blank_params + post main_people_forms_path(transient_registration.token), main_people_form: blank_params expect(transient_registration.reload.key_people.count).to eq(key_people_count) end end @@ -211,7 +196,6 @@ module WasteCarriersEngine let(:valid_params) do { - reg_identifier: transient_registration[:reg_identifier], first_name: "Foo", last_name: "Bar", dob_day: "1", @@ -221,18 +205,18 @@ module WasteCarriersEngine end it "does not update the transient registration" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(transient_registration.reload.key_people).to_not exist end it "returns a 302 response" do - post main_people_forms_path, main_people_form: valid_params + post main_people_forms_path(transient_registration.token), main_people_form: valid_params expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - post main_people_forms_path, main_people_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post main_people_forms_path(transient_registration.token), main_people_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -255,7 +239,7 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_main_people_forms_path(transient_registration[:reg_identifier]) + get back_main_people_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end @@ -263,8 +247,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(addresses: [build(:address, :registered, :from_os_places)]) } it "redirects to the company_address form" do - get back_main_people_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_address_form_path(transient_registration[:reg_identifier])) + get back_main_people_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_company_address_form_path(transient_registration[:token])) end end @@ -272,8 +256,8 @@ module WasteCarriersEngine before(:each) { transient_registration.update_attributes(addresses: [build(:address, :registered, :manual_uk)]) } it "redirects to the company_address_manual form" do - get back_main_people_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:reg_identifier])) + get back_main_people_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_company_address_manual_form_path(transient_registration[:token])) end end end @@ -289,13 +273,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_main_people_forms_path(transient_registration[:reg_identifier]) + get back_main_people_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_main_people_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_main_people_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -327,28 +311,28 @@ module WasteCarriersEngine context "when the delete person action is triggered" do it "returns a 302 response" do - delete delete_person_main_people_forms_path(main_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_main_people_forms_path(main_person_a[:id], token: transient_registration.token) expect(response).to have_http_status(302) end it "redirects to the main people form" do - delete delete_person_main_people_forms_path(main_person_a[:id]), reg_identifier: transient_registration.reg_identifier - expect(response).to redirect_to(new_main_people_form_path(transient_registration[:reg_identifier])) + delete delete_person_main_people_forms_path(main_person_a[:id], token: transient_registration.token) + expect(response).to redirect_to(new_main_people_form_path(transient_registration[:token])) end it "reduces the number of key_people" do key_people_count = transient_registration.key_people.count - delete delete_person_main_people_forms_path(main_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_main_people_forms_path(main_person_a[:id], token: transient_registration.token) expect(transient_registration.reload.key_people.count).to eq(key_people_count - 1) end it "removes the main person" do - delete delete_person_main_people_forms_path(main_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_main_people_forms_path(main_person_a[:id], token: transient_registration.token) expect(transient_registration.reload.key_people.where(id: main_person_a[:id]).count).to eq(0) end it "does not modify the other key_people" do - delete delete_person_main_people_forms_path(main_person_a[:id]), reg_identifier: transient_registration.reg_identifier + delete delete_person_main_people_forms_path(main_person_a[:id], token: transient_registration.token) expect(transient_registration.reload.key_people.where(id: main_person_b[:id]).count).to eq(1) end end 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 8ea28d073..13c42940d 100644 --- a/spec/requests/waste_carriers_engine/other_businesses_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/other_businesses_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_other_businesses_forms_path(transient_registration[:reg_identifier]) + get back_other_businesses_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the tier_check form" do - get back_other_businesses_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_tier_check_form_path(transient_registration[:reg_identifier])) + get back_other_businesses_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_tier_check_form_path(transient_registration[:token])) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_other_businesses_forms_path(transient_registration[:reg_identifier]) + get back_other_businesses_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_other_businesses_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_other_businesses_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 7db0d4abb..bcf51e43d 100644 --- a/spec/requests/waste_carriers_engine/payment_summary_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/payment_summary_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_payment_summary_forms_path(transient_registration[:reg_identifier]) + get back_payment_summary_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the cards form" do - get back_payment_summary_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_cards_form_path(transient_registration[:reg_identifier])) + get back_payment_summary_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_cards_form_path(transient_registration[:token])) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_payment_summary_forms_path(transient_registration[:reg_identifier]) + get back_payment_summary_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_payment_summary_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_payment_summary_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 d18360c4f..8a95741ba 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 @@ -25,13 +25,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_register_in_northern_ireland_forms_path(transient_registration[:reg_identifier]) + get back_register_in_northern_ireland_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the location form" do - get back_register_in_northern_ireland_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_location_form_path(transient_registration[:reg_identifier])) + get back_register_in_northern_ireland_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) end end end @@ -46,13 +46,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_register_in_northern_ireland_forms_path(transient_registration[:reg_identifier]) + get back_register_in_northern_ireland_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_register_in_northern_ireland_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_register_in_northern_ireland_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 dcb6b7414..1e3555fb3 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 @@ -25,13 +25,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_register_in_scotland_forms_path(transient_registration[:reg_identifier]) + get back_register_in_scotland_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the location form" do - get back_register_in_scotland_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_location_form_path(transient_registration[:reg_identifier])) + get back_register_in_scotland_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) end end end @@ -46,13 +46,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_register_in_scotland_forms_path(transient_registration[:reg_identifier]) + get back_register_in_scotland_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_register_in_scotland_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_register_in_scotland_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 34af55451..168a64345 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 @@ -8,85 +8,6 @@ module WasteCarriersEngine include_examples "POST without params form", "register_in_wales_form" - describe "POST 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 valid params are submitted" do - let(:valid_params) do - { - reg_identifier: transient_registration[:reg_identifier] - } - end - - it "returns a 302 response" do - post register_in_wales_forms_path, register_in_wales_form: valid_params - expect(response).to have_http_status(302) - end - - it "redirects to the business_type form" do - post register_in_wales_forms_path, register_in_wales_form: valid_params - expect(response).to redirect_to(new_business_type_form_path(transient_registration[:reg_identifier])) - end - end - - context "when invalid params are submitted" do - let(:invalid_params) do - { - reg_identifier: "foo" - } - end - - it "returns a 302 response" do - post register_in_wales_forms_path, register_in_wales_form: invalid_params - expect(response).to have_http_status(302) - end - - it "does not update the transient registration" do - post register_in_wales_forms_path, register_in_wales_form: invalid_params - expect(transient_registration.reload[:reg_identifier]).to_not eq(invalid_params[:reg_identifier]) - 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 - - let(:valid_params) do - { - reg_identifier: transient_registration[:reg_identifier] - } - end - - it "returns a 302 response" do - post register_in_wales_forms_path, register_in_wales_form: valid_params - expect(response).to have_http_status(302) - end - - it "redirects to the correct form for the state" do - post register_in_wales_forms_path, register_in_wales_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) - end - end - end - end - describe "GET back_register_in_wales_forms_path" do context "when a valid user is signed in" do let(:user) { create(:user) } @@ -104,13 +25,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_register_in_wales_forms_path(transient_registration[:reg_identifier]) + get back_register_in_wales_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the location form" do - get back_register_in_wales_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_location_form_path(transient_registration[:reg_identifier])) + get back_register_in_wales_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) end end end @@ -125,13 +46,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_register_in_wales_forms_path(transient_registration[:reg_identifier]) + get back_register_in_wales_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_register_in_wales_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_register_in_wales_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 fda96244c..585f8f8a3 100644 --- a/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb @@ -26,21 +26,16 @@ module WasteCarriersEngine end context "when valid params are submitted and the company_no is the same as the original registration" do - let(:valid_params) do - { - reg_identifier: transient_registration[:reg_identifier], - company_no: transient_registration[:company_no] - } - end + let(:valid_params) { { company_no: transient_registration[:company_no] } } it "returns a 302 response" do - post registration_number_forms_path, registration_number_form: valid_params + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params expect(response).to have_http_status(302) end it "redirects to the company_name form" do - post registration_number_forms_path, registration_number_form: valid_params - expect(response).to redirect_to(new_company_name_form_path(transient_registration[:reg_identifier])) + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params + expect(response).to redirect_to(new_company_name_form_path(transient_registration[:token])) end context "when the original registration had a shorter variant of the company_no" do @@ -50,57 +45,42 @@ module WasteCarriersEngine end it "returns a 302 response" do - post registration_number_forms_path, registration_number_form: valid_params + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params expect(response).to have_http_status(302) end it "redirects to the company_name form" do - post registration_number_forms_path, registration_number_form: valid_params - expect(response).to redirect_to(new_company_name_form_path(transient_registration[:reg_identifier])) + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params + expect(response).to redirect_to(new_company_name_form_path(transient_registration[:token])) end end end context "when valid params are submitted and the company_no is different to the original registration" do - let(:valid_params) do - { - reg_identifier: transient_registration[:reg_identifier], - company_no: "01234567" - } - end + let(:valid_params) { { company_no: "01234567" } } it "updates the transient registration" do - post registration_number_forms_path, registration_number_form: valid_params + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params expect(transient_registration.reload[:company_no].to_s).to eq(valid_params[:company_no]) end it "returns a 302 response" do - post registration_number_forms_path, registration_number_form: valid_params + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params expect(response).to have_http_status(302) end it "redirects to the cannot_renew_company_no_change form" do - post registration_number_forms_path, registration_number_form: valid_params - expect(response).to redirect_to(new_cannot_renew_company_no_change_form_path(transient_registration[:reg_identifier])) + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params + expect(response).to redirect_to(new_cannot_renew_company_no_change_form_path(transient_registration[:token])) end end context "when invalid params are submitted" do - let(:invalid_params) do - { - reg_identifier: "foo", - company_no: "" - } - end - - it "returns a 302 response" do - post registration_number_forms_path, registration_number_form: invalid_params - expect(response).to have_http_status(302) - end + let(:invalid_params) { { company_no: "" } } it "does not update the transient registration" do - post registration_number_forms_path, registration_number_form: invalid_params - expect(transient_registration.reload[:reg_identifier].to_s).to_not eq(invalid_params[:reg_identifier]) + post registration_number_forms_path(transient_registration[:token]), registration_number_form: invalid_params + expect(transient_registration.reload[:token].to_s).to_not eq(invalid_params[:token]) end end end @@ -113,26 +93,21 @@ module WasteCarriersEngine workflow_state: "renewal_start_form") end - let(:valid_params) do - { - reg_identifier: transient_registration[:reg_identifier], - company_no: "01234567" - } - end + let(:valid_params) { { company_no: "01234567" } } it "does not update the transient registration" do - post registration_number_forms_path, registration_number_form: valid_params + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params expect(transient_registration.reload[:company_no].to_s).to_not eq(valid_params[:company_no]) end it "returns a 302 response" do - post registration_number_forms_path, registration_number_form: valid_params + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - post registration_number_forms_path, registration_number_form: valid_params - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + post registration_number_forms_path(transient_registration[:token]), registration_number_form: valid_params + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end @@ -155,13 +130,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_registration_number_forms_path(transient_registration[:reg_identifier]) + get back_registration_number_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the renewal_information form" do - get back_registration_number_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:reg_identifier])) + get back_registration_number_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_information_form_path(transient_registration[:token])) end end end @@ -176,13 +151,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_registration_number_forms_path(transient_registration[:reg_identifier]) + get back_registration_number_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_registration_number_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_registration_number_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end diff --git a/spec/requests/waste_carriers_engine/renewal_complete_forms_spec.rb b/spec/requests/waste_carriers_engine/renewal_complete_forms_spec.rb index 1203cdcc5..23fd3a5bd 100644 --- a/spec/requests/waste_carriers_engine/renewal_complete_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/renewal_complete_forms_spec.rb @@ -11,27 +11,14 @@ module WasteCarriersEngine sign_in(user) end - context "when no renewal is in progress" do - let(:registration) do - create(:registration, - :has_required_data, - :expires_soon, - account_email: user.email) - end - - it "redirects to the renewal_start_form" do - get new_renewal_complete_form_path(registration.reg_identifier) - expect(response).to redirect_to(new_renewal_start_form_path(registration.reg_identifier)) - end - - it "does not renew the registration" do - old_expires_on = registration.reload.expires_on - get new_renewal_complete_form_path(registration.reg_identifier) - expect(registration.reload.expires_on).to eq(old_expires_on) + context "when no renewing registration exists" do + it "redirects to the invalid page" do + get new_renewal_complete_form_path("wibblewobblejellyonaplate") + expect(response).to redirect_to(page_path("invalid")) end end - context "when a renewal is in progress" do + context "when a valid renewing registration exists" do let(:transient_registration) do create(:renewing_registration, :has_required_data, @@ -43,14 +30,14 @@ module WasteCarriersEngine context "when the workflow_state is correct" do it "loads the page" do - get new_renewal_complete_form_path(transient_registration.reg_identifier) + get new_renewal_complete_form_path(transient_registration.token) expect(response).to have_http_status(200) end it "renews the registration" do registration = Registration.where(reg_identifier: transient_registration.reg_identifier).first old_expires_on = registration.expires_on - get new_renewal_complete_form_path(transient_registration.reg_identifier) + get new_renewal_complete_form_path(transient_registration.token) expect(registration.reload.expires_on).to_not eq(old_expires_on) end end @@ -61,14 +48,14 @@ module WasteCarriersEngine end it "redirects to the correct page" do - get new_renewal_complete_form_path(transient_registration.reg_identifier) - expect(response).to redirect_to(new_payment_summary_form_path(transient_registration.reg_identifier)) + get new_renewal_complete_form_path(transient_registration.token) + expect(response).to redirect_to(new_payment_summary_form_path(transient_registration.token)) end it "does not renew the registration" do registration = Registration.where(reg_identifier: transient_registration.reg_identifier).first old_expires_on = registration.expires_on - get new_renewal_complete_form_path(transient_registration.reg_identifier) + get new_renewal_complete_form_path(transient_registration.token) expect(registration.reload.expires_on).to eq(old_expires_on) 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 4bbdda48e..5f77c8e20 100644 --- a/spec/requests/waste_carriers_engine/renewal_information_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/renewal_information_forms_spec.rb @@ -25,13 +25,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_renewal_information_forms_path(transient_registration[:reg_identifier]) + get back_renewal_information_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the cbd_type form" do - get back_renewal_information_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_cbd_type_form_path(transient_registration[:reg_identifier])) + get back_renewal_information_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_cbd_type_form_path(transient_registration[:token])) end end end @@ -46,13 +46,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_renewal_information_forms_path(transient_registration[:reg_identifier]) + get back_renewal_information_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_renewal_information_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_renewal_information_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end diff --git a/spec/requests/waste_carriers_engine/renewal_start_forms_spec.rb b/spec/requests/waste_carriers_engine/renewal_start_forms_spec.rb index e57fc3a47..a5a3aa8eb 100644 --- a/spec/requests/waste_carriers_engine/renewal_start_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/renewal_start_forms_spec.rb @@ -13,14 +13,14 @@ module WasteCarriersEngine end context "when no matching registration exists" do - it "redirects to the invalid reg_identifier error page" do + it "redirects to the invalid token error page" do get new_renewal_start_form_path("CBDU999999999") expect(response).to redirect_to(page_path("invalid")) end end - context "when the reg_identifier doesn't match the format" do - it "redirects to the invalid reg_identifier error page" do + context "when the token doesn't match the format" do + it "redirects to the invalid token error page" do get new_renewal_start_form_path("foo") expect(response).to redirect_to(page_path("invalid")) end @@ -32,7 +32,7 @@ module WasteCarriersEngine let(:registration) { create(:registration, :has_required_data, :expires_soon, account_email: user.email) } it "returns a success response" do - get new_renewal_start_form_path(registration[:reg_identifier]) + get new_renewal_start_form_path(registration.reg_identifier) expect(response).to have_http_status(200) end @@ -40,7 +40,7 @@ module WasteCarriersEngine before(:each) { registration.update_attributes(expires_on: Date.today - Rails.configuration.grace_window) } it "redirects to the unrenewable error page" do - get new_renewal_start_form_path(registration[:reg_identifier]) + get new_renewal_start_form_path(registration.reg_identifier) expect(response).to redirect_to(page_path("unrenewable")) end end @@ -56,7 +56,7 @@ module WasteCarriersEngine end it "returns a success response" do - get new_renewal_start_form_path(transient_registration[:reg_identifier]) + get new_renewal_start_form_path(transient_registration[:token]) expect(response).to have_http_status(200) end end @@ -70,8 +70,8 @@ module WasteCarriersEngine end it "redirects to the form for the current state" do - get new_renewal_start_form_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_location_form_path(transient_registration[:reg_identifier])) + get new_renewal_start_form_path(transient_registration[:token]) + expect(response).to redirect_to(new_location_form_path(transient_registration[:token])) end end end @@ -87,7 +87,7 @@ module WasteCarriersEngine end it "redirects to the permissions error page" do - get new_renewal_start_form_path(registration[:reg_identifier]) + get new_renewal_start_form_path(registration.reg_identifier) expect(response).to redirect_to(page_path("permission")) end end @@ -101,7 +101,7 @@ module WasteCarriersEngine end it "redirects to the permissions error page" do - get new_renewal_start_form_path(transient_registration[:reg_identifier]) + get new_renewal_start_form_path(transient_registration[:token]) expect(response).to redirect_to(page_path("permission")) end end @@ -136,33 +136,34 @@ module WasteCarriersEngine end context "when no matching registration exists" do - let(:invalid_params) { { reg_identifier: "CBDU99999" } } + let(:invalid_registration) { "CBDU99999" } + + it "redirects to the invalid token error page" do + post renewal_start_forms_path(invalid_registration) - it "redirects to the invalid reg_identifier error page" do - post renewal_start_forms_path, renewal_start_form: invalid_params expect(response).to redirect_to(page_path("invalid")) end it "does not create a new transient registration" do original_tr_count = RenewingRegistration.count - post renewal_start_forms_path, renewal_start_form: invalid_params + post renewal_start_forms_path(invalid_registration) updated_tr_count = RenewingRegistration.count expect(original_tr_count).to eq(updated_tr_count) end end - context "when the reg_identifier doesn't match the format" do - let(:invalid_params) { { reg_identifier: "foo" } } + context "when the token doesn't match the format" do + let(:invalid_renewal) { "foo" } - it "redirects to the invalid reg_identifier error page" do - post renewal_start_forms_path, renewal_start_form: invalid_params + it "redirects to the invalid token error page" do + post renewal_start_forms_path(invalid_renewal) expect(response).to redirect_to(page_path("invalid")) end it "does not create a new transient registration" do original_tr_count = RenewingRegistration.count - post renewal_start_forms_path, renewal_start_form: invalid_params + post renewal_start_forms_path(invalid_renewal) updated_tr_count = RenewingRegistration.count expect(original_tr_count).to eq(updated_tr_count) @@ -181,54 +182,45 @@ module WasteCarriersEngine end context "when valid params are submitted" do - let(:valid_params) { { reg_identifier: registration.reg_identifier } } + let(:valid_registration) { registration.reg_identifier } it "creates a new transient registration" do expected_tr_count = RenewingRegistration.count + 1 - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_registration) updated_tr_count = RenewingRegistration.count expect(expected_tr_count).to eq(updated_tr_count) end it "creates a transient registration with correct data" do - post renewal_start_forms_path, renewal_start_form: valid_params - transient_registration = RenewingRegistration.where(reg_identifier: registration.reg_identifier).first + post renewal_start_forms_path(valid_registration) + transient_registration = RenewingRegistration.where(reg_identifier: valid_registration).first expect(transient_registration.reg_identifier).to eq(registration.reg_identifier) expect(transient_registration.company_name).to eq(registration.company_name) end it "returns a 302 response" do - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_registration) expect(response).to have_http_status(302) end it "redirects to the business type form" do - post renewal_start_forms_path, renewal_start_form: valid_params - expect(response).to redirect_to(new_location_form_path(valid_params[:reg_identifier])) + post renewal_start_forms_path(valid_registration) + transient_registration = RenewingRegistration.where(reg_identifier: valid_registration).first + + expect(response).to redirect_to(new_location_form_path(transient_registration.token)) end context "when the registration cannot be renewed" do before(:each) { registration.update_attributes(expires_on: Date.today - Rails.configuration.grace_window) } it "redirects to the unrenewable error page" do - get new_renewal_start_form_path(registration[:reg_identifier]) + get new_renewal_start_form_path(valid_registration) expect(response).to redirect_to(page_path("unrenewable")) end end end - - context "when invalid params are submitted" do - let(:invalid_params) { { reg_identifier: "foo" } } - - it "does not create a new transient registration" do - original_tr_count = RenewingRegistration.count - post renewal_start_forms_path, renewal_start_form: invalid_params - updated_tr_count = RenewingRegistration.count - expect(original_tr_count).to eq(updated_tr_count) - end - end end end @@ -240,16 +232,16 @@ module WasteCarriersEngine workflow_state: "renewal_start_form") end - let(:valid_params) { { reg_identifier: transient_registration.reg_identifier } } + let(:valid_renewal) { transient_registration.token } it "returns a 302 response" do - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_renewal) expect(response).to have_http_status(302) end it "redirects to the business type form" do - post renewal_start_forms_path, renewal_start_form: valid_params - expect(response).to redirect_to(new_location_form_path(valid_params[:reg_identifier])) + post renewal_start_forms_path(valid_renewal) + expect(response).to redirect_to(new_location_form_path(valid_renewal)) end it "does not create a new transient registration" do @@ -257,7 +249,7 @@ module WasteCarriersEngine transient_registration.touch original_tr_count = RenewingRegistration.count - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_renewal) updated_tr_count = RenewingRegistration.count expect(original_tr_count).to eq(updated_tr_count) @@ -271,16 +263,14 @@ module WasteCarriersEngine workflow_state: "other_businesses_form") end - let(:valid_params) { { reg_identifier: transient_registration.reg_identifier } } - it "returns a 302 response" do - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_renewal) expect(response).to have_http_status(302) end it "redirects to the correct form" do - post renewal_start_forms_path, renewal_start_form: valid_params - expect(response).to redirect_to(new_other_businesses_form_path(valid_params[:reg_identifier])) + post renewal_start_forms_path(valid_renewal) + expect(response).to redirect_to(new_other_businesses_form_path(valid_renewal)) end it "does not create a new transient registration" do @@ -288,7 +278,7 @@ module WasteCarriersEngine transient_registration.touch original_tr_count = RenewingRegistration.count - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_renewal) updated_tr_count = RenewingRegistration.count expect(original_tr_count).to eq(updated_tr_count) @@ -305,10 +295,10 @@ module WasteCarriersEngine :expires_soon, account_email: "not-#{user.email}") end - let(:valid_params) { { reg_identifier: registration.reg_identifier } } + let(:valid_registration) { registration.reg_identifier } it "redirects to the permissions error page" do - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_registration) expect(response).to redirect_to(page_path("permission")) end end @@ -320,10 +310,10 @@ module WasteCarriersEngine account_email: "not-#{user.email}", workflow_state: "renewal_start_form") end - let(:valid_params) { { reg_identifier: transient_registration.reg_identifier } } + let(:valid_renewal) { transient_registration.token } it "redirects to the permissions error page" do - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_renewal) expect(response).to redirect_to(page_path("permission")) end end @@ -332,7 +322,7 @@ module WasteCarriersEngine context "when a user is not signed in" do let(:registration) { create(:registration, :has_required_data) } - let(:valid_params) { { reg_identifier: registration[:reg_identifier] } } + let(:valid_registration) { registration.reg_identifier } before(:each) do user = create(:user) @@ -340,18 +330,18 @@ module WasteCarriersEngine end it "returns a 302 response" do - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_registration) expect(response).to have_http_status(302) end it "redirects to the sign in page" do - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_registration) expect(response).to redirect_to(new_user_session_path) end it "does not create a new transient registration" do original_tr_count = RenewingRegistration.count - post renewal_start_forms_path, renewal_start_form: valid_params + post renewal_start_forms_path(valid_registration) updated_tr_count = RenewingRegistration.count expect(original_tr_count).to eq(updated_tr_count) 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 295398609..da181bb85 100644 --- a/spec/requests/waste_carriers_engine/service_provided_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/service_provided_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_service_provided_forms_path(transient_registration[:reg_identifier]) + get back_service_provided_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the other_businesses form" do - get back_service_provided_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_other_businesses_form_path(transient_registration[:reg_identifier])) + get back_service_provided_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_other_businesses_form_path(transient_registration[:token])) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_service_provided_forms_path(transient_registration[:reg_identifier]) + get back_service_provided_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_service_provided_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_service_provided_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) end end end diff --git a/spec/requests/waste_carriers_engine/tier_check_forms_spec.rb b/spec/requests/waste_carriers_engine/tier_check_forms_spec.rb index 865c7552e..c2da0faf6 100644 --- a/spec/requests/waste_carriers_engine/tier_check_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/tier_check_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_tier_check_forms_path(transient_registration[:reg_identifier]) + get back_tier_check_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the business_type form" do - get back_tier_check_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_business_type_form_path(transient_registration[:reg_identifier])) + get back_tier_check_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_business_type_form_path(transient_registration[:token])) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_tier_check_forms_path(transient_registration[:reg_identifier]) + get back_tier_check_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_tier_check_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_tier_check_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 82a4c6526..9b2f361f7 100644 --- a/spec/requests/waste_carriers_engine/waste_types_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/waste_types_forms_spec.rb @@ -29,13 +29,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_waste_types_forms_path(transient_registration[:reg_identifier]) + get back_waste_types_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the service_provided form" do - get back_waste_types_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_service_provided_form_path(transient_registration[:reg_identifier])) + get back_waste_types_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_service_provided_form_path(transient_registration[:token])) end end end @@ -50,13 +50,13 @@ module WasteCarriersEngine context "when the back action is triggered" do it "returns a 302 response" do - get back_waste_types_forms_path(transient_registration[:reg_identifier]) + get back_waste_types_forms_path(transient_registration[:token]) expect(response).to have_http_status(302) end it "redirects to the correct form for the state" do - get back_waste_types_forms_path(transient_registration[:reg_identifier]) - expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:reg_identifier])) + get back_waste_types_forms_path(transient_registration[:token]) + expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token])) 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 12131fa3a..d38c387c3 100644 --- a/spec/requests/waste_carriers_engine/worldpay_forms_spec.rb +++ b/spec/requests/waste_carriers_engine/worldpay_forms_spec.rb @@ -20,19 +20,19 @@ module WasteCarriersEngine account_email: user.email, workflow_state: "worldpay_form") end - let(:reg_id) { transient_registration[:reg_identifier] } + let(:token) { transient_registration[:token] } describe "#new" do it "redirects to worldpay", vcr: true do VCR.use_cassette("worldpay_redirect") do - get new_worldpay_form_path(reg_id) + get new_worldpay_form_path(token) expect(response.location).to include("https://secure-test.worldpay.com") end end it "creates a new finance_details" do VCR.use_cassette("worldpay_redirect") do - get new_worldpay_form_path(reg_id) + get new_worldpay_form_path(token) expect(transient_registration.reload.finance_details).to_not eq(nil) end end @@ -43,8 +43,8 @@ module WasteCarriersEngine end it "redirects to payment_summary_form" do - get new_worldpay_form_path(reg_id) - expect(response).to redirect_to(new_payment_summary_form_path(reg_id)) + get new_worldpay_form_path(token) + expect(response).to redirect_to(new_payment_summary_form_path(token)) end end end @@ -61,7 +61,7 @@ module WasteCarriersEngine let(:params) do { orderKey: "#{Rails.configuration.worldpay_admin_code}^#{Rails.configuration.worldpay_merchantcode}^#{order.order_code}", - reg_identifier: reg_id + token: token } end @@ -72,8 +72,8 @@ module WasteCarriersEngine end it "redirects to renewal_complete_form" do - get success_worldpay_forms_path(reg_id), params - expect(response).to redirect_to(new_renewal_complete_form_path(reg_id)) + get success_worldpay_forms_path(token), params + expect(response).to redirect_to(new_renewal_complete_form_path(token)) end it "updates the transient registration metadata attributes from application configuration" do @@ -81,7 +81,7 @@ module WasteCarriersEngine expect(transient_registration.reload.metaData.route).to be_nil - get success_worldpay_forms_path(reg_id), params + get success_worldpay_forms_path(token), params expect(transient_registration.reload.metaData.route).to eq("ASSISTED_DIGITAL") end @@ -92,8 +92,8 @@ module WasteCarriersEngine end it "redirects to renewal_received_form" do - get success_worldpay_forms_path(reg_id), params - expect(response).to redirect_to(new_renewal_received_form_path(reg_id)) + get success_worldpay_forms_path(token), params + expect(response).to redirect_to(new_renewal_received_form_path(token)) end it "updates the transient registration metadata attributes from application configuration" do @@ -101,7 +101,7 @@ module WasteCarriersEngine expect(transient_registration.reload.metaData.route).to be_nil - get success_worldpay_forms_path(reg_id), params + get success_worldpay_forms_path(token), params expect(transient_registration.reload.metaData.route).to eq("ASSISTED_DIGITAL") end @@ -113,7 +113,7 @@ module WasteCarriersEngine end it "does not raise an error" do - expect { get success_worldpay_forms_path(reg_id), params }.to_not raise_error + expect { get success_worldpay_forms_path(token), params }.to_not raise_error end end end @@ -125,8 +125,8 @@ module WasteCarriersEngine end it "redirects to payment_summary_form" do - get success_worldpay_forms_path(reg_id), params - expect(response).to redirect_to(new_payment_summary_form_path(reg_id)) + get success_worldpay_forms_path(token), params + expect(response).to redirect_to(new_payment_summary_form_path(token)) end end @@ -136,13 +136,13 @@ module WasteCarriersEngine end it "redirects to payment_summary_form" do - get success_worldpay_forms_path(reg_id), params - expect(response).to redirect_to(new_payment_summary_form_path(reg_id)) + get success_worldpay_forms_path(token), params + expect(response).to redirect_to(new_payment_summary_form_path(token)) end it "does not update the payment" do unmodified_payment = transient_registration.finance_details.payments.first - get success_worldpay_forms_path(reg_id), params + get success_worldpay_forms_path(token), params expect(transient_registration.reload.finance_details.payments.first).to eq(unmodified_payment) end end @@ -160,7 +160,7 @@ module WasteCarriersEngine let(:params) do { orderKey: "#{Rails.configuration.worldpay_admin_code}^#{Rails.configuration.worldpay_merchantcode}^#{order.order_code}", - reg_identifier: reg_id + token: token } end @@ -171,8 +171,8 @@ module WasteCarriersEngine end it "redirects to renewal_received_form" do - get pending_worldpay_forms_path(reg_id), params - expect(response).to redirect_to(new_renewal_received_form_path(reg_id)) + get pending_worldpay_forms_path(token), params + expect(response).to redirect_to(new_renewal_received_form_path(token)) end end @@ -182,8 +182,8 @@ module WasteCarriersEngine end it "redirects to payment_summary_form" do - get pending_worldpay_forms_path(reg_id), params - expect(response).to redirect_to(new_payment_summary_form_path(reg_id)) + get pending_worldpay_forms_path(token), params + expect(response).to redirect_to(new_payment_summary_form_path(token)) end end end diff --git a/spec/services/waste_carriers_engine/worldpay_url_service_spec.rb b/spec/services/waste_carriers_engine/worldpay_url_service_spec.rb index 5c44696c0..8dabd7fa9 100644 --- a/spec/services/waste_carriers_engine/worldpay_url_service_spec.rb +++ b/spec/services/waste_carriers_engine/worldpay_url_service_spec.rb @@ -12,9 +12,9 @@ module WasteCarriersEngine create(:renewing_registration, :has_required_data) end - let(:reg_id) { transient_registration.reg_identifier } + let(:token) { transient_registration.token } let(:link_base) { "https://secure-test.worldpay.com/wcc/dispatcher?OrderKey=" } - let(:worldpay_url_service) { WorldpayUrlService.new(reg_id, link_base) } + let(:worldpay_url_service) { WorldpayUrlService.new(token, link_base) } describe "format_url" do let(:url) { worldpay_url_service.format_link } @@ -25,27 +25,27 @@ module WasteCarriersEngine end it "includes the success URL" do - success_url = "&successURL=" + CGI.escape("#{root}/worldpay/success/#{reg_id}") + success_url = "&successURL=" + CGI.escape("#{root}/#{token}/worldpay/success") expect(url).to include(success_url) end it "includes the pending URL" do - pending_url = "&pendingURL=" + CGI.escape("#{root}/worldpay/pending/#{reg_id}") + pending_url = "&pendingURL=" + CGI.escape("#{root}/#{token}/worldpay/pending") expect(url).to include(pending_url) end it "includes the failure URL" do - failure_url = "&failureURL=" + CGI.escape("#{root}/worldpay/failure/#{reg_id}") + failure_url = "&failureURL=" + CGI.escape("#{root}/#{token}/worldpay/failure") expect(url).to include(failure_url) end it "includes the cancel URL" do - cancel_url = "&cancelURL=" + CGI.escape("#{root}/worldpay/cancel/#{reg_id}") + cancel_url = "&cancelURL=" + CGI.escape("#{root}/#{token}/worldpay/cancel") expect(url).to include(cancel_url) end it "includes the error URL" do - error_url = "&errorURL=" + CGI.escape("#{root}/worldpay/error/#{reg_id}") + error_url = "&errorURL=" + CGI.escape("#{root}/#{token}/worldpay/error") expect(url).to include(error_url) end end diff --git a/spec/support/form_request_helpers.rb b/spec/support/form_request_helpers.rb index aeaffd7fc..4ac7a868c 100644 --- a/spec/support/form_request_helpers.rb +++ b/spec/support/form_request_helpers.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true module FormRequestHelpers - def post_form_with_params(form, params) - post create_path_for(form), params_for_form(form, params) + def post_form_with_params(form, token, params = {}) + post create_path_for(form, token), params_for_form(form, params) end # Should call a method like location_forms_path - def create_path_for(form) - send("#{form}s_path") + def create_path_for(form, token) + public_send("#{form}s_path", token) end # Should output a hash like { location_forms: params } diff --git a/spec/support/shared_examples/having_a_secure_token.rb b/spec/support/shared_examples/having_a_secure_token.rb new file mode 100644 index 000000000..19de66782 --- /dev/null +++ b/spec/support/shared_examples/having_a_secure_token.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +RSpec.shared_examples "Having a secure token" do + let(:transient_registration) { build(:transient_registration) } + + it "generates a unique secure token when saved" do + expect(transient_registration.token).to be_nil + + transient_registration.save + + expect(transient_registration.reload.token).to_not be_nil + end +end diff --git a/spec/support/shared_examples/post_form.rb b/spec/support/shared_examples/post_form.rb index 20ee61d21..c58522754 100644 --- a/spec/support/shared_examples/post_form.rb +++ b/spec/support/shared_examples/post_form.rb @@ -18,7 +18,7 @@ sign_in(user) end - context "when no renewal is in progress" do + context "when no transient registration is found" do let(:registration) do create(:registration, :has_required_data, @@ -26,19 +26,18 @@ account_email: user.email) end - let(:params) do - { reg_identifier: registration.reg_identifier } - end + it "redirects to the incalid page" do + post_form_with_params(form, "foo") - it "redirects to the renewal_start_form" do - post_form_with_params(form, params) - expect(response).to redirect_to(new_renewal_start_form_path(registration[:reg_identifier])) + expect(response).to redirect_to(page_path("invalid")) end it "does not create a transient registration" do - post_form_with_params(form, params) - matching_transient_regs = WasteCarriersEngine::RenewingRegistration.where(reg_identifier: registration.reg_identifier) - expect(matching_transient_regs.length).to eq(0) + count = WasteCarriersEngine::TransientRegistration.count + + post_form_with_params(form, "foo") + + expect(WasteCarriersEngine::TransientRegistration.count).to eq(count) end end @@ -52,7 +51,6 @@ context "when the workflow_state matches the requested form" do before do transient_registration.update_attributes(workflow_state: form) - valid_params[:reg_identifier] = transient_registration.reg_identifier end context "when the params are valid" do @@ -61,35 +59,31 @@ # Otherwise, expect the value submitted in params expected_value = valid_params[test_attribute] unless expected_value.present? - post_form_with_params(form, valid_params) + post_form_with_params(form, transient_registration.token, valid_params) expect(transient_registration.reload[test_attribute]).to eq(expected_value) end it "changes the workflow_state" do state_before_request = transient_registration[:workflow_state] - post_form_with_params(form, valid_params) + post_form_with_params(form, transient_registration.token, valid_params) expect(transient_registration.reload[:workflow_state]).to_not eq(state_before_request) end it "redirects to the next page" do - post_form_with_params(form, valid_params) + post_form_with_params(form, transient_registration.token, valid_params) expect(response).to have_http_status(302) end end context "when the params are invalid" do - before do - invalid_params[:reg_identifier] = transient_registration.reg_identifier - end - it "does not update the transient registration, including workflow_state" do transient_reg_before_submitting = transient_registration - post_form_with_params(form, invalid_params) + post_form_with_params(form, transient_registration.token, invalid_params) expect(transient_registration.reload).to eq(transient_reg_before_submitting) end it "show the form again" do - post_form_with_params(form, invalid_params) + post_form_with_params(form, transient_registration.token, invalid_params) expect(response).to render_template("#{form}s/new") end end @@ -98,40 +92,23 @@ it "does not throw an error" do # rubocop:disable Style/BlockDelimiters expect { - post_form_with_params(form, reg_identifier: transient_registration.reg_identifier) + post_form_with_params(form, transient_registration.token) }.not_to raise_error # rubocop:enable Style/BlockDelimiters end end - context "when the reg_identifier is invalid" do - before do - valid_params[:reg_identifier] = "foo" - end - - it "does not update the transient_registration, including workflow_state" do - transient_reg_before_submitting = transient_registration - post_form_with_params(form, valid_params) - expect(transient_registration.reload).to eq(transient_reg_before_submitting) - end - - it "redirects to the invalid reg_identifier error page" do - post_form_with_params(form, valid_params) - expect(response).to redirect_to(page_path("invalid")) - end - end - context "when the registration cannot be renewed" do before { transient_registration.update_attributes(expires_on: Date.today - Rails.configuration.grace_window) } it "does not update the transient registration, including workflow_state" do transient_reg_before_submitting = transient_registration - post_form_with_params(form, valid_params) + post_form_with_params(form, transient_registration.token, valid_params) expect(transient_registration.reload).to eq(transient_reg_before_submitting) end it "redirects to the unrenewable error page" do - post_form_with_params(form, valid_params) + post_form_with_params(form, transient_registration.token, valid_params) expect(response).to redirect_to(page_path("unrenewable")) end end @@ -147,20 +124,17 @@ "payment_summary_form" end transient_registration.update_attributes(workflow_state: different_state) - - # We should submit valid params so we don't trigger the wrong error - valid_params[:reg_identifier] = transient_registration.reg_identifier end it "does not update the transient_registration, including workflow_state" do transient_reg_before_submitting = transient_registration - post_form_with_params(form, valid_params) + post_form_with_params(form, transient_registration.token, valid_params) expect(transient_registration.reload).to eq(transient_reg_before_submitting) end it "redirects to the correct form for the workflow_state" do workflow_state = transient_registration[:workflow_state] - post_form_with_params(form, valid_params) + post_form_with_params(form, transient_registration.token, valid_params) expect(response).to redirect_to(new_path_for(workflow_state, transient_registration)) end end @@ -169,7 +143,6 @@ # Should call a method like new_location_form_path("CBDU1234") def new_path_for(form, transient_registration) - reg_id = transient_registration[:reg_identifier] if transient_registration.present? - send("new_#{form}_path", reg_id) + send("new_#{form}_path", transient_registration.token) end end diff --git a/spec/support/shared_examples/request_post_no_params_form.rb b/spec/support/shared_examples/post_without_params_form.rb similarity index 63% rename from spec/support/shared_examples/request_post_no_params_form.rb rename to spec/support/shared_examples/post_without_params_form.rb index 37530420c..e59e667ea 100644 --- a/spec/support/shared_examples/request_post_no_params_form.rb +++ b/spec/support/shared_examples/post_without_params_form.rb @@ -13,27 +13,11 @@ sign_in(user) end - context "when no renewal is in progress" do - let(:registration) do - create(:registration, - :has_required_data, - :expires_soon, - account_email: user.email) - end - - let(:params) do - { reg_identifier: registration.reg_identifier } - end - - it "redirects to the renewal_start_form" do - post_form_with_params(form, params) - expect(response).to redirect_to(new_renewal_start_form_path(registration[:reg_identifier])) - end + context "when the token is invalid" do + it "redirects to the invalid page" do + post_form_with_params(form, "foo") - it "does not create a transient registration" do - post_form_with_params(form, params) - matching_transient_regs = WasteCarriersEngine::RenewingRegistration.where(reg_identifier: registration.reg_identifier) - expect(matching_transient_regs.length).to eq(0) + expect(response).to redirect_to(page_path("invalid")) end end @@ -47,10 +31,6 @@ account_email: user.email) end - let(:params) do - { reg_identifier: transient_registration.reg_identifier } - end - context "when the workflow_state matches the requested form" do before do transient_registration.update_attributes(workflow_state: form) @@ -59,29 +39,20 @@ context "when the params are valid" do it "changes the workflow_state" do state_before_request = transient_registration[:workflow_state] - post_form_with_params(form, params) + post_form_with_params(form, transient_registration.token) expect(transient_registration.reload[:workflow_state]).to_not eq(state_before_request) end it "redirects to the next page" do - post_form_with_params(form, params) + post_form_with_params(form, transient_registration.token) expect(response).to have_http_status(302) end end - context "when the reg_identifier is invalid" do - before do - params[:reg_identifier] = "foo" - end + context "when the token is invalid" do + it "redirects to the invalid error page" do + post_form_with_params(form, "foo") - it "does not update the transient_registration, including workflow_state" do - transient_reg_before_submitting = transient_registration - post_form_with_params(form, params) - expect(transient_registration.reload).to eq(transient_reg_before_submitting) - end - - it "redirects to the invalid reg_identifier error page" do - post_form_with_params(form, params) expect(response).to redirect_to(page_path("invalid")) end end @@ -91,12 +62,12 @@ it "does not update the transient registration, including workflow_state" do transient_reg_before_submitting = transient_registration - post_form_with_params(form, params) + post_form_with_params(form, transient_registration.token) expect(transient_registration.reload).to eq(transient_reg_before_submitting) end it "redirects to the unrenewable error page" do - post_form_with_params(form, params) + post_form_with_params(form, transient_registration.token) expect(response).to redirect_to(page_path("unrenewable")) end end @@ -112,20 +83,17 @@ "payment_summary_form" end transient_registration.update_attributes(workflow_state: different_state) - - # We should submit valid params so we don't trigger the wrong error - params[:reg_identifier] = transient_registration.reg_identifier end it "does not update the transient_registration, including workflow_state" do transient_reg_before_submitting = transient_registration - post_form_with_params(form, params) + post_form_with_params(form, transient_registration.token) expect(transient_registration.reload).to eq(transient_reg_before_submitting) end it "redirects to the correct form for the workflow_state" do workflow_state = transient_registration[:workflow_state] - post_form_with_params(form, params) + post_form_with_params(form, transient_registration.token) expect(response).to redirect_to(new_path_for(workflow_state, transient_registration)) end end diff --git a/spec/support/shared_examples/request_get_flexible_form.rb b/spec/support/shared_examples/request_get_flexible_form.rb index 2833ed7d8..5799b323d 100644 --- a/spec/support/shared_examples/request_get_flexible_form.rb +++ b/spec/support/shared_examples/request_get_flexible_form.rb @@ -13,20 +13,6 @@ sign_in(user) end - context "when no renewal is in progress" do - let(:registration) do - create(:registration, - :has_required_data, - :expires_soon, - account_email: user.email) - end - - it "redirects to the renewal_start_form" do - get new_path_for(form, registration) - expect(response).to redirect_to(new_renewal_start_form_path(registration[:reg_identifier])) - end - end - context "when a renewal is in progress" do let(:transient_registration) do create(:renewing_registration, @@ -97,7 +83,6 @@ # Should call a method like new_location_form_path("CBDU1234") def new_path_for(form, transient_registration) - reg_id = transient_registration[:reg_identifier] if transient_registration.present? - send("new_#{form}_path", reg_id) + send("new_#{form}_path", transient_registration.token) end end diff --git a/spec/support/shared_examples/request_get_locked_in_form.rb b/spec/support/shared_examples/request_get_locked_in_form.rb index 545b7823d..71ea5351f 100644 --- a/spec/support/shared_examples/request_get_locked_in_form.rb +++ b/spec/support/shared_examples/request_get_locked_in_form.rb @@ -13,20 +13,6 @@ sign_in(user) end - context "when no renewal is in progress" do - let(:registration) do - create(:registration, - :has_required_data, - :expires_soon, - account_email: user.email) - end - - it "redirects to the renewal_start_form" do - get new_path_for(form, registration) - expect(response).to redirect_to(new_renewal_start_form_path(registration[:reg_identifier])) - end - end - context "when a renewal is in progress" do let(:transient_registration) do create(:renewing_registration, @@ -98,7 +84,6 @@ # Should call a method like new_location_form_path("CBDU1234") def new_path_for(form, transient_registration) - reg_id = transient_registration[:reg_identifier] if transient_registration.present? - send("new_#{form}_path", reg_id) + public_send("new_#{form}_path", transient_registration.token) end end 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 64325b4ef..8940fb494 100644 --- a/spec/support/shared_examples/request_get_unsuccessful_worldpay_response.rb +++ b/spec/support/shared_examples/request_get_unsuccessful_worldpay_response.rb @@ -17,7 +17,7 @@ account_email: user.email, workflow_state: "worldpay_form") end - let(:reg_id) { transient_registration[:reg_identifier] } + let(:token) { transient_registration.token } before do transient_registration.prepare_for_payment(:worldpay, user) @@ -29,15 +29,14 @@ let(:params) do { - orderKey: "#{Rails.configuration.worldpay_admin_code}^#{Rails.configuration.worldpay_merchantcode}^#{order.order_code}", - reg_identifier: reg_id + orderKey: "#{Rails.configuration.worldpay_admin_code}^#{Rails.configuration.worldpay_merchantcode}^#{order.order_code}" } end let(:validation_action) { "valid_#{action}?".to_sym } let(:path) do path_route = "#{action}_worldpay_forms_path".to_sym - public_send(path_route, reg_id) + public_send(path_route, token) end context "when the params are valid" do @@ -47,7 +46,7 @@ it "redirects to payment_summary_form" do get path, params - expect(response).to redirect_to(new_payment_summary_form_path(reg_id)) + expect(response).to redirect_to(new_payment_summary_form_path(token)) end end @@ -58,7 +57,7 @@ it "redirects to payment_summary_form" do get path, params - expect(response).to redirect_to(new_payment_summary_form_path(reg_id)) + expect(response).to redirect_to(new_payment_summary_form_path(token)) end end end