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_payment_forms_controller.rb b/app/controllers/waste_carriers_engine/copy_cards_payment_forms_controller.rb
index 9581b784d..d19e38eb2 100644
--- a/app/controllers/waste_carriers_engine/copy_cards_payment_forms_controller.rb
+++ b/app/controllers/waste_carriers_engine/copy_cards_payment_forms_controller.rb
@@ -1,7 +1,9 @@
# frozen_string_literal: true
module WasteCarriersEngine
- class CopyCardsPaymentFormsController < BaseOrderCopyCardsFormsController
+ class CopyCardsPaymentFormsController < FormsController
+ include OrderCopyCardsPermissionChecks
+
def new
super(CopyCardsPaymentForm, "copy_cards_payment_form")
end
diff --git a/app/controllers/waste_carriers_engine/forms_controller.rb b/app/controllers/waste_carriers_engine/forms_controller.rb
index 8c06a16ea..0248c3f5b 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,19 @@ def transient_registration_attributes
params.permit
end
- def find_or_initialize_transient_registration(reg_identifier)
- @transient_registration = RenewingRegistration.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
+
+ def find_or_initialize_transient_registration(token)
+ @transient_registration ||= TransientRegistration.where(token: token).first
end
# 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 +73,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/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..19fe0cbe7 100644
--- a/app/forms/waste_carriers_engine/base_form.rb
+++ b/app/forms/waste_carriers_engine/base_form.rb
@@ -9,9 +9,13 @@ 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..dc717578e 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(reg_identifier)
+ # TODO: Downtime at deploy when releaasing token?
+ @transient_registration = RenewingRegistration.where(token: reg_identifier).first ||
+ RenewingRegistration.new(reg_identifier: reg_identifier)
+ 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..72e1ba1e7
--- /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 = SecureRandom.base64(24)
+ 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/views/waste_carriers_engine/bank_transfer_forms/new.html.erb b/app/views/waste_carriers_engine/bank_transfer_forms/new.html.erb
index 26008d010..c0963e0a1 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
@@ -105,7 +105,7 @@
- <%= f.hidden_field :reg_identifier, value: @bank_transfer_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @bank_transfer_form.token %>
<%= 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..3374f2059 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
@@ -49,7 +49,7 @@
- <%= f.hidden_field :reg_identifier, value: @cbd_type_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @cbd_type_form.token %>
<%= 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..a88796079 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
@@ -21,7 +21,7 @@
- <%= f.hidden_field :reg_identifier, value: @company_name_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @company_name_form.token %>
<%= 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..a8f05db50 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
@@ -25,7 +25,7 @@
- <%= f.hidden_field :reg_identifier, value: @company_postcode_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @company_postcode_form.token %>
<%= 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..42f97f851 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
@@ -40,7 +40,7 @@
- <%= f.hidden_field :reg_identifier, value: @construction_demolition_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @construction_demolition_form.token %>
<%= 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..a2b5331bf 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
@@ -20,7 +20,7 @@
<%= 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.hidden_field :token, value: @contact_address_form.token %>
<%= 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..38165a8eb 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
@@ -25,7 +25,7 @@
<%= 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.hidden_field :token, value: @contact_address_manual_form.token %>
<%= 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..73e237877 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
@@ -32,7 +32,7 @@
- <%= f.hidden_field :reg_identifier, value: @contact_email_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @contact_email_form.token %>
<%= 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..f56b8cc29 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
@@ -30,7 +30,7 @@
- <%= f.hidden_field :reg_identifier, value: @contact_name_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @contact_name_form.token %>
<%= 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..f1a995aa6 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
@@ -21,7 +21,7 @@
- <%= f.hidden_field :reg_identifier, value: @contact_phone_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @contact_phone_form.token %>
<%= 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..e1581a344 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
@@ -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/declaration_forms/new.html.erb b/app/views/waste_carriers_engine/declaration_forms/new.html.erb
index 1733115d1..8e5fd097a 100644
--- a/app/views/waste_carriers_engine/declaration_forms/new.html.erb
+++ b/app/views/waste_carriers_engine/declaration_forms/new.html.erb
@@ -25,7 +25,7 @@
<%= link_to t(".privacy_link_text"), page_path("privacy"), target: "_blank" %>
- <%= f.hidden_field :reg_identifier, value: @declaration_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @declaration_form.token %>
<%= 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..f91989501 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
@@ -48,7 +48,7 @@
- <%= f.hidden_field :reg_identifier, value: @declare_convictions_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @declare_convictions_form.token %>
<%= 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..ea22b2207 100644
--- a/app/views/waste_carriers_engine/location_forms/new.html.erb
+++ b/app/views/waste_carriers_engine/location_forms/new.html.erb
@@ -50,7 +50,7 @@
- <%= f.hidden_field :reg_identifier, value: @location_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @location_form.token %>
<%= 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..3c32a4070 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,7 +9,7 @@
<%= render("waste_carriers_engine/shared/dob", form: @main_people_form, f: f) %>
- <%= f.hidden_field :reg_identifier, value: @main_people_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @main_people_form.token %>
<% if @main_people_form.can_only_have_one_main_person? %>
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..e6e802019 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
@@ -28,7 +28,7 @@
- <%= f.hidden_field :reg_identifier, value: @other_businesses_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @other_businesses_form.token %>
<%= 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..d2ddab849 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
@@ -75,7 +75,7 @@
- <%= f.hidden_field :reg_identifier, value: @payment_summary_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @payment_summary_form.token %>
- <%= f.hidden_field :reg_identifier, value: @register_in_northern_ireland_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @register_in_northern_ireland_form.token %>
- <%= f.hidden_field :reg_identifier, value: @register_in_scotland_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @register_in_scotland_form.token %>
<%= 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..644fe6eb6 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
@@ -12,7 +12,7 @@
<%= t(".paragraph_3") %>
- <%= f.hidden_field :reg_identifier, value: @register_in_wales_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @register_in_wales_form.token %>
<%= 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..a7df5f1eb 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
@@ -39,7 +39,7 @@
<%= t(".explanation.#{@registration_number_form.business_type}") %>
- <%= f.hidden_field :reg_identifier, value: @registration_number_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @registration_number_form.token %>
<%= 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..b91d5b470 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,7 @@
<%= 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 %>
+ <%= f.hidden_field :token, value: @renewal_complete_form.token %>
<%= 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..c6a4a43e7 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
@@ -28,7 +28,7 @@
<%= 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.hidden_field :token, value: @renewal_information_form.token %>
<%= 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..1e80c96f7 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,7 @@
<%= 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 %>
+ <%= f.hidden_field :token, value: @renewal_received_form.token %>
<%= 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..63d087ef9 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,7 @@
<% end %>
- <%= f.hidden_field :reg_identifier, value: @renewal_start_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @renewal_start_form.token %>
<%= 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..5493cabea 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
@@ -27,7 +27,7 @@
- <%= f.hidden_field :reg_identifier, value: @service_provided_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @service_provided_form.token %>
- <%= f.hidden_field :reg_identifier, value: @waste_types_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @waste_types_form.token %>
<%= 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..88deab2be 100644
--- a/app/views/waste_carriers_engine/worldpay_forms/new.html.erb
+++ b/app/views/waste_carriers_engine/worldpay_forms/new.html.erb
@@ -18,7 +18,7 @@
<%= t(".paragraph_3") %>
<%= t(".paragraph_4") %>
- <%= f.hidden_field :reg_identifier, value: @worldpay_form.reg_identifier %>
+ <%= f.hidden_field :token, value: @worldpay_form.token %>
<%= f.submit t(".next_button"), class: "button" %>
diff --git a/config/routes.rb b/config/routes.rb
index af2ea6f75..040b66821 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
+ path_names: { new: "" }
+
+ scope "/:token" do
+ 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..2b8b9080c 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) { { token: "foo" } }
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..449536762 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) { { token: "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..2fe9e024a 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) { { token: "foo" } }
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..77c468ef2 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) { { token: "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..373cd420a 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) { { token: "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..dfdcd5151 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) { { token: "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..eb0335606 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) { { token: "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..a4c37e262 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) { { token: "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..b948fbc98 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) { { token: "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..f5c3cb208 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,7 @@ module WasteCarriersEngine
context "when invalid params are submitted" do
let(:invalid_params) do
{
- reg_identifier: "foo",
+ token: "foo",
first_name: "",
last_name: "",
dob_day: "31",
@@ -114,13 +113,13 @@ module WasteCarriersEngine
end
it "returns a 302 response" 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(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,14 +131,14 @@ 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"
+ post conviction_details_forms_path(transient_registration.token), conviction_details_form: invalid_params, commit: "Add another person"
expect(response).to have_http_status(302)
end
end
@@ -148,7 +147,7 @@ module WasteCarriersEngine
context "when blank params are submitted" do
let(:blank_params) do
{
- reg_identifier: "foo",
+ token: "foo",
first_name: "",
last_name: "",
position: "",
@@ -160,7 +159,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 +175,7 @@ module WasteCarriersEngine
let(:valid_params) do
{
- reg_identifier: transient_registration[:reg_identifier],
+ token: transient_registration[:token],
first_name: "Foo",
last_name: "Bar",
position: "Baz",
@@ -187,18 +186,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 +220,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 +241,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 +279,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..d34f3b972 100644
--- a/spec/requests/waste_carriers_engine/copy_cards_forms_spec.rb
+++ b/spec/requests/waste_carriers_engine/copy_cards_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_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
@@ -31,7 +31,7 @@ module WasteCarriersEngine
let(:registration) { create(:registration, :has_required_data, :is_pending) }
it "redirects to the page" do
- get new_copy_cards_form_path(registration.reg_identifier)
+ get new_copy_cards_form_path(registration.token)
expect(response).to redirect_to(page_path("invalid"))
end
@@ -41,13 +41,13 @@ module WasteCarriersEngine
let(:registration) { create(:registration, :has_required_data, :is_active) }
it "renders the appropriate template" do
- get new_copy_cards_form_path(registration.reg_identifier)
+ get new_copy_cards_form_path(registration.token)
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)
+ get new_copy_cards_form_path(registration.token)
expect(response.code).to eq("200")
end
@@ -82,9 +82,9 @@ module WasteCarriersEngine
end
context "when no matching registration exists" do
- let(:invalid_params) { { reg_identifier: "CBDU99999" } }
+ let(:invalid_params) { { token: "CBDU99999" } }
- it "redirects to the invalid reg_identifier error page" do
+ it "redirects to the invalid token error page" do
post copy_cards_forms_path, copy_cards_form: invalid_params
expect(response).to redirect_to(page_path("invalid"))
end
@@ -98,10 +98,10 @@ module WasteCarriersEngine
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_params) { { token: "foo" } }
- it "redirects to the invalid reg_identifier error page" do
+ it "redirects to the invalid token error page" do
post copy_cards_forms_path, copy_cards_form: invalid_params
expect(response).to redirect_to(page_path("invalid"))
end
@@ -119,24 +119,24 @@ 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.token, 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
- transient_registration = OrderCopyCardsRegistration.find_by(reg_identifier: registration.reg_identifier)
+ transient_registration = OrderCopyCardsRegistration.find_by(token: registration.token)
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(valid_params[: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.token, 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
@@ -150,7 +150,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_params) { { token: registration[:token] } }
before(:each) do
user = create(:user)
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 b45223e61..8d33de2c8 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,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_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
+ context "when the token doesn't match the format" do
+ it "redirects to the invalid token error page" do
get new_copy_cards_payment_form_path("foo")
expect(response).to redirect_to(page_path("invalid"))
end
@@ -28,7 +28,7 @@ module WasteCarriersEngine
context "when a matching registration exists" do
before do
- order_copy_cards_registration = OrderCopyCardsRegistration.new(reg_identifier: registration.reg_identifier)
+ order_copy_cards_registration = OrderCopyCardsRegistration.new(token: registration.token)
order_copy_cards_registration.workflow_state = "copy_cards_payment_form"
order_copy_cards_registration.save
end
@@ -37,7 +37,7 @@ module WasteCarriersEngine
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)
+ get new_copy_cards_payment_form_path(registration.token)
expect(response).to redirect_to(page_path("invalid"))
end
@@ -47,13 +47,13 @@ module WasteCarriersEngine
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)
+ get new_copy_cards_payment_form_path(registration.token)
expect(response).to render_template("waste_carriers_engine/copy_cards_payment_forms/new")
end
it "responds to the GET request with a 200 status code" do
- get new_copy_cards_payment_form_path(registration.reg_identifier)
+ get new_copy_cards_payment_form_path(registration.token)
expect(response.code).to eq("200")
end
@@ -88,9 +88,9 @@ module WasteCarriersEngine
end
context "when no matching registration exists" do
- let(:invalid_params) { { reg_identifier: "CBDU99999" } }
+ let(:invalid_params) { { token: "CBDU99999" } }
- it "redirects to the invalid reg_identifier error page" do
+ it "redirects to the invalid token error page" do
post copy_cards_payment_forms_path, copy_cards_payment_form: invalid_params
expect(response).to redirect_to(page_path("invalid"))
end
@@ -104,10 +104,10 @@ module WasteCarriersEngine
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_params) { { token: "foo" } }
- it "redirects to the invalid reg_identifier error page" do
+ it "redirects to the invalid token error page" do
post copy_cards_payment_forms_path, copy_cards_payment_form: invalid_params
expect(response).to redirect_to(page_path("invalid"))
end
@@ -125,13 +125,13 @@ module WasteCarriersEngine
let(:registration) { create(:registration, :has_required_data, :is_active) }
before do
- order_copy_cards_registration = OrderCopyCardsRegistration.new(reg_identifier: registration.reg_identifier)
+ order_copy_cards_registration = OrderCopyCardsRegistration.new(token: registration.token)
order_copy_cards_registration.workflow_state = "copy_cards_payment_form"
order_copy_cards_registration.save
end
context "when valid params are submitted" do
- let(:valid_params) { { reg_identifier: registration.reg_identifier, temp_payment_method: temp_payment_method } }
+ let(:valid_params) { { token: registration.token, temp_payment_method: temp_payment_method } }
context "when the temp payment method is `card`" do
let(:temp_payment_method) { "card" }
@@ -139,11 +139,11 @@ module WasteCarriersEngine
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
- transient_registration = OrderCopyCardsRegistration.find_by(reg_identifier: registration.reg_identifier)
+ transient_registration = OrderCopyCardsRegistration.find_by(token: registration.token)
expect(transient_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(valid_params[:token]))
end
end
@@ -153,17 +153,17 @@ module WasteCarriersEngine
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
- transient_registration = OrderCopyCardsRegistration.find_by(reg_identifier: registration.reg_identifier)
+ transient_registration = OrderCopyCardsRegistration.find_by(token: registration.token)
expect(transient_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(valid_params[:token]))
end
end
end
context "when invalid params are submitted" do
- let(:invalid_params) { { reg_identifier: registration.reg_identifier, temp_payment_method: "foo" } }
+ let(:invalid_params) { { token: registration.token, 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
@@ -177,7 +177,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_params) { { token: registration[:token] } }
before(:each) do
user = create(:user)
diff --git a/spec/requests/waste_carriers_engine/declaration_forms_spec.rb b/spec/requests/waste_carriers_engine/declaration_forms_spec.rb
index 35cb5e8b7..66ef89b9d 100644
--- a/spec/requests/waste_carriers_engine/declaration_forms_spec.rb
+++ b/spec/requests/waste_carriers_engine/declaration_forms_spec.rb
@@ -34,7 +34,7 @@ module WasteCarriersEngine
let(:params) do
{
- reg_identifier: transient_registration.reg_identifier,
+ token: transient_registration.token,
declaration: 1
}
end
@@ -69,13 +69,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 +90,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..bf67ec309 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,7 @@ module WasteCarriersEngine
context "when valid params are submitted" do
let(:valid_params) do
{
- reg_identifier: transient_registration[:reg_identifier],
+ token: transient_registration[:token],
first_name: "Foo",
last_name: "Bar",
dob_day: "1",
@@ -51,7 +51,7 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_declare_convictions_form_path(transient_registration[:token]))
end
context "when there is already a main person" do
@@ -132,7 +132,7 @@ 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]))
+ expect(response).to redirect_to(new_main_people_form_path(transient_registration[:token]))
end
end
end
@@ -140,7 +140,7 @@ module WasteCarriersEngine
context "when invalid params are submitted" do
let(:invalid_params) do
{
- reg_identifier: "foo",
+ token: "foo",
first_name: "",
last_name: "",
dob_day: "31",
@@ -184,7 +184,7 @@ module WasteCarriersEngine
context "when blank params are submitted" do
let(:blank_params) do
{
- reg_identifier: "foo",
+ token: "foo",
first_name: "",
last_name: "",
dob_day: "",
@@ -211,7 +211,7 @@ module WasteCarriersEngine
let(:valid_params) do
{
- reg_identifier: transient_registration[:reg_identifier],
+ token: transient_registration[:token],
first_name: "Foo",
last_name: "Bar",
dob_day: "1",
@@ -232,7 +232,7 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token]))
end
end
end
@@ -255,7 +255,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 +263,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 +272,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 +289,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 +327,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..5aa87fe12 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
@@ -26,7 +26,7 @@ module WasteCarriersEngine
context "when valid params are submitted" do
let(:valid_params) do
{
- reg_identifier: transient_registration[:reg_identifier]
+ token: transient_registration[:token]
}
end
@@ -37,14 +37,14 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_business_type_form_path(transient_registration[:token]))
end
end
context "when invalid params are submitted" do
let(:invalid_params) do
{
- reg_identifier: "foo"
+ token: "foo"
}
end
@@ -55,7 +55,7 @@ module WasteCarriersEngine
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])
+ expect(transient_registration.reload[:token]).to_not eq(invalid_params[:token])
end
end
end
@@ -70,7 +70,7 @@ module WasteCarriersEngine
let(:valid_params) do
{
- reg_identifier: transient_registration[:reg_identifier]
+ token: transient_registration[:token]
}
end
@@ -81,7 +81,7 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token]))
end
end
end
@@ -104,13 +104,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 +125,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..e60f0824c 100644
--- a/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb
+++ b/spec/requests/waste_carriers_engine/registration_number_forms_spec.rb
@@ -28,7 +28,7 @@ module WasteCarriersEngine
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],
+ token: transient_registration[:token],
company_no: transient_registration[:company_no]
}
end
@@ -40,12 +40,12 @@ module WasteCarriersEngine
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]))
+ 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
before(:each) do
- registration = Registration.where(reg_identifier: transient_registration.reg_identifier).first
+ registration = Registration.where(token: transient_registration.token).first
registration.update_attributes(company_no: "9360070")
end
@@ -56,7 +56,7 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_company_name_form_path(transient_registration[:token]))
end
end
end
@@ -64,7 +64,7 @@ module WasteCarriersEngine
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],
+ token: transient_registration[:token],
company_no: "01234567"
}
end
@@ -81,14 +81,14 @@ module WasteCarriersEngine
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]))
+ 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",
+ token: "foo",
company_no: ""
}
end
@@ -100,7 +100,7 @@ module WasteCarriersEngine
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])
+ expect(transient_registration.reload[:token].to_s).to_not eq(invalid_params[:token])
end
end
end
@@ -115,7 +115,7 @@ module WasteCarriersEngine
let(:valid_params) do
{
- reg_identifier: transient_registration[:reg_identifier],
+ token: transient_registration[:token],
company_no: "01234567"
}
end
@@ -132,7 +132,7 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_renewal_start_form_path(transient_registration[:token]))
end
end
end
@@ -155,13 +155,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 +176,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..bffc82d66 100644
--- a/spec/requests/waste_carriers_engine/renewal_complete_forms_spec.rb
+++ b/spec/requests/waste_carriers_engine/renewal_complete_forms_spec.rb
@@ -20,13 +20,13 @@ module WasteCarriersEngine
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))
+ get new_renewal_complete_form_path(registration.token)
+ expect(response).to redirect_to(new_renewal_start_form_path(registration.token))
end
it "does not renew the registration" do
old_expires_on = registration.reload.expires_on
- get new_renewal_complete_form_path(registration.reg_identifier)
+ get new_renewal_complete_form_path(registration.token)
expect(registration.reload.expires_on).to eq(old_expires_on)
end
end
@@ -43,14 +43,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
+ registration = Registration.where(token: transient_registration.token).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 +61,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
+ registration = Registration.where(token: transient_registration.token).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..7ccedf7c6 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[:token])
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[:token])
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[:token])
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,9 +136,9 @@ module WasteCarriersEngine
end
context "when no matching registration exists" do
- let(:invalid_params) { { reg_identifier: "CBDU99999" } }
+ let(:invalid_params) { { token: "CBDU99999" } }
- it "redirects to the invalid reg_identifier error page" do
+ it "redirects to the invalid token error page" do
post renewal_start_forms_path, renewal_start_form: invalid_params
expect(response).to redirect_to(page_path("invalid"))
end
@@ -152,10 +152,10 @@ module WasteCarriersEngine
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_params) { { token: "foo" } }
- it "redirects to the invalid reg_identifier error page" do
+ it "redirects to the invalid token error page" do
post renewal_start_forms_path, renewal_start_form: invalid_params
expect(response).to redirect_to(page_path("invalid"))
end
@@ -181,7 +181,7 @@ module WasteCarriersEngine
end
context "when valid params are submitted" do
- let(:valid_params) { { reg_identifier: registration.reg_identifier } }
+ let(:valid_params) { { token: registration.token } }
it "creates a new transient registration" do
expected_tr_count = RenewingRegistration.count + 1
@@ -193,9 +193,9 @@ module WasteCarriersEngine
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
+ transient_registration = RenewingRegistration.where(token: registration.token).first
- expect(transient_registration.reg_identifier).to eq(registration.reg_identifier)
+ expect(transient_registration.token).to eq(registration.token)
expect(transient_registration.company_name).to eq(registration.company_name)
end
@@ -206,21 +206,21 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_location_form_path(valid_params[: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(registration[:token])
expect(response).to redirect_to(page_path("unrenewable"))
end
end
end
context "when invalid params are submitted" do
- let(:invalid_params) { { reg_identifier: "foo" } }
+ let(:invalid_params) { { token: "foo" } }
it "does not create a new transient registration" do
original_tr_count = RenewingRegistration.count
@@ -240,7 +240,7 @@ module WasteCarriersEngine
workflow_state: "renewal_start_form")
end
- let(:valid_params) { { reg_identifier: transient_registration.reg_identifier } }
+ let(:valid_params) { { token: transient_registration.token } }
it "returns a 302 response" do
post renewal_start_forms_path, renewal_start_form: valid_params
@@ -249,7 +249,7 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_location_form_path(valid_params[:token]))
end
it "does not create a new transient registration" do
@@ -271,7 +271,7 @@ module WasteCarriersEngine
workflow_state: "other_businesses_form")
end
- let(:valid_params) { { reg_identifier: transient_registration.reg_identifier } }
+ let(:valid_params) { { token: transient_registration.token } }
it "returns a 302 response" do
post renewal_start_forms_path, renewal_start_form: valid_params
@@ -280,7 +280,7 @@ module WasteCarriersEngine
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]))
+ expect(response).to redirect_to(new_other_businesses_form_path(valid_params[:token]))
end
it "does not create a new transient registration" do
@@ -305,7 +305,7 @@ module WasteCarriersEngine
:expires_soon,
account_email: "not-#{user.email}")
end
- let(:valid_params) { { reg_identifier: registration.reg_identifier } }
+ let(:valid_params) { { token: registration.token } }
it "redirects to the permissions error page" do
post renewal_start_forms_path, renewal_start_form: valid_params
@@ -320,7 +320,7 @@ module WasteCarriersEngine
account_email: "not-#{user.email}",
workflow_state: "renewal_start_form")
end
- let(:valid_params) { { reg_identifier: transient_registration.reg_identifier } }
+ let(:valid_params) { { token: transient_registration.token } }
it "redirects to the permissions error page" do
post renewal_start_forms_path, renewal_start_form: valid_params
@@ -332,7 +332,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_params) { { token: registration[:token] } }
before(:each) do
user = create(:user)
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/support/form_request_helpers.rb b/spec/support/form_request_helpers.rb
index aeaffd7fc..fd23352e8 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