diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 0f1918fe4..6e441bab7 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,20 +1,21 @@
# This configuration was generated by
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
-# using RuboCop version 1.44.1.
+# using RuboCop version 1.55.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 2
-# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
+# This cop supports safe autocorrection (--autocorrect).
+# Configuration parameters: AllowedMethods, AllowedPatterns.
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/models/exit_survey_response_spec.rb'
- 'spec/services/support/messages/outlook/resync_email_ids_spec.rb'
# Offense count: 8
-# Configuration parameters: AllowedPatterns, IgnoredPatterns.
+# Configuration parameters: AllowedPatterns.
# SupportedStyles: snake_case, camelCase
Naming/MethodName:
EnforcedStyle: snake_case
@@ -36,13 +37,21 @@ RSpec/AnyInstance:
- 'spec/support/shared/notify_email_templates.rb'
- 'spec/support/sign_in_helpers.rb'
+# Offense count: 1
+# This cop supports unsafe autocorrection (--autocorrect-all).
+# Configuration parameters: SkipBlocks, EnforcedStyle.
+# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/controllers/support_agents_spec.rb'
-# Offense count: 3
+# Offense count: 11
RSpec/LetSetup:
- Enabled: false
+ Exclude:
+ - 'spec/jobs/support/send_exit_survey_job_spec.rb'
+ - 'spec/services/support/messages/outlook/synchronisation/message_case_detection_spec.rb'
+ - 'spec/support/shared/duplicate_email_attachments.rb'
+ - 'spec/support/shared/support_agent.rb'
# Offense count: 4
RSpec/SubjectStub:
@@ -50,15 +59,15 @@ RSpec/SubjectStub:
- 'spec/forms/framework_requests/special_requirements_form_spec.rb'
- 'spec/services/support/messages/outlook/synchronisation/message_case_detection_spec.rb'
-# Offense count: 115
+# Offense count: 125
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Enabled: false
-# Offense count: 13
+# Offense count: 14
# Configuration parameters: Database, Include.
# SupportedDatabases: mysql, postgresql
-# Include: db/migrate/*.rb
+# Include: db/**/*.rb
Rails/BulkChangeTable:
Exclude:
- 'db/migrate/20210118110545_change_options_to_jsonb.rb'
@@ -74,21 +83,23 @@ Rails/BulkChangeTable:
- 'db/migrate/20230919092926_update_lot_frameworks_framework.rb'
- 'db/migrate/20230919144709_add_reference_sequence_to_frameworks_framework.rb'
-# Offense count: 2
+# Offense count: 5
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb
Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/all_cases_survey/satisfaction_reason_controller.rb'
+ - 'app/controllers/framework_requests/bill_uploads_controller.rb'
+ - 'app/controllers/framework_requests/document_uploads_controller.rb'
# Offense count: 1
# Configuration parameters: Include.
-# Include: db/migrate/*.rb
+# Include: db/**/*.rb
Rails/NotNullColumn:
Exclude:
- 'db/migrate/20210107122307_add_liquid_template_to_journey.rb'
-# Offense count: 3
+# Offense count: 4
# Configuration parameters: Include.
# Include: db/**/*.rb
Rails/ReversibleMigration:
@@ -123,5 +134,9 @@ Style/DateTime:
- 'lib/microsoft_graph/transformer/message.rb'
- 'lib/microsoft_graph/transformer/update_message.rb'
-Rails/UniqueValidationWithoutIndex:
- Enabled: false
+# Offense count: 1
+# This cop supports safe autocorrection (--autocorrect).
+# Configuration parameters: AllowModifier.
+Style/SoleNestedConditional:
+ Exclude:
+ - 'app/models/framework_request_flow.rb'
diff --git a/app/controllers/framework_requests/base_controller.rb b/app/controllers/framework_requests/base_controller.rb
index 549e65a25..565bd171a 100644
--- a/app/controllers/framework_requests/base_controller.rb
+++ b/app/controllers/framework_requests/base_controller.rb
@@ -74,12 +74,8 @@ def sign_in_path
confirm_sign_in_framework_requests_path
end
- def last_energy_path
- return energy_alternative_framework_requests_path(framework_support_form: form.common) if framework_request.energy_alternative.present?
- return energy_bill_framework_requests_path(framework_support_form: form.common) if framework_request.have_energy_bill.present?
- return energy_request_about_framework_requests_path(framework_support_form: form.common) if framework_request.energy_request_about.present?
-
- energy_request_framework_requests_path(framework_support_form: form.common)
+ def flow
+ framework_request.reload.flow
end
def create_redirect_path; end
diff --git a/app/controllers/framework_requests/bill_uploads_controller.rb b/app/controllers/framework_requests/bill_uploads_controller.rb
index e9eb73ae5..0e0afac2a 100644
--- a/app/controllers/framework_requests/bill_uploads_controller.rb
+++ b/app/controllers/framework_requests/bill_uploads_controller.rb
@@ -2,6 +2,8 @@ module FrameworkRequests
class BillUploadsController < BaseController
skip_before_action :authenticate_user!
+ before_action :edit_back_url, only: %i[update]
+
def list
files = framework_request.energy_bills.map do |bill|
{
@@ -53,7 +55,7 @@ def update_data
end
def create_redirect_path
- message_framework_requests_path(framework_support_form: form.common)
+ special_requirements_framework_requests_path(framework_support_form: form.common)
end
def back_url
@@ -61,11 +63,20 @@ def back_url
end
def determine_back_path
- @current_user = UserPresenter.new(current_user)
- return email_framework_requests_path(framework_support_form: form.common) if @current_user.guest?
- return last_energy_path if @current_user.single_org?
+ return energy_alternative_framework_requests_path(framework_support_form: form.common) if framework_request.energy_alternative.present?
+
+ energy_bill_framework_requests_path(framework_support_form: form.common)
+ end
- select_organisation_framework_requests_path(framework_support_form: form.common)
+ def edit_back_url
+ @back_url =
+ if @form.source.change_link?
+ framework_request_path
+ elsif framework_request.energy_alternative.nil?
+ edit_framework_request_energy_bill_path(framework_request)
+ else
+ edit_framework_request_energy_alternative_path(framework_request)
+ end
end
end
end
diff --git a/app/controllers/framework_requests/categories_controller.rb b/app/controllers/framework_requests/categories_controller.rb
index 0bcc1caa0..971dcad89 100644
--- a/app/controllers/framework_requests/categories_controller.rb
+++ b/app/controllers/framework_requests/categories_controller.rb
@@ -30,7 +30,11 @@ def update
if @form.final_category?
@form.save!
- redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
+ if flow.unfinished?
+ redirect_to edit_framework_request_contract_length_path(framework_request)
+ else
+ redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
+ end
else
redirect_to edit_framework_request_category_path(framework_request, **@form.slugs)
end
@@ -42,8 +46,8 @@ def back_url = @back_url = determine_back_path
def create_redirect_path
if @form.final_category?
- if @form.allow_bill_upload?
- special_requirements_framework_requests_path(framework_support_form: @form.common)
+ if flow.energy_or_services?
+ contract_length_framework_requests_path(framework_support_form: @form.common)
else
procurement_amount_framework_requests_path(framework_support_form: @form.common)
end
@@ -60,10 +64,23 @@ def edit_back_url
end
def determine_back_path
- return categories_framework_requests_path(framework_support_form: @form.common.merge(category_slug: "multiple")) if category_path == "multiple"
- return message_framework_requests_path(framework_support_form: @form.common) if category_path.nil?
-
- categories_framework_requests_path(category_path: @form.parent_category_path, framework_support_form: @form.common)
+ @current_user = UserPresenter.new(current_user)
+
+ if category_path == "multiple"
+ categories_framework_requests_path(framework_support_form: @form.common.merge(category_slug: "multiple"))
+ elsif category_path.nil?
+ if @current_user.guest?
+ email_framework_requests_path(framework_support_form: @form.common)
+ elsif form.eligible_for_school_picker?
+ confirm_schools_framework_requests_path(framework_support_form: @form.common)
+ elsif @current_user.single_org?
+ confirm_sign_in_framework_requests_path(framework_support_form: @form.common)
+ else
+ select_organisation_framework_requests_path(framework_support_form: @form.common)
+ end
+ else
+ categories_framework_requests_path(category_path: @form.parent_category_path, framework_support_form: @form.common)
+ end
end
def form_params = %i[category_slug category_other]
diff --git a/app/controllers/framework_requests/confirm_schools_controller.rb b/app/controllers/framework_requests/confirm_schools_controller.rb
index 5009ccc88..eb7935800 100644
--- a/app/controllers/framework_requests/confirm_schools_controller.rb
+++ b/app/controllers/framework_requests/confirm_schools_controller.rb
@@ -21,7 +21,7 @@ def update
if @form.valid?
if @form.school_urns_confirmed?
@form.save!
- redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
+ update_redirect_path
else
redirect_to edit_framework_request_school_picker_path(framework_request)
end
@@ -45,12 +45,18 @@ def form_params
end
def create_redirect_path
- if @form.allow_bill_upload?
- bill_uploads_framework_requests_path(framework_support_form: @form.common)
- elsif current_user.guest?
+ if current_user.guest?
name_framework_requests_path(framework_support_form: @form.common)
else
- message_framework_requests_path(framework_support_form: @form.common)
+ categories_framework_requests_path(framework_support_form: @form.common)
+ end
+ end
+
+ def update_redirect_path
+ if flow.unfinished?
+ redirect_to edit_framework_request_same_supplier_path(framework_request)
+ else
+ redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
end
end
diff --git a/app/controllers/framework_requests/confirm_sign_in_controller.rb b/app/controllers/framework_requests/confirm_sign_in_controller.rb
index d19e75f62..1f89e8322 100644
--- a/app/controllers/framework_requests/confirm_sign_in_controller.rb
+++ b/app/controllers/framework_requests/confirm_sign_in_controller.rb
@@ -15,9 +15,8 @@ def create_redirect_path
@current_user = UserPresenter.new(current_user)
return select_organisation_framework_requests_path(framework_support_form: form.common) unless @current_user.single_org?
return school_picker_framework_requests_path(framework_support_form: form.common) if @current_user.belongs_to_trust_or_federation? && @current_user.org.organisations.present?
- return bill_uploads_framework_requests_path(framework_support_form: form.common) if @form.allow_bill_upload?
- message_framework_requests_path(framework_support_form: form.common)
+ categories_framework_requests_path(framework_support_form: form.common)
end
def set_inferred_attrbutes
diff --git a/app/controllers/framework_requests/contract_lengths_controller.rb b/app/controllers/framework_requests/contract_lengths_controller.rb
new file mode 100644
index 000000000..63f47bed1
--- /dev/null
+++ b/app/controllers/framework_requests/contract_lengths_controller.rb
@@ -0,0 +1,47 @@
+module FrameworkRequests
+ class ContractLengthsController < BaseController
+ skip_before_action :authenticate_user!
+
+ before_action :edit_back_url, only: %i[update]
+
+ def update
+ if @form.valid?
+ @form.save!
+ if flow.unfinished?
+ redirect_to edit_framework_request_contract_start_date_path(framework_request)
+ else
+ redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
+ end
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def form
+ @form ||= FrameworkRequests::ContractLengthForm.new(all_form_params)
+ end
+
+ def form_params
+ [:contract_length]
+ end
+
+ def create_redirect_path
+ contract_start_date_framework_requests_path(framework_support_form: form.common)
+ end
+
+ def back_url
+ @back_url = categories_framework_requests_path(category_path: framework_request.category&.ancestors_slug, framework_support_form: @form.common)
+ end
+
+ def edit_back_url
+ @back_url =
+ if flow.unfinished?
+ edit_framework_request_category_path(framework_support_form: form.common)
+ else
+ framework_request_path(form.framework_request)
+ end
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/contract_start_dates_controller.rb b/app/controllers/framework_requests/contract_start_dates_controller.rb
new file mode 100644
index 000000000..63dc0794d
--- /dev/null
+++ b/app/controllers/framework_requests/contract_start_dates_controller.rb
@@ -0,0 +1,63 @@
+module FrameworkRequests
+ class ContractStartDatesController < BaseController
+ include Support::Concerns::HasDateParams
+
+ skip_before_action :authenticate_user!
+
+ before_action :edit_back_url, only: %i[update]
+
+ def update
+ if @form.valid?
+ @form.save!
+ if flow.unfinished?
+ if framework_request.multischool_with_multiple_selections?
+ redirect_to edit_framework_request_same_supplier_path(framework_request)
+ else
+ redirect_to framework_request.energy_category? ? edit_framework_request_energy_bill_path(framework_request) : edit_framework_request_documents_path(framework_request)
+ end
+ else
+ redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
+ end
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def form
+ @form ||= FrameworkRequests::ContractStartDateForm.new(all_form_params)
+ end
+
+ def form_params
+ %i[contract_start_date_known contract_start_date]
+ end
+
+ def all_form_params
+ super
+ .except("contract_start_date(3i)", "contract_start_date(2i)", "contract_start_date(1i)")
+ .merge(contract_start_date: date_param(:framework_support_form, :contract_start_date).compact_blank)
+ end
+
+ def create_redirect_path
+ if framework_request.multischool_with_multiple_selections?
+ same_supplier_framework_requests_path(framework_support_form: form.common)
+ else
+ procurement_amount_framework_requests_path(framework_support_form: form.common)
+ end
+ end
+
+ def back_url
+ @back_url = contract_length_framework_requests_path(ramework_support_form: @form.common)
+ end
+
+ def edit_back_url
+ @back_url =
+ if flow.unfinished?
+ edit_framework_request_contract_length_path(framework_support_form: form.common)
+ else
+ framework_request_path(form.framework_request)
+ end
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/document_uploads_controller.rb b/app/controllers/framework_requests/document_uploads_controller.rb
new file mode 100644
index 000000000..ee253ac81
--- /dev/null
+++ b/app/controllers/framework_requests/document_uploads_controller.rb
@@ -0,0 +1,80 @@
+module FrameworkRequests
+ class DocumentUploadsController < BaseController
+ skip_before_action :authenticate_user!
+
+ before_action :set_document_types, only: %i[index edit]
+ before_action :edit_back_url, only: %i[update]
+
+ def list
+ files = framework_request.documents.map do |bill|
+ {
+ file_id: bill.id,
+ name: bill.filename,
+ size: bill.file.attachment.byte_size,
+ type: bill.file.attachment.content_type,
+ }
+ end
+ render status: :ok, json: files.to_json
+ end
+
+ def upload
+ if file_is_safe?
+ document = Document.pending.create!(
+ file: params[:file],
+ framework_request_id: framework_request.id,
+ filename: params[:file].original_filename,
+ )
+
+ render status: :created, json: { file_id: document.id }
+ else
+ track_event("Rfh/DocumentUploads/Upload/VirusDetected", framework_request_id: framework_request.id)
+
+ params[:file].tempfile.delete
+
+ render status: :unprocessable_entity, json: { error: "virus detected" }
+ end
+ end
+
+ def remove
+ document = Document.find(params[:file_id])
+ document.destroy!
+ head :ok
+ end
+
+ private
+
+ def file_is_safe?
+ Rails.configuration.clamav_scanner.file_is_safe?(params[:file])
+ end
+
+ def form
+ @form ||= FrameworkRequests::DocumentUploadsForm.new(all_form_params)
+ end
+
+ def update_data
+ {}
+ end
+
+ def create_redirect_path
+ special_requirements_framework_requests_path(framework_support_form: form.common)
+ end
+
+ def back_url
+ @back_url = documents_framework_requests_path(framework_support_form: form.common)
+ end
+
+ def edit_back_url
+ @back_url =
+ if @form.source.change_link?
+ framework_request_path
+ else
+ edit_framework_request_documents_path(framework_request)
+ end
+ end
+
+ def set_document_types
+ @document_types = framework_request.document_types
+ @other = framework_request.document_type_other
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/documents_controller.rb b/app/controllers/framework_requests/documents_controller.rb
new file mode 100644
index 000000000..67a6ae110
--- /dev/null
+++ b/app/controllers/framework_requests/documents_controller.rb
@@ -0,0 +1,49 @@
+module FrameworkRequests
+ class DocumentsController < BaseController
+ skip_before_action :authenticate_user!
+
+ before_action :edit_back_url, only: %i[update]
+
+ def update
+ if @form.valid?
+ @form.save!
+ if framework_request.reload.document_types.include?("none")
+ redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
+ else
+ redirect_to edit_framework_request_document_uploads_path(framework_request)
+ end
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def form
+ @form ||= FrameworkRequests::DocumentsForm.new(all_form_params)
+ end
+
+ def form_params
+ [:document_type_other, { document_types: [] }]
+ end
+
+ def create_redirect_path
+ return special_requirements_framework_requests_path(framework_support_form: @form.common) if framework_request.document_types.include?("none")
+
+ document_uploads_framework_requests_path(framework_support_form: @form.common)
+ end
+
+ def back_url
+ @back_url = message_framework_requests_path(framework_support_form: @form.common)
+ end
+
+ def edit_back_url
+ @back_url =
+ if framework_request.multischool_with_multiple_selections?
+ edit_framework_request_same_supplier_path(framework_request)
+ else
+ edit_framework_request_contract_start_date_path(framework_request)
+ end
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/emails_controller.rb b/app/controllers/framework_requests/emails_controller.rb
index f26dad890..c656ad0a2 100644
--- a/app/controllers/framework_requests/emails_controller.rb
+++ b/app/controllers/framework_requests/emails_controller.rb
@@ -13,9 +13,7 @@ def form_params
end
def create_redirect_path
- return bill_uploads_framework_requests_path(framework_support_form: form.common) if form.allow_bill_upload?
-
- message_framework_requests_path(framework_support_form: form.common)
+ categories_framework_requests_path(framework_support_form: form.common)
end
def back_url
diff --git a/app/controllers/framework_requests/energy_alternative_controller.rb b/app/controllers/framework_requests/energy_alternative_controller.rb
deleted file mode 100644
index 735a96c8f..000000000
--- a/app/controllers/framework_requests/energy_alternative_controller.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-module FrameworkRequests
- class EnergyAlternativeController < BaseController
- skip_before_action :authenticate_user!
-
- private
-
- def form
- @form ||= FrameworkRequests::EnergyAlternativeForm.new(all_form_params)
- end
-
- def form_params
- [:energy_alternative]
- end
-
- def create_redirect_path = sign_in_path
-
- def back_url
- @back_url = energy_bill_framework_requests_path(framework_support_form: @form.common)
- end
- end
-end
diff --git a/app/controllers/framework_requests/energy_alternatives_controller.rb b/app/controllers/framework_requests/energy_alternatives_controller.rb
new file mode 100644
index 000000000..61f01d7ab
--- /dev/null
+++ b/app/controllers/framework_requests/energy_alternatives_controller.rb
@@ -0,0 +1,44 @@
+module FrameworkRequests
+ class EnergyAlternativesController < BaseController
+ skip_before_action :authenticate_user!
+
+ before_action :edit_back_url, only: %i[update]
+
+ def update
+ if @form.valid?
+ @form.save!
+ if framework_request.reload.different_format_energy_alternative?
+ redirect_to edit_framework_request_bill_uploads_path(framework_request)
+ else
+ redirect_to framework_request_path(framework_request)
+ end
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def form
+ @form ||= FrameworkRequests::EnergyAlternativeForm.new(all_form_params)
+ end
+
+ def form_params
+ [:energy_alternative]
+ end
+
+ def create_redirect_path
+ return bill_uploads_framework_requests_path(framework_support_form: @form.common) if framework_request.different_format_energy_alternative?
+
+ special_requirements_framework_requests_path(framework_support_form: @form.common)
+ end
+
+ def back_url
+ @back_url = energy_bill_framework_requests_path(framework_support_form: @form.common)
+ end
+
+ def edit_back_url
+ @back_url = edit_framework_request_energy_bill_path(framework_request)
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/energy_bill_controller.rb b/app/controllers/framework_requests/energy_bill_controller.rb
deleted file mode 100644
index 31d997ec1..000000000
--- a/app/controllers/framework_requests/energy_bill_controller.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module FrameworkRequests
- class EnergyBillController < BaseController
- skip_before_action :authenticate_user!
-
- private
-
- def form
- @form ||= FrameworkRequests::EnergyBillForm.new(all_form_params)
- end
-
- def form_params
- [:have_energy_bill]
- end
-
- def create_redirect_path
- return sign_in_path if @form.have_energy_bill?
-
- energy_alternative_framework_requests_path(framework_support_form: @form.common)
- end
-
- def back_url
- @back_url = energy_request_about_framework_requests_path(framework_support_form: @form.common)
- end
- end
-end
diff --git a/app/controllers/framework_requests/energy_bills_controller.rb b/app/controllers/framework_requests/energy_bills_controller.rb
new file mode 100644
index 000000000..c8034d03b
--- /dev/null
+++ b/app/controllers/framework_requests/energy_bills_controller.rb
@@ -0,0 +1,49 @@
+module FrameworkRequests
+ class EnergyBillsController < BaseController
+ skip_before_action :authenticate_user!
+
+ before_action :edit_back_url, only: %i[update]
+
+ def update
+ if @form.valid?
+ @form.save!
+ if @form.have_energy_bill?
+ redirect_to edit_framework_request_bill_uploads_path(framework_request)
+ else
+ redirect_to edit_framework_request_energy_alternative_path(framework_request)
+ end
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def form
+ @form ||= FrameworkRequests::EnergyBillForm.new(all_form_params)
+ end
+
+ def form_params
+ [:have_energy_bill]
+ end
+
+ def create_redirect_path
+ return bill_uploads_framework_requests_path(framework_support_form: @form.common) if @form.have_energy_bill?
+
+ energy_alternative_framework_requests_path(framework_support_form: @form.common)
+ end
+
+ def back_url
+ @back_url = message_framework_requests_path(framework_support_form: @form.common)
+ end
+
+ def edit_back_url
+ @back_url =
+ if framework_request.multischool_with_multiple_selections?
+ edit_framework_request_same_supplier_path(framework_request)
+ else
+ edit_framework_request_contract_start_date_path(framework_request)
+ end
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/energy_request_about_controller.rb b/app/controllers/framework_requests/energy_request_about_controller.rb
deleted file mode 100644
index fb5227347..000000000
--- a/app/controllers/framework_requests/energy_request_about_controller.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-module FrameworkRequests
- class EnergyRequestAboutController < BaseController
- skip_before_action :authenticate_user!
-
- private
-
- def form
- @form ||= FrameworkRequests::EnergyRequestAboutForm.new(all_form_params)
- end
-
- def form_params
- [:energy_request_about]
- end
-
- def create_redirect_path
- case @form.energy_request_about
- when :energy_contract then energy_bill_framework_requests_path(framework_support_form: @form.common)
- else sign_in_path
- end
- end
-
- def back_url
- @back_url = energy_request_framework_requests_path(framework_support_form: @form.common)
- end
- end
-end
diff --git a/app/controllers/framework_requests/energy_request_controller.rb b/app/controllers/framework_requests/energy_request_controller.rb
deleted file mode 100644
index 5c4036ee4..000000000
--- a/app/controllers/framework_requests/energy_request_controller.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module FrameworkRequests
- class EnergyRequestController < BaseController
- skip_before_action :authenticate_user!
-
- private
-
- def form
- @form ||= FrameworkRequests::EnergyRequestForm.new(all_form_params)
- end
-
- def form_params
- [:is_energy_request]
- end
-
- def create_redirect_path
- return energy_request_about_framework_requests_path(framework_support_form: @form.common) if @form.is_energy_request?
-
- sign_in_path
- end
-
- def back_url
- @back_url = framework_requests_path
- end
- end
-end
diff --git a/app/controllers/framework_requests/messages_controller.rb b/app/controllers/framework_requests/messages_controller.rb
index daeeaf11b..ae24fbfca 100644
--- a/app/controllers/framework_requests/messages_controller.rb
+++ b/app/controllers/framework_requests/messages_controller.rb
@@ -13,21 +13,17 @@ def form_params
end
def create_redirect_path
- categories_framework_requests_path(framework_support_form: form.common)
+ if framework_request.energy_category?
+ energy_bill_framework_requests_path(framework_support_form: form.common)
+ elsif flow.goods? || flow.not_fully_supported?
+ special_requirements_framework_requests_path(framework_support_form: form.common)
+ else
+ documents_framework_requests_path(framework_support_form: form.common)
+ end
end
def back_url
- @back_url = determine_back_path
- end
-
- def determine_back_path
- @current_user = UserPresenter.new(current_user)
- return confirm_schools_framework_requests_path(framework_support_form: form.common) if form.eligible_for_school_picker?
- return bill_uploads_framework_requests_path(framework_support_form: form.common) if form.allow_bill_upload?
- return email_framework_requests_path(framework_support_form: form.common) if @current_user.guest?
- return last_energy_path if Flipper.enabled?(:energy_bill_flow) && @current_user.single_org?
-
- select_organisation_framework_requests_path(framework_support_form: form.common)
+ @back_url = procurement_amount_framework_requests_path(framework_support_form: form.common)
end
end
end
diff --git a/app/controllers/framework_requests/origins_controller.rb b/app/controllers/framework_requests/origins_controller.rb
new file mode 100644
index 000000000..252a626ae
--- /dev/null
+++ b/app/controllers/framework_requests/origins_controller.rb
@@ -0,0 +1,30 @@
+module FrameworkRequests
+ class OriginsController < BaseController
+ skip_before_action :authenticate_user!
+
+ def create
+ if @form.valid?
+ @form.save!
+ session.delete(:support_journey) unless current_user.guest?
+ session.delete(:framework_request_id)
+ redirect_to framework_request_path(@form.framework_request)
+ else
+ render :index
+ end
+ end
+
+ private
+
+ def form
+ @form ||= FrameworkRequests::OriginForm.new(all_form_params)
+ end
+
+ def form_params
+ %i[origin origin_other]
+ end
+
+ def back_url
+ @back_url = special_requirements_framework_requests_path(framework_support_form: @form.common)
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/procurement_amounts_controller.rb b/app/controllers/framework_requests/procurement_amounts_controller.rb
index 6eeb5a5ef..336194ebc 100644
--- a/app/controllers/framework_requests/procurement_amounts_controller.rb
+++ b/app/controllers/framework_requests/procurement_amounts_controller.rb
@@ -13,11 +13,20 @@ def form_params
end
def create_redirect_path
- special_requirements_framework_requests_path(framework_support_form: form.common)
+ message_framework_requests_path(framework_support_form: form.common)
end
def back_url
- @back_url = categories_framework_requests_path(category_path: framework_request.category&.ancestors_slug, framework_support_form: @form.common)
+ @back_url =
+ if flow.energy? || flow.services?
+ if framework_request.multischool_with_multiple_selections?
+ same_supplier_framework_requests_path(framework_support_form: @form.common)
+ else
+ contract_start_date_framework_requests_path(framework_support_form: @form.common)
+ end
+ else
+ categories_framework_requests_path(category_path: framework_request.category&.ancestors_slug, framework_support_form: @form.common)
+ end
end
end
end
diff --git a/app/controllers/framework_requests/same_suppliers_controller.rb b/app/controllers/framework_requests/same_suppliers_controller.rb
new file mode 100644
index 000000000..cdeefbb75
--- /dev/null
+++ b/app/controllers/framework_requests/same_suppliers_controller.rb
@@ -0,0 +1,49 @@
+module FrameworkRequests
+ class SameSuppliersController < BaseController
+ skip_before_action :authenticate_user!
+
+ before_action :edit_back_url, only: %i[update]
+
+ def update
+ if @form.valid?
+ @form.save!
+ if flow.unfinished?
+ redirect_to framework_request.energy_category? ? edit_framework_request_energy_bill_path(framework_request) : edit_framework_request_documents_path(framework_request)
+ else
+ redirect_to framework_request_path(framework_request), notice: I18n.t("support_request.flash.updated")
+ end
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def form
+ @form ||= FrameworkRequests::SameSupplierForm.new(all_form_params)
+ end
+
+ def form_params
+ [:same_supplier_used]
+ end
+
+ def create_redirect_path
+ procurement_amount_framework_requests_path(framework_support_form: form.common)
+ end
+
+ def back_url
+ @back_url = contract_start_date_framework_requests_path(framework_support_form: @form.common)
+ end
+
+ def edit_back_url
+ @back_url =
+ if @form.source.change_link?
+ framework_request_path
+ elsif flow.unfinished?
+ edit_framework_request_contract_start_date_path(framework_request)
+ else
+ edit_framework_request_confirm_schools_path(framework_request)
+ end
+ end
+ end
+end
diff --git a/app/controllers/framework_requests/school_pickers_controller.rb b/app/controllers/framework_requests/school_pickers_controller.rb
index 319525ded..b2fbab6af 100644
--- a/app/controllers/framework_requests/school_pickers_controller.rb
+++ b/app/controllers/framework_requests/school_pickers_controller.rb
@@ -59,7 +59,7 @@ def back_url
def edit_back_url
@back_url =
- if @form.source == "change_link"
+ if @form.source.change_link?
framework_request_path
else
edit_framework_request_confirm_organisation_path(framework_support_form: @form.common.merge(school_type: "group", org_confirm: true))
diff --git a/app/controllers/framework_requests/select_organisations_controller.rb b/app/controllers/framework_requests/select_organisations_controller.rb
index b232974b2..92cde3f5e 100644
--- a/app/controllers/framework_requests/select_organisations_controller.rb
+++ b/app/controllers/framework_requests/select_organisations_controller.rb
@@ -13,15 +13,13 @@ def form_params
def create_redirect_path
if form.eligible_for_school_picker?
school_picker_framework_requests_path(framework_support_form: form.common)
- elsif form.allow_bill_upload?
- bill_uploads_framework_requests_path(framework_support_form: form.common)
else
- message_framework_requests_path(framework_support_form: form.common)
+ categories_framework_requests_path(framework_support_form: form.common)
end
end
def back_url
- @back_url = last_energy_path
+ @back_url = confirm_sign_in_framework_requests_path
end
end
end
diff --git a/app/controllers/framework_requests/sign_in_controller.rb b/app/controllers/framework_requests/sign_in_controller.rb
index adc7a66e7..447feea77 100644
--- a/app/controllers/framework_requests/sign_in_controller.rb
+++ b/app/controllers/framework_requests/sign_in_controller.rb
@@ -13,11 +13,7 @@ def create_redirect_path
end
def back_url
- @back_url = url_from(back_link_param) || prev_step
- end
-
- def prev_step
- Flipper.enabled?(:energy_bill_flow) ? energy_request_framework_requests_path(framework_support_form: @form.common) : framework_requests_path
+ @back_url = url_from(back_link_param) || framework_requests_path
end
end
end
diff --git a/app/controllers/framework_requests/special_requirements_controller.rb b/app/controllers/framework_requests/special_requirements_controller.rb
index 1542bd774..480aa497c 100644
--- a/app/controllers/framework_requests/special_requirements_controller.rb
+++ b/app/controllers/framework_requests/special_requirements_controller.rb
@@ -2,17 +2,6 @@ module FrameworkRequests
class SpecialRequirementsController < BaseController
skip_before_action :authenticate_user!
- def create
- if @form.valid?
- @form.save!
- session.delete(:support_journey) unless current_user.guest?
- session.delete(:framework_request_id)
- redirect_to framework_request_path(@form.framework_request)
- else
- render :index
- end
- end
-
def edit
super
@form.special_requirements_choice = framework_request.special_requirements == "-" ? "no" : "yes"
@@ -28,14 +17,30 @@ def form_params
[:special_requirements]
end
+ def create_redirect_path
+ origin_framework_requests_path(framework_support_form: form.common)
+ end
+
def back_url
@back_url = determine_back_path
end
def determine_back_path
- return categories_framework_requests_path(category_path: framework_request.category&.ancestors_slug, framework_support_form: @form.common) if form.allow_bill_upload?
-
- procurement_amount_framework_requests_path(framework_support_form: form.common)
+ if framework_request.energy_category?
+ if framework_request.has_bills?
+ bill_uploads_framework_requests_path(framework_support_form: form.common)
+ else
+ energy_alternative_framework_requests_path(framework_support_form: form.common)
+ end
+ elsif flow.services? || flow.energy?
+ if framework_request.has_documents?
+ document_uploads_framework_requests_path(framework_support_form: form.common)
+ else
+ documents_framework_requests_path(framework_support_form: form.common)
+ end
+ else
+ message_framework_requests_path(framework_support_form: form.common)
+ end
end
end
end
diff --git a/app/controllers/framework_requests/start_controller.rb b/app/controllers/framework_requests/start_controller.rb
index 84982a52e..46eac3a86 100644
--- a/app/controllers/framework_requests/start_controller.rb
+++ b/app/controllers/framework_requests/start_controller.rb
@@ -8,17 +8,7 @@ def create
request.current_user_journey.try(:update!, framework_request:)
- redirect_to Flipper.enabled?(:energy_bill_flow) ? next_step_energy_bill_flow : next_step_legacy
- end
-
- private
-
- def next_step_energy_bill_flow
- energy_request_framework_requests_path
- end
-
- def next_step_legacy
- current_user.guest? ? sign_in_framework_requests_path : confirm_sign_in_framework_requests_path
+ redirect_to current_user.guest? ? sign_in_framework_requests_path : confirm_sign_in_framework_requests_path
end
end
end
diff --git a/app/controllers/framework_requests_controller.rb b/app/controllers/framework_requests_controller.rb
index feb303160..84607878e 100644
--- a/app/controllers/framework_requests_controller.rb
+++ b/app/controllers/framework_requests_controller.rb
@@ -9,7 +9,7 @@ def index
def show
@current_user = UserPresenter.new(current_user)
- @back_url = edit_framework_request_special_requirements_path
+ @back_url = edit_framework_request_origin_path
if framework_request.submitted?
redirect_to framework_request_submission_path(framework_request)
diff --git a/app/controllers/support/cases/requests_controller.rb b/app/controllers/support/cases/requests_controller.rb
index c973c1c2c..696eca7f8 100644
--- a/app/controllers/support/cases/requests_controller.rb
+++ b/app/controllers/support/cases/requests_controller.rb
@@ -2,7 +2,7 @@ module Support
module Cases
class RequestsController < Cases::ApplicationController
def show
- @request = @current_case.framework_request
+ @request = FrameworkRequestPresenter.new(@current_case.framework_request)
end
private
diff --git a/app/controllers/support/cases_controller.rb b/app/controllers/support/cases_controller.rb
index 4421cf441..2873abfd5 100644
--- a/app/controllers/support/cases_controller.rb
+++ b/app/controllers/support/cases_controller.rb
@@ -36,6 +36,7 @@ def index
def show
session[:back_link] = url_from(back_link_param) unless back_link_param.nil?
@back_url = url_from(back_link_param) || session[:back_link] || support_cases_path
+ @request = FrameworkRequestPresenter.new(current_case.framework_request)
end
def new
diff --git a/app/controllers/support/concerns/has_date_params.rb b/app/controllers/support/concerns/has_date_params.rb
index 9b8006fdb..4ace263d9 100644
--- a/app/controllers/support/concerns/has_date_params.rb
+++ b/app/controllers/support/concerns/has_date_params.rb
@@ -11,7 +11,7 @@ module HasDateParams
#
# @return [Hash]
def date_param(form_param, date_field)
- date = params.require(form_param).permit(date_field)
+ date = params.fetch(form_param, {}).permit(date_field)
{ day: date["#{date_field}(3i)"], month: date["#{date_field}(2i)"], year: date["#{date_field}(1i)"] }
end
end
diff --git a/app/forms/framework_requests/base_form.rb b/app/forms/framework_requests/base_form.rb
index 088bd8881..9926edd06 100644
--- a/app/forms/framework_requests/base_form.rb
+++ b/app/forms/framework_requests/base_form.rb
@@ -2,8 +2,6 @@ module FrameworkRequests
class BaseForm
include ActiveModel::Model
- delegate :allow_bill_upload?, to: :framework_request
-
attr_accessor(
:id,
:dsi,
@@ -11,9 +9,10 @@ class BaseForm
:user,
:org_confirm,
:special_requirements_choice,
- :source,
)
+ attr_writer :source
+
def initialize(attributes = {})
super
@user = UserPresenter.new(@user)
@@ -69,6 +68,10 @@ def school_or_group
def eligible_for_school_picker? = group? && (school_or_group.federation? || school_or_group.mat_or_trust?) && school_or_group.organisations.present?
+ def source
+ (@source || "").inquiry
+ end
+
private
def found_uid_or_urn
diff --git a/app/forms/framework_requests/category_form.rb b/app/forms/framework_requests/category_form.rb
index 3ab348429..104dffa09 100644
--- a/app/forms/framework_requests/category_form.rb
+++ b/app/forms/framework_requests/category_form.rb
@@ -17,7 +17,7 @@ def initialize(attributes = {})
def category_options
return if multiple_categories?
- categories = @category_path.blank? ? RequestForHelpCategory.top_level.active : @current_category&.sub_categories
+ categories = @category_path.blank? ? RequestForHelpCategory.top_level.active : @current_category&.sub_categories&.active
categories.map do |category|
OpenStruct.new(
diff --git a/app/forms/framework_requests/contract_length_form.rb b/app/forms/framework_requests/contract_length_form.rb
new file mode 100644
index 000000000..6c28071b1
--- /dev/null
+++ b/app/forms/framework_requests/contract_length_form.rb
@@ -0,0 +1,12 @@
+module FrameworkRequests
+ class ContractLengthForm < BaseForm
+ validates :contract_length, presence: true
+
+ attr_accessor :contract_length
+
+ def initialize(attributes = {})
+ super
+ @contract_length ||= framework_request.contract_length
+ end
+ end
+end
diff --git a/app/forms/framework_requests/contract_start_date_form.rb b/app/forms/framework_requests/contract_start_date_form.rb
new file mode 100644
index 000000000..1b8ae4e2a
--- /dev/null
+++ b/app/forms/framework_requests/contract_start_date_form.rb
@@ -0,0 +1,27 @@
+module FrameworkRequests
+ class ContractStartDateForm < BaseForm
+ validates :contract_start_date_known, presence: true
+ validates :contract_start_date, presence: true, if: -> { contract_start_date_known == "true" }
+ validate :contract_start_date_valid, if: -> { contract_start_date_known == "true" }
+
+ attr_accessor :contract_start_date_known, :contract_start_date
+
+ def initialize(attributes = {})
+ super
+ @contract_start_date_known ||= framework_request.contract_start_date_known
+ @contract_start_date = framework_request.contract_start_date if @contract_start_date.blank?
+ end
+
+ private
+
+ def contract_start_date_valid
+ return if contract_start_date.is_a?(Date)
+
+ begin
+ self.contract_start_date = Date.civil(contract_start_date["year"].to_i, contract_start_date["month"].to_i, contract_start_date["day"].to_i)
+ rescue Date::Error, TypeError
+ errors.add(:contract_start_date, I18n.t("faf.contract_start_date.date.invalid"))
+ end
+ end
+ end
+end
diff --git a/app/forms/framework_requests/document_uploads_form.rb b/app/forms/framework_requests/document_uploads_form.rb
new file mode 100644
index 000000000..38a772b6b
--- /dev/null
+++ b/app/forms/framework_requests/document_uploads_form.rb
@@ -0,0 +1,4 @@
+module FrameworkRequests
+ class DocumentUploadsForm < BaseForm
+ end
+end
diff --git a/app/forms/framework_requests/documents_form.rb b/app/forms/framework_requests/documents_form.rb
new file mode 100644
index 000000000..0572bf0c6
--- /dev/null
+++ b/app/forms/framework_requests/documents_form.rb
@@ -0,0 +1,20 @@
+module FrameworkRequests
+ class DocumentsForm < BaseForm
+ validates :document_types, presence: true
+ validates :document_type_other, presence: true, if: -> { @document_types.include?("other") }
+
+ attr_accessor :document_types, :document_type_other
+
+ def initialize(attributes = {})
+ super
+ @document_types ||= framework_request.document_types
+ @document_type_other ||= framework_request.document_type_other
+ @document_types.compact_blank!
+ end
+
+ def save!
+ @document_type_other = nil unless @document_types.include?("other")
+ super
+ end
+ end
+end
diff --git a/app/forms/framework_requests/origin_form.rb b/app/forms/framework_requests/origin_form.rb
new file mode 100644
index 000000000..0e15267ba
--- /dev/null
+++ b/app/forms/framework_requests/origin_form.rb
@@ -0,0 +1,19 @@
+module FrameworkRequests
+ class OriginForm < BaseForm
+ validates :origin, presence: true
+ validates :origin_other, presence: true, if: -> { @origin == "other" }
+
+ attr_accessor :origin, :origin_other
+
+ def initialize(attributes = {})
+ super
+ @origin ||= framework_request.origin
+ @origin_other ||= framework_request.origin_other
+ end
+
+ def save!
+ @origin_other = nil unless @origin == "other"
+ super
+ end
+ end
+end
diff --git a/app/forms/framework_requests/procurement_amount_form.rb b/app/forms/framework_requests/procurement_amount_form.rb
index b8fb59291..22d8fd277 100644
--- a/app/forms/framework_requests/procurement_amount_form.rb
+++ b/app/forms/framework_requests/procurement_amount_form.rb
@@ -3,6 +3,7 @@ class ProcurementAmountForm < BaseForm
include ActiveModel::Validations::Callbacks
before_validation :format_amount
+ validates :procurement_amount, presence: true, numericality: { greater_than: 0.99 }
validate :procurement_amount_validation
attr_accessor :procurement_amount
@@ -18,7 +19,6 @@ def format_amount
def procurement_amount_validation
validator = Support::Forms::ValidateProcurementAmount.new(@procurement_amount)
- errors.add(:procurement_amount, I18n.t("framework_request.errors.rules.procurement_amount.invalid")) if validator.invalid_number?
errors.add(:procurement_amount, I18n.t("framework_request.errors.rules.procurement_amount.too_large")) if validator.too_large?
end
end
diff --git a/app/forms/framework_requests/same_supplier_form.rb b/app/forms/framework_requests/same_supplier_form.rb
new file mode 100644
index 000000000..5269da302
--- /dev/null
+++ b/app/forms/framework_requests/same_supplier_form.rb
@@ -0,0 +1,12 @@
+module FrameworkRequests
+ class SameSupplierForm < BaseForm
+ validates :same_supplier_used, presence: true
+
+ attr_accessor :same_supplier_used
+
+ def initialize(attributes = {})
+ super
+ @same_supplier_used ||= framework_request.same_supplier_used
+ end
+ end
+end
diff --git a/app/helpers/request_for_help/contract_length_helper.rb b/app/helpers/request_for_help/contract_length_helper.rb
new file mode 100644
index 000000000..3b8e3256a
--- /dev/null
+++ b/app/helpers/request_for_help/contract_length_helper.rb
@@ -0,0 +1,7 @@
+module RequestForHelp
+ module ContractLengthHelper
+ def available_contract_lengths
+ I18nOption.from("faf.contract_length.options.%%key%%", FrameworkRequest.contract_lengths.keys).sort_by(&:title)
+ end
+ end
+end
diff --git a/app/helpers/request_for_help/documents_helper.rb b/app/helpers/request_for_help/documents_helper.rb
new file mode 100644
index 000000000..057b86b00
--- /dev/null
+++ b/app/helpers/request_for_help/documents_helper.rb
@@ -0,0 +1,13 @@
+module RequestForHelp
+ module DocumentsHelper
+ def available_document_types
+ CheckboxOption.from(I18nOption.from("faf.documents.options.%%key%%", FrameworkRequest.document_types), exclusive_fields: %w[none])
+ end
+
+ def selected_document_types(document_types, other)
+ result = I18nOption.from("faf.documents.options.%%key%%", document_types.excluding("other")).map(&:title)
+ result << other if document_types.include?("other")
+ result
+ end
+ end
+end
diff --git a/app/helpers/request_for_help/origin_helper.rb b/app/helpers/request_for_help/origin_helper.rb
new file mode 100644
index 000000000..4c867c0b0
--- /dev/null
+++ b/app/helpers/request_for_help/origin_helper.rb
@@ -0,0 +1,7 @@
+module RequestForHelp
+ module OriginHelper
+ def available_origins
+ I18nOption.from("faf.origin.options.%%key%%", FrameworkRequest.origins.keys)
+ end
+ end
+end
diff --git a/app/helpers/request_for_help/same_supplier_helper.rb b/app/helpers/request_for_help/same_supplier_helper.rb
new file mode 100644
index 000000000..9c18571f1
--- /dev/null
+++ b/app/helpers/request_for_help/same_supplier_helper.rb
@@ -0,0 +1,7 @@
+module RequestForHelp
+ module SameSupplierHelper
+ def available_same_supplier_options
+ I18nOption.from("faf.same_supplier.options.%%key%%", FrameworkRequest.same_supplier_useds.keys).in_order_of(:id, %w[yes no not_sure])
+ end
+ end
+end
diff --git a/app/models/checkbox_option.rb b/app/models/checkbox_option.rb
index b94ae5da6..a54282edf 100644
--- a/app/models/checkbox_option.rb
+++ b/app/models/checkbox_option.rb
@@ -1,11 +1,12 @@
class CheckboxOption
attr_reader :id, :title, :exclusive
- def self.from(collection, id_field: :id, title_field: :title, include_all: false, include_unspecified: false)
+ def self.from(collection, id_field: :id, title_field: :title, include_all: false, include_unspecified: false, exclusive_fields: [])
result = collection.map do |key|
id = key.respond_to?(id_field) ? key.send(id_field) : key[id_field]
title = key.respond_to?(title_field) ? key.send(title_field) : key[title_field]
- new(id:, title:)
+ exclusive = exclusive_fields.include?(id)
+ new(id:, title:, exclusive:)
end
result.unshift(unspecified) if include_unspecified
result.unshift(all) if include_all
diff --git a/app/models/document.rb b/app/models/document.rb
new file mode 100644
index 000000000..34df70fd4
--- /dev/null
+++ b/app/models/document.rb
@@ -0,0 +1,26 @@
+class Document < ApplicationRecord
+ belongs_to :framework_request, class_name: "FrameworkRequest"
+ belongs_to :support_case, class_name: "Support::Case", optional: true
+
+ has_one_attached :file
+ enum submission_status: { pending: 0, submitted: 1 }
+
+ def name = filename
+ def file_name = filename
+ def file_size = file.attachment.byte_size
+ def file_type = file.attachment.content_type
+ def description = "User submitted document"
+
+ def submit
+ update!(submission_status: :submitted, support_case: framework_request.support_case)
+
+ Support::CaseAttachment.create!(
+ attachable: self,
+ support_case_id:,
+ custom_name: file_name,
+ description: "User uploaded document",
+ created_at:,
+ updated_at:,
+ )
+ end
+end
diff --git a/app/models/framework_request.rb b/app/models/framework_request.rb
index c14a10f13..6c8d22be6 100644
--- a/app/models/framework_request.rb
+++ b/app/models/framework_request.rb
@@ -1,25 +1,36 @@
class FrameworkRequest < Request
+ DOCUMENT_TYPES = %w[current_contract communications_with_supplier floor_plans quotes specifications other none].freeze
+
belongs_to :user, optional: true
belongs_to :category, class_name: "RequestForHelpCategory", optional: true
belongs_to :support_case, class_name: "Support::Case", optional: true
has_many :energy_bills, class_name: "EnergyBill"
+ has_many :documents, class_name: "Document"
before_save :clear_school_urns, if: -> { attribute_changed?(:org_id) }
+ before_save :clear_same_supplier_used, if: -> { attribute_changed?(:org_id) }
+ before_save :clear_attributes_by_flow, if: -> { attribute_changed?(:category_id) }
before_save :auto_assign_sat_school, if: -> { sat_selected? }
enum energy_request_about: { energy_contract: 1, not_energy_contract: 0 }, _suffix: true
enum energy_alternative: { different_format: 0, email_later: 1, no_bill: 2, no_thanks: 3 }, _suffix: true
+ enum :contract_length, { not_sure: 0, one_year: 1, two_years: 2, three_years: 3, four_years: 4, five_years: 5 }, prefix: true
+ enum :same_supplier_used, { no: 0, yes: 1, not_sure: 2 }, prefix: true
+ enum :origin, { used_before: 0, meeting_or_event: 1, dfe_publication: 2, non_dfe_publication: 3, recommendation: 4, search_engine: 5, social_media: 6, website: 7, other: 8 }, prefix: true
- def allow_bill_upload?
- Flipper.enabled?(:energy_bill_flow) && is_energy_request && energy_request_about == "energy_contract" &&
- (have_energy_bill || energy_alternative == "different_format")
- end
+ validates :document_types, inclusion: { in: DOCUMENT_TYPES }, allow_nil: true
+
+ def self.document_types = DOCUMENT_TYPES
def has_bills?
energy_bills.any?
end
+ def has_documents?
+ documents.any?
+ end
+
def organisation
return Support::EstablishmentGroup.find_by(uid: org_id) if group
@@ -40,14 +51,26 @@ def multischool?
school_urns.present?
end
- def clear_school_urns
- self.school_urns = []
+ def multischool_with_multiple_selections?
+ multischool? && school_urns.size > 1
+ end
+
+ def submit_documents
+ documents.each(&:submit)
+ end
+
+ def energy_category?
+ category.gas? || category.electricity?
+ end
+
+ def flow
+ FrameworkRequestFlow.new(self)
end
private
def sat_selected?
- attribute_changed?(:org_id) && group && organisation.sat?
+ attribute_changed?(:org_id) && group && organisation&.sat?
end
def auto_assign_sat_school
@@ -55,4 +78,33 @@ def auto_assign_sat_school
self.school_urns = [organisation.organisations.first.urn]
end
+
+ def clear_school_urns
+ self.school_urns = []
+ end
+
+ def clear_same_supplier_used
+ self.same_supplier_used = nil
+ end
+
+ def clear_attributes_by_flow
+ if flow.goods? || flow.not_fully_supported?
+ self.contract_length = nil
+ self.contract_start_date_known = nil
+ self.contract_start_date = nil
+ self.same_supplier_used = nil
+ self.document_types = []
+ self.document_type_other = nil
+ energy_bills.destroy_all
+ documents.destroy_all
+ elsif flow.energy?
+ self.document_types = []
+ self.document_type_other = nil
+ documents.destroy_all
+ elsif flow.services?
+ self.have_energy_bill = nil
+ self.energy_alternative = nil
+ energy_bills.destroy_all
+ end
+ end
end
diff --git a/app/models/framework_request_flow.rb b/app/models/framework_request_flow.rb
new file mode 100644
index 000000000..311d9aa03
--- /dev/null
+++ b/app/models/framework_request_flow.rb
@@ -0,0 +1,49 @@
+class FrameworkRequestFlow
+ delegate :contract_length, to: :@framework_request
+ delegate :contract_start_date_known, to: :@framework_request
+ delegate :same_supplier_used, to: :@framework_request
+ delegate :multischool_with_multiple_selections?, to: :@framework_request
+ delegate :energy_category?, to: :@framework_request
+ delegate :have_energy_bill, to: :@framework_request
+ delegate :document_types, to: :@framework_request
+
+ def initialize(framework_request)
+ @framework_request = framework_request
+ end
+
+ def unfinished?
+ return false if get_flow.nil?
+
+ if services? || energy?
+ return true if contract_length.nil? || contract_start_date_known.nil? || (multischool_with_multiple_selections? && same_supplier_used.nil?)
+ end
+
+ if services? && document_types.empty?
+ return true
+ end
+
+ if energy? && energy_category? && have_energy_bill.nil?
+ return true
+ end
+
+ false
+ end
+
+ def services? = get_flow == "services"
+
+ def energy? = get_flow == "energy"
+
+ def goods? = get_flow == "goods"
+
+ def not_fully_supported? = get_flow == "not_fully_supported"
+
+ def energy_or_services? = energy? || services?
+
+private
+
+ def get_flow
+ return if @framework_request.category.nil?
+
+ @framework_request.category.flow
+ end
+end
diff --git a/app/models/request_for_help_category.rb b/app/models/request_for_help_category.rb
index 072418d48..4adafc5b2 100644
--- a/app/models/request_for_help_category.rb
+++ b/app/models/request_for_help_category.rb
@@ -8,6 +8,8 @@ class RequestForHelpCategory < ApplicationRecord
scope :top_level, -> { where(parent_id: nil) }
scope :active, -> { where(archived: false) }
+ enum :flow, { services: 0, goods: 1, energy: 2, not_fully_supported: 3 }, suffix: true
+
def self.find_by_path(path)
slugs = path.split("/")
parent = nil
@@ -56,4 +58,8 @@ def root_parent
def ancestors_slug = ancestors.map(&:slug).join("/")
def other? = slug == "other"
+
+ def gas? = slug == "gas"
+
+ def electricity? = slug == "electricity"
end
diff --git a/app/presenters/framework_request_presenter.rb b/app/presenters/framework_request_presenter.rb
index 201c7825b..df59b86fc 100644
--- a/app/presenters/framework_request_presenter.rb
+++ b/app/presenters/framework_request_presenter.rb
@@ -42,4 +42,33 @@ def bill_count
def bill_filenames
energy_bills.map(&:filename).join(", ")
end
+
+ def document_count
+ documents.count
+ end
+
+ def contract_length
+ return if super.nil?
+
+ I18n.t("faf.contract_length.options.#{super}")
+ end
+
+ def contract_start_date
+ return if super.nil?
+
+ super.strftime(date_format)
+ end
+
+ def same_supplier_used
+ return if super.nil?
+
+ I18n.t("faf.same_supplier.options.#{super}")
+ end
+
+ def origin
+ return if super.nil?
+ return origin_other if origin_other?
+
+ I18n.t("faf.origin.options.#{super}")
+ end
end
diff --git a/app/services/request_for_help/seed_categories.rb b/app/services/request_for_help/seed_categories.rb
index 097fa7692..42a4b272a 100644
--- a/app/services/request_for_help/seed_categories.rb
+++ b/app/services/request_for_help/seed_categories.rb
@@ -16,8 +16,9 @@ def load_categories!(categories)
record = RequestForHelpCategory.top_level.find_or_initialize_by(title: category["title"])
record.description = category["description"]
record.slug = category["slug"]
- record.archived = category["is_archived"] == true
record.support_category = Support::Category.active.find_by(title: category["support_category"])
+ record.flow = category["flow"]
+ archive(record, category["is_archived"])
record.save!
load_sub_categories!(category["sub_categories"], record)
@@ -29,12 +30,30 @@ def load_sub_categories!(sub_categories, category)
record = category.sub_categories.find_or_initialize_by(title: sub_category["title"])
record.description = sub_category["description"]
record.slug = sub_category["slug"]
- record.archived = sub_category["is_archived"] == true
record.support_category = Support::Category.active.find_by(title: sub_category["support_category"])
+ record.flow = sub_category["flow"]
+ archive(record, sub_category["is_archived"])
record.save!
load_sub_categories!(sub_category["sub_categories"], record)
end
end
+
+ private
+
+ def archive(record, do_archive)
+ return if record.archived && do_archive
+ return if !record.archived && !do_archive
+
+ if record.archived && !do_archive
+ record.archived = false
+ record.archived_at = nil
+ end
+
+ if !record.archived && do_archive
+ record.archived = true
+ record.archived_at = Time.zone.now
+ end
+ end
end
end
diff --git a/app/services/submit_framework_request.rb b/app/services/submit_framework_request.rb
index 91ccea83a..f4fcaa6a2 100644
--- a/app/services/submit_framework_request.rb
+++ b/app/services/submit_framework_request.rb
@@ -34,6 +34,8 @@ def call
CaseFiles::SubmitEnergyBills.new
.call(framework_request_id: request.id, support_case_id: @kase.id)
+ request.submit_documents
+
request.update!(submitted: true)
end
@@ -72,6 +74,8 @@ def open_case
user_selected_category:,
detected_category_id: request.category&.support_category&.id,
participating_schools: map_urns_to_orgs(request.school_urns),
+ discovery_method: request.__getobj__.origin,
+ discovery_method_other_text: request.origin_other,
}
@kase = Support::CreateCase.new(kase_attrs).call
@@ -95,7 +99,7 @@ def open_case
end
def send_confirmation_email
- if request.has_bills? || request.energy_alternative == "email_later"
+ if request.flow.energy?
Emails::ConfirmationEnergy.new(
recipient: request.user,
reference: @kase.ref,
diff --git a/app/views/framework_request_submissions/show.html.erb b/app/views/framework_request_submissions/show.html.erb
index 881f8cc36..26d14ee6e 100644
--- a/app/views/framework_request_submissions/show.html.erb
+++ b/app/views/framework_request_submissions/show.html.erb
@@ -13,7 +13,7 @@
- <% if @framework_request.is_energy_request %>
+ <% if @framework_request.flow.energy? %>
<%= render "energy" %>
<% else %>
<%= render "default" %>
diff --git a/app/views/framework_requests/bill_uploads/_form.html.erb b/app/views/framework_requests/bill_uploads/_form.html.erb
index d643662e1..919a6955b 100644
--- a/app/views/framework_requests/bill_uploads/_form.html.erb
+++ b/app/views/framework_requests/bill_uploads/_form.html.erb
@@ -27,7 +27,10 @@
Upload your energy information
-
Please upload your most recent energy bill. You can upload multiple bills if you have more than one meter. You can also upload your energy information in another format, like a spreadsheet.
+
+
Please upload your most recent energy bill. You can upload multiple bills if you have more than one meter. You can also upload your energy information in another format, like a spreadsheet.
+
Documents can be any type and must be smaller than 30MB. Upload as many documents as you want.
"
+ data-energy-bill-upload-page-one-continue-button-value="Continue to upload"
+ data-energy-bill-upload-page-two-title-value="Your files are uploading"
+ data-energy-bill-upload-page-two-continue-button-value="Continue to upload"
+ data-energy-bill-upload-page-three-title-value="Your files have been uploaded"
+ data-energy-bill-upload-page-three-continue-button-value="Continue">
+
+
+ <% end %>
<% end %>
<% if @current_case.case_attachments.present? %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9959e11e7..678c97fa0 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -344,15 +344,21 @@ en:
email: Your email address
name: Your name
problem: Description of request
+ contract_length: Contract length
+ contract_start_date: Contract start date
+ same_supplier_used: Same supplier used
school: Your school
school_type: School type
schools_buying_for: Schools you're buying for
school_number: "%{selected} of %{total} schools"
single: Single
bills_attached: Bills attached
+ documents_attached: Documents attached
category: Type of goods or service
+ origin: Origin
header: Send your request
response_time: Once you send this request, we will review it and get in touch within 2 working days.
+ not_known: Not known
aria:
change_name: "Change your name"
change_email: "Change your email"
@@ -360,10 +366,15 @@ en:
change_school_type: "Change your school type"
change_school_picker: "Change the schools you're buying for"
change_message: "Change the description of your request"
+ change_contract_length: "Change the length of your contract"
+ change_contract_start_date: "Change the start date of your contract"
+ change_same_supplier_used: "Change whether the same supplier is used for all your schools"
change_procurement_amount: "Change procurement amount"
change_bills_attached: "Change bills attached"
+ change_documents_attached: "Change documents attached"
change_special_requirements: "Change special requirements"
change_category: "Change type of goods or service"
+ change_origin: "Change the origin of your request"
confirm_group_or_trust:
caption: About your school
choice:
@@ -398,6 +409,47 @@ en:
'no': No, I need to change my selection
table:
school_name: School name
+ contract_length:
+ caption: About your procurement
+ title: How long do you want the contract for including any extensions?
+ hint: Tell us how long you want the contract for at this time. We know this can change. We do not recommend contracts that are shorter than one year.
+ options:
+ one_year: 1 year
+ two_years: 2 years
+ three_years: 3 years
+ four_years: 4 years
+ five_years: 5 years
+ not_sure: Not sure
+ contract_start_date:
+ caption: About your procurement
+ title: Do you know when you want the contract to start?
+ options:
+ 'yes': "Yes"
+ 'no': "No"
+ date:
+ label: Enter the date
+ hint: For example, 27 3 2007
+ invalid: Provide a valid date
+ documents:
+ caption: About your request
+ title: Are there any documents that you would like to upload and share with us?
+ hint:
+ - This may help us to answer your query. We can still help if you cannot upload any documents right now.
+ - You'll also be able to share documents with us at a later date.
+ - Select all that apply.
+ options:
+ current_contract: Current contract
+ communications_with_supplier: Communications with your supplier, such as an email
+ floor_plans: Floor plans or site maps
+ quotes: Quotes
+ specifications: Specifications
+ other: Other, please specify
+ none: I do not have anything to upload right now
+ document_upload:
+ caption: About your request
+ title: Upload your documents
+ body: You can upload any type of document smaller than 30MB. Upload as many documents as you want.
+ hint: "Upload the documents you told us about. These were:"
dsi_or_search:
header: Do you have a DfE Sign-in account linked to the school that your request is about?
link:
@@ -433,21 +485,27 @@ en:
body:
- Your recent energy bills give us the information we need to help you. You'll be able to upload more than one bill if you have them.
- We'll review your bills and use the information to suggest a suitable framework for buying energy. We won't share this information without your permission.
- energy_request:
- header: Is your request about energy?
- subtitle: About your request
- body: 'You can read our guidance about %{guidance_link}. It includes:'
- guidance_link: buying energy for your school
- body_bullets:
- - whether you can get a reduced rate VAT
- - how to choose between fixed, flexible or variable price contracts
- - what to think about when choosing contract length
- energy_request_about:
- header: Is your request about an energy contract, for example, a renewal?
- subtitle: About your request
+ origin:
+ caption: About your procurement
+ title: How did you first find out about this service?
+ options:
+ used_before: I've used this service before
+ meeting_or_event: Meeting or event
+ dfe_publication: DfE publication (e.g. ESFA update, SBP update, Sector Bulletin)
+ non_dfe_publication: Non-DfE newsletter
+ recommendation: Recommendation
+ search_engine: Search engine, such as Google
+ social_media: Social media, such as LinkedIn, Facebook, X (formerly Twitter)
+ website: Website, such as GOV.UK
+ other: Other
+ please_specify: Please specify
+ same_supplier:
+ caption: About your procurement
+ title: Do all the schools currently use the same supplier?
options:
- energy_contract: "Yes"
- not_energy_contract: "No"
+ 'yes': "Yes"
+ 'no': "No"
+ not_sure: We're not sure
school_picker:
title: Which schools in your academy trust or federation will be involved in this procurement?
caption: About your school
@@ -546,12 +604,11 @@ en:
header: Which school are you buying for?
user_query:
caption: About your request
- hint: Briefly describe how we can help in a few sentences.
+ hint: Describe how we can help in a few sentences.
hint_list_start: "We'd like to know:"
hint_bullets:
- - what you're buying
- the start and end dates of your current contract, if you have one
- - when you need the new goods or services
+ - if you're buying goods, when you need them
- anything else about your procurement you think we should know
hint_list_end: Please provide as much information as you can. This will help us to answer your question.
label: How can we help?
@@ -821,6 +878,8 @@ en:
contact_extension_number: Contact extension
contact_name: Contact name
contact_phone: Contact phone
+ contract_length: Contract length
+ contract_start_date: Contract start date
create: Create a new case
files: Attach files
date_received: Date received
@@ -902,9 +961,11 @@ en:
hint: For example, 12 11 2007
label: Next key date
label_optional: Next key date (optional)
+ not_known: Not known
organisation: Organisation
organisation_name: Organisation name
organisation_type: Organisation type
+ origin: Origin
place_on_hold: Place on hold
problem_description: Description of query
initial_problem_description: Initial description of query
@@ -943,6 +1004,7 @@ en:
phase: Phase of education
local_authority: Local authority
uploaded_files: Uploaded files
+ same_supplier_used: Same supplier used
sort_by: Sort by
source:
digital: Specify case
diff --git a/config/locales/validation/en.yml b/config/locales/validation/en.yml
index e9a2159f9..f4bb3474b 100644
--- a/config/locales/validation/en.yml
+++ b/config/locales/validation/en.yml
@@ -66,6 +66,38 @@ en:
attributes:
school_urns_confirmed:
blank: Select whether these are the schools you're buying for
+ framework_requests/contract_length_form:
+ attributes:
+ contract_length:
+ blank: Select the amount of time you want the contract for including any extensions. Choose 'not sure' if you do not know.
+ framework_requests/contract_start_date_form:
+ attributes:
+ contract_start_date_known:
+ blank: Select if you know when the contract should start
+ contract_start_date:
+ blank: Enter the date you want the contract to start
+ framework_requests/same_supplier_form:
+ attributes:
+ same_supplier_used:
+ blank: Select if all schools are currently using the same supplier
+ framework_requests/documents_form:
+ attributes:
+ document_types:
+ blank: Select the documents that you want to upload or 'I do not have any to upload at this time' if there are none to share right now.
+ document_type_other:
+ blank: Specify the type of documents that you want to upload
+ framework_requests/procurement_amount_form:
+ attributes:
+ procurement_amount:
+ blank: Enter how much the school will be spending. The number must be greater than 0.
+ greater_than: The number must be greater than 0
+ not_a_number: Enter a valid number
+ framework_requests/origin_form:
+ attributes:
+ origin:
+ blank: Select where you heard about the service
+ origin_other:
+ blank: Specify where you heard about the service
request:
rules:
diff --git a/config/request_for_help/categories.yml b/config/request_for_help/categories.yml
index 07960e942..4513686b8 100644
--- a/config/request_for_help/categories.yml
+++ b/config/request_for_help/categories.yml
@@ -6,18 +6,23 @@ categories:
slug: accessibility-audits
description: for building or digital
support_category: Audit Accessibility (buildings and digital)
+ flow: services
- title: Decarbonisation energy audits
slug: decarbonisation-energy-audits
support_category: Decarbonisation
+ flow: services
- title: Financial audit
slug: financial-audit
support_category: Audit Financial
+ flow: services
- title: Safeguarding audit
slug: safeguarding-audit
support_category: Audit Safeguarding
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: Financial services
slug: financial-services
@@ -25,15 +30,19 @@ categories:
- title: Financial audit
slug: financial-audit
support_category: Audit Financial
+ flow: services
- title: Insurance
slug: insurance
support_category: Insurance
+ flow: services
- title: Spend analysis
slug: spend-analysis
support_category: Spend Analysis
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: Leasing
slug: leasing
@@ -41,18 +50,23 @@ categories:
- title: Leasing
slug: leasing-sub
support_category: Leasing
+ flow: services
- title: LEDs (light-emitting diode)
slug: leds
support_category: Decarbonisation
+ flow: services
- title: Property leasing agents
slug: property-leasing-agents
support_category: Property leasing agents
+ flow: services
- title: Solar
slug: solar
support_category: Solar
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: School and education supplies
slug: school-and-education-supplies
@@ -60,19 +74,24 @@ categories:
- title: Books
slug: books
support_category: Books
+ flow: goods
- title: Stationery and office supplies
slug: stationery-and-office-supplies
support_category: Stationery supply & office supplies
+ flow: goods
- title: Uniform
slug: uniform
description: for staff or pupils
support_category: Uniform
+ flow: not_fully_supported
- title: Vending machine
slug: vending-machine
support_category: Vending Machine
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Transport
slug: transport
@@ -80,12 +99,15 @@ categories:
- title: Passenger transport
slug: passenger-transport
support_category: Passenger transport
+ flow: services
- title: Vehicle hire or purchase
slug: vehicle-hire-or-purchase
support_category: Vehicle hire & purchase
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: Food and catering
slug: food-and-catering
@@ -93,22 +115,28 @@ categories:
- title: Breakfast club
slug: breakfast-club
support_category: Breakfast Club
+ flow: services
- title: Catering equipment
slug: catering-equipment
support_category: Catering Equipment
+ flow: goods
- title: Catering services
slug: catering-services
support_category: Catering Services
+ flow: services
- title: Uniform
slug: uniform
description: for staff or pupils
support_category: Uniform
+ flow: not_fully_supported
- title: Vending machine
slug: vending-machine
support_category: Vending Machine
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Energy and utilities
slug: energy-and-utilities
@@ -116,30 +144,39 @@ categories:
- title: Decarbonisation and energy efficiency
slug: decarbonisation-and-energy-efficiency
support_category: Decarbonisation
+ flow: energy
- title: Electricity
slug: electricity
support_category: Electricity
+ flow: energy
- title: Gas
slug: gas
support_category: Gas
+ flow: energy
- title: Heat pumps
slug: heat-pumps
support_category: Decarbonisation
+ flow: energy
- title: LEDs (light-emitting diode)
slug: leds
support_category: Decarbonisation
+ flow: energy
- title: Other fuels
slug: other-fuels
support_category: Other fuels
+ flow: energy
- title: Solar
slug: solar
support_category: Solar
+ flow: services
- title: Water
slug: water
support_category: Water
+ flow: energy
- title: Other
slug: other
support_category: Other (Energy)
+ flow: energy
- title: Cleaning
slug: cleaning
@@ -147,15 +184,19 @@ categories:
- title: Cleaning products
slug: cleaning-products
support_category: Cleaning Products
+ flow: goods
- title: Cleaning services
slug: cleaning-services
support_category: Cleaning Services
+ flow: services
- title: Personal protection equipment (PPE)
slug: ppe
support_category: PPE
+ flow: goods
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Buildings and site maintenance
slug: buildings-and-site-maintenance
@@ -163,44 +204,56 @@ categories:
- title: Boilers and plumbing services
slug: boilers-and-plumbing-services
support_category: Boilers and plumbing services
+ flow: services
- title: Building maintenance and building management system
slug: building-maintenance-and-bms
support_category: Building maintenance & BMS
+ flow: services
- title: Cleaning
slug: cleaning
sub_categories: *cleaning_subcategories
- title: Grounds and winter maintenance
slug: grounds-and-winter-maintenance
support_category: Grounds & Winter Maintenance
+ flow: services
- title: Mechanical and electrical systems
slug: mechanical-and-electrical-systems
support_category: Mechanical & Electrical Systems
+ flow: not_fully_supported
- title: Multi-use games area
slug: mugas
support_category: MUGAs
+ flow: services
- title: Personal protection equipment (PPE)
slug: ppe
support_category: PPE
+ flow: goods
- title: Removal and relocation
slug: removal-and-relocation
description: such as furniture, classroom, moving sites
support_category: Removal & relocation
+ flow: services
- title: Security and CCTV
slug: security-and-cctv
support_category: Security & CCTV
+ flow: services
- title: Water, drains and sewerage
slug: water-drains-and-sewerage
support_category: Water, drains & sewerage
+ flow: energy
- title: Waste management
slug: waste-management
support_category: Waste management
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Furniture
slug: furniture
support_category: Furniture
+ flow: goods
- title: Health and safety
slug: health-and-safety
@@ -209,19 +262,24 @@ categories:
slug: fire-safety
description: goods and systems
support_category: Fire Safety (Goods & Systems)
+ flow: goods
- title: Personal protection equipment (PPE)
slug: ppe
description: such as masks, protective clothing and helmets
support_category: PPE
+ flow: goods
- title: Security and CCTV
slug: security-and-cctv
support_category: Security & CCTV
+ flow: services
- title: Statutory testing and facilities management compliance
slug: statutory-testing-and-fm-compliance
support_category: Statutory testing & FM Compliance
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: ICT
slug: ict
@@ -232,86 +290,111 @@ categories:
- title: Audio visual displays
slug: av-displays
support_category: AV Displays
+ flow: services
- title: Laptops
slug: laptops
support_category: Laptops
+ flow: goods
- title: Multi-functional devices (MFD)
slug: mfds
description: devices that can copy, print, scan or fax
support_category: MFD
+ flow: services
- title: Peripherals
slug: peripherals
description: such as keyboards or hard drives
support_category: Peripherals
+ flow: goods
- title: Server configuration and support
slug: server-configuration-and-support
support_category: Server Configuration & Support
+ flow: services
- title: Switches and routers
slug: switches and routers
support_category: Switches & Routers
+ flow: goods
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: ICT funding
slug: ict-funding
support_category: Funding - non procurement requests
+ is_archived: true
+ flow: services
- title: Online platforms and services
slug: online-platforms-and-services
sub_categories:
- title: Cloud SaaS (software-as-a-service)
slug: cloud-saas
support_category: Cloud SaaS
+ flow: services
- title: Cyber services
slug: cyber-services
support_category: Cyber services
+ flow: services
- title: Hosting and storage
slug: hosting-and-storage
support_category: Hosting & Storage
+ flow: services
- title: Server configuration and support
slug: server-configuration-and-support
support_category: Server Configuration & Support
+ flow: services
- title: Virtual learning environment platforms
slug: vle-platforms
support_category: Platforms (VLEs)
+ flow: services
- title: Websites
slug: websites
support_category: Websites
+ flow: services
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: Software
slug: software
sub_categories:
- title: Curriculum content
slug: curriculum-content
support_category: Curriculum Content
+ flow: services
- title: Management information system (MIS)
slug: mis
support_category: MIS
+ flow: services
- title: Operating system software
slug: os-software
support_category: OS Software
+ flow: services
- title: Server configuration and support
slug: server-configuration-and-support
support_category: Server Configuration & Support
+ flow: services
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: Telecoms and broadband
slug: telecoms-and-broadband
sub_categories:
- title: Broadband infrastructure
slug: broadband-infrastructure
support_category: Broadband Infrastructure
+ flow: services
- title: Broadband service
slug: broadband-service
support_category: Broadband service
+ flow: services
- title: Telecoms
slug: telecoms
support_category: Telecoms & Broadband
+ flow: services
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: Consultancy
slug: consultancy
@@ -320,13 +403,16 @@ categories:
slug: consultancy-direct
description: direct contract with a consultant
support_category: Consultancy
+ flow: services
- title: Managed consultancy
slug: managed-consultancy
description: consultants managed through a service
support_category: Specialist professional services
+ flow: services
- title: Other
slug: other
support_category: Other (PS)
+ flow: services
- title: Human resources and payroll
slug: human-resources-and-payroll
@@ -334,22 +420,29 @@ categories:
- title: Human resources
slug: hr
support_category: HR
+ flow: services
- title: Payroll
slug: payroll
support_category: Payroll
+ flow: services
- title: Recruitment of other staff
slug: recruitment-of-other-staff
support_category: Recruitment of other staff
+ flow: services
- title: Recruitment screening
slug: recruitment-screening
support_category: Recruitment screening
+ flow: services
- title: Supply teachers and agency workers
slug: supply-teachers-and-agency-workers
support_category: Supply Teachers & Agency workers
+ flow: services
- title: Other
slug: other
support_category: Other (PS)
+ flow: services
- title: Legal Services
slug: legal-services
support_category: Legal Services
+ flow: services
diff --git a/config/routes.rb b/config/routes.rb
index 2f866aef6..748676589 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -95,17 +95,11 @@
collection do
post "/start", to: "start#create"
- get "/energy_request", to: "energy_request#index"
- post "/energy_request", to: "energy_request#create"
+ get "/energy_bill", to: "energy_bills#index"
+ post "/energy_bill", to: "energy_bills#create"
- get "/energy_request_about", to: "energy_request_about#index"
- post "/energy_request_about", to: "energy_request_about#create"
-
- get "/energy_bill", to: "energy_bill#index"
- post "/energy_bill", to: "energy_bill#create"
-
- get "/energy_alternative", to: "energy_alternative#index"
- post "/energy_alternative", to: "energy_alternative#create"
+ get "/energy_alternative", to: "energy_alternatives#index"
+ post "/energy_alternative", to: "energy_alternatives#create"
get "/sign_in", to: "sign_in#index"
post "/sign_in", to: "sign_in#create"
@@ -149,11 +143,32 @@
get "/categories/(*category_path)", to: "categories#index", as: "categories"
post "/categories/(*category_path)", to: "categories#create"
+ get "/contract_length", to: "contract_lengths#index"
+ post "/contract_length", to: "contract_lengths#create"
+
+ get "/contract_start_date", to: "contract_start_dates#index"
+ post "/contract_start_date", to: "contract_start_dates#create"
+
+ get "/same_supplier", to: "same_suppliers#index"
+ post "/same_supplier", to: "same_suppliers#create"
+
get "/procurement_amount", to: "procurement_amounts#index"
post "/procurement_amount", to: "procurement_amounts#create"
+ get "/documents", to: "documents#index"
+ post "/documents", to: "documents#create"
+
+ get "/document_uploads", to: "document_uploads#index"
+ post "/document_uploads", to: "document_uploads#create"
+ get "(:id)/document_uploads/list", to: "document_uploads#list", as: "list_document_uploads"
+ post "(:id)/document_uploads/upload", to: "document_uploads#upload", as: "upload_document_uploads"
+ delete "(:id)/document_uploads/remove", to: "document_uploads#remove", as: "remove_document_uploads"
+
get "/special_requirements", to: "special_requirements#index"
post "/special_requirements", to: "special_requirements#create"
+
+ get "/origin", to: "origins#index"
+ post "/origin", to: "origins#create"
end
member do
resource :select_organisation, only: %i[edit update], as: :framework_request_select_organisation
@@ -164,14 +179,22 @@
resource :confirm_schools, only: %i[edit update], as: :framework_request_confirm_schools
resource :name, only: %i[edit update], as: :framework_request_name
resource :email, only: %i[edit update], as: :framework_request_email
+ resource :energy_bill, only: %i[edit update], as: :framework_request_energy_bill
+ resource :energy_alternative, only: %i[edit update], as: :framework_request_energy_alternative
resource :bill_uploads, only: %i[edit update], as: :framework_request_bill_uploads
resource :message, only: %i[edit update], as: :framework_request_message
resource :category, only: [], as: :framework_request_category do
get "edit/(*category_path)", to: "categories#edit", as: "edit"
patch "(*category_path)", to: "categories#update", as: ""
end
+ resource :contract_length, only: %i[edit update], as: :framework_request_contract_length
+ resource :contract_start_date, only: %i[edit update], as: :framework_request_contract_start_date
+ resource :same_supplier, only: %i[edit update], as: :framework_request_same_supplier
resource :procurement_amount, only: %i[edit update], as: :framework_request_procurement_amount
+ resource :documents, only: %i[edit update], as: :framework_request_documents
+ resource :document_uploads, only: %i[edit update], as: :framework_request_document_uploads
resource :special_requirements, only: %i[edit update], as: :framework_request_special_requirements
+ resource :origin, only: %i[edit update], as: :framework_request_origin
end
end
end
diff --git a/config/support/categories.yml b/config/support/categories.yml
index 194c96300..d54121c28 100644
--- a/config/support/categories.yml
+++ b/config/support/categories.yml
@@ -30,6 +30,7 @@ categories:
- title: Cyber services
slug: cyber_services
- title: Funding - non procurement requests
+ is_archived: true
- title: Hosting & Storage
slug: hosting_and_storage
- title: Laptops
diff --git a/db/migrate/20230908141955_add_flow_to_request_for_help_categories.rb b/db/migrate/20230908141955_add_flow_to_request_for_help_categories.rb
new file mode 100644
index 000000000..ec8dec895
--- /dev/null
+++ b/db/migrate/20230908141955_add_flow_to_request_for_help_categories.rb
@@ -0,0 +1,5 @@
+class AddFlowToRequestForHelpCategories < ActiveRecord::Migration[7.0]
+ def change
+ add_column :request_for_help_categories, :flow, :int
+ end
+end
diff --git a/db/migrate/20230913105429_add_contract_length_to_framework_requests.rb b/db/migrate/20230913105429_add_contract_length_to_framework_requests.rb
new file mode 100644
index 000000000..71c53f366
--- /dev/null
+++ b/db/migrate/20230913105429_add_contract_length_to_framework_requests.rb
@@ -0,0 +1,5 @@
+class AddContractLengthToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ add_column :framework_requests, :contract_length, :integer
+ end
+end
diff --git a/db/migrate/20230913125303_add_contract_start_date_to_framework_requests.rb b/db/migrate/20230913125303_add_contract_start_date_to_framework_requests.rb
new file mode 100644
index 000000000..5772719ec
--- /dev/null
+++ b/db/migrate/20230913125303_add_contract_start_date_to_framework_requests.rb
@@ -0,0 +1,8 @@
+class AddContractStartDateToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ change_table :framework_requests, bulk: true do |t|
+ t.column :contract_start_date_known, :boolean
+ t.column :contract_start_date, :date
+ end
+ end
+end
diff --git a/db/migrate/20230913152536_add_same_supplier_used_to_framework_requests.rb b/db/migrate/20230913152536_add_same_supplier_used_to_framework_requests.rb
new file mode 100644
index 000000000..1859df2b0
--- /dev/null
+++ b/db/migrate/20230913152536_add_same_supplier_used_to_framework_requests.rb
@@ -0,0 +1,5 @@
+class AddSameSupplierUsedToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ add_column :framework_requests, :same_supplier_used, :integer
+ end
+end
diff --git a/db/migrate/20230915140037_add_document_types_to_framework_requests.rb b/db/migrate/20230915140037_add_document_types_to_framework_requests.rb
new file mode 100644
index 000000000..d51433b64
--- /dev/null
+++ b/db/migrate/20230915140037_add_document_types_to_framework_requests.rb
@@ -0,0 +1,8 @@
+class AddDocumentTypesToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ change_table :framework_requests, bulk: true do |t|
+ t.column :document_types, :string, array: true, default: []
+ t.column :document_type_other, :text
+ end
+ end
+end
diff --git a/db/migrate/20230915155648_create_documents.rb b/db/migrate/20230915155648_create_documents.rb
new file mode 100644
index 000000000..12ccaf310
--- /dev/null
+++ b/db/migrate/20230915155648_create_documents.rb
@@ -0,0 +1,13 @@
+class CreateDocuments < ActiveRecord::Migration[7.0]
+ def change
+ create_table :documents, id: :uuid do |t|
+ t.integer :submission_status, default: 0
+ t.string :filename
+ t.integer :filesize
+ t.references :support_case, foreign_key: { to_table: :support_cases }, type: :uuid
+ t.references :framework_request, foreign_key: { to_table: :framework_requests }, type: :uuid
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20230918155242_add_origin_to_framework_requests.rb b/db/migrate/20230918155242_add_origin_to_framework_requests.rb
new file mode 100644
index 000000000..341bb201f
--- /dev/null
+++ b/db/migrate/20230918155242_add_origin_to_framework_requests.rb
@@ -0,0 +1,8 @@
+class AddOriginToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ change_table :framework_requests, bulk: true do |t|
+ t.column :origin, :integer
+ t.column :origin_other, :text
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 866247395..7a9d23ddd 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -121,6 +121,18 @@
t.index ["step_id"], name: "index_currency_answers_on_step_id"
end
+ create_table "documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+ t.integer "submission_status", default: 0
+ t.string "filename"
+ t.integer "filesize"
+ t.uuid "support_case_id"
+ t.uuid "framework_request_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["framework_request_id"], name: "index_documents_on_framework_request_id"
+ t.index ["support_case_id"], name: "index_documents_on_support_case_id"
+ end
+
create_table "energy_bills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.integer "submission_status", default: 0
t.string "filename"
@@ -204,6 +216,14 @@
t.text "category_other"
t.string "school_urns", default: [], array: true
t.uuid "support_case_id"
+ t.integer "contract_length"
+ t.boolean "contract_start_date_known"
+ t.date "contract_start_date"
+ t.integer "same_supplier_used"
+ t.string "document_types", default: [], array: true
+ t.text "document_type_other"
+ t.integer "origin"
+ t.text "origin_other"
t.index ["category_id"], name: "index_framework_requests_on_category_id"
t.index ["support_case_id"], name: "index_framework_requests_on_support_case_id"
t.index ["user_id"], name: "index_framework_requests_on_user_id"
@@ -348,6 +368,7 @@
t.datetime "archived_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "flow"
t.index ["parent_id"], name: "index_request_for_help_categories_on_parent_id"
t.index ["slug"], name: "index_request_for_help_categories_on_slug"
t.index ["support_category_id"], name: "index_request_for_help_categories_on_support_category_id"
@@ -887,6 +908,8 @@
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "all_cases_survey_responses", "support_cases", column: "case_id"
+ add_foreign_key "documents", "framework_requests"
+ add_foreign_key "documents", "support_cases"
add_foreign_key "exit_survey_responses", "support_cases", column: "case_id"
add_foreign_key "framework_requests", "request_for_help_categories", column: "category_id"
add_foreign_key "framework_requests", "support_cases"
diff --git a/spec/controllers/framework_requests/base_controller_spec.rb b/spec/controllers/framework_requests/base_controller_spec.rb
deleted file mode 100644
index 53b3560b6..000000000
--- a/spec/controllers/framework_requests/base_controller_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-describe FrameworkRequests::BaseController, type: :controller do
- describe "#last_energy_path" do
- before do
- allow(controller).to receive(:framework_request).and_return(framework_request)
- allow(controller).to receive(:form).and_return(FrameworkRequests::BaseForm.new(user: build(:user)))
- end
-
- context "when the energy alternative question has been answered" do
- let(:framework_request) { build(:framework_request, energy_alternative: "different_format") }
-
- it "returns the energy alternative path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_alternative"
- end
- end
-
- context "when the energy bill question has been answered" do
- let(:framework_request) { build(:framework_request, have_energy_bill: true) }
-
- it "returns the energy bill path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_bill"
- end
- end
-
- context "when the energy request about question has been answered" do
- let(:framework_request) { build(:framework_request, energy_request_about: "energy_contract") }
-
- it "returns the energy request about path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_request_about"
- end
- end
-
- context "when none of the other energy questions have been answered" do
- let(:framework_request) { build(:framework_request) }
-
- it "returns the energy request path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_request"
- end
- end
- end
-end
diff --git a/spec/controllers/framework_requests/bill_uploads_controller_spec.rb b/spec/controllers/framework_requests/bill_uploads_controller_spec.rb
index 4e73a3b53..1560d80c4 100644
--- a/spec/controllers/framework_requests/bill_uploads_controller_spec.rb
+++ b/spec/controllers/framework_requests/bill_uploads_controller_spec.rb
@@ -1,32 +1,80 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::BillUploadsController, type: :controller do
- it "redirects to the message page" do
- post :create
- expect(response).to redirect_to "/procurement-support/message"
+ describe "on create" do
+ it "redirects to the accessibility needs page" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+
+ describe "back url" do
+ include_examples "back url", "/procurement-support/energy_bill"
+
+ context "when an alternative to energy bills is selected" do
+ let(:framework_request) { create(:framework_request, energy_alternative: :different_format) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/energy_alternative"
+ end
+ end
+ end
end
- describe "back url" do
- context "when the user is signed in" do
- before { user_is_signed_in(user:) }
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy"), energy_alternative:) }
+ let(:energy_alternative) { nil }
+
+ context "when coming in from the check-your-answers page" do
+ let(:framework_support_form) { { framework_support_form: { source: "change_link" } } }
+ let(:params) { { id: framework_request.id, **framework_support_form } }
+
+ before { get :edit, params: }
- context "when the user belongs to one organisation" do
- let(:user) { build(:user, :one_supported_school) }
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when coming in from elsewhere" do
+ let(:params) { { id: framework_request.id } }
- before { allow(controller).to receive(:last_energy_path).and_return("last_energy_path") }
+ context "when the user selected to upload bills straight away" do
+ let(:energy_alternative) { nil }
- include_examples "back url", "last_energy_path"
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the energy bill page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/energy_bill/edit"
+ end
end
- context "when the user belongs to multiple organisations" do
- let(:user) { build(:user, :many_supported_schools) }
+ context "when the user selected to upload bills via energy alternative" do
+ let(:energy_alternative) { :different_format }
+
+ before do
+ get :edit, params:
+ end
- include_examples "back url", "/procurement-support/select_organisation"
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/energy_alternative/edit"
+ end
end
end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+
+ before do
+ patch :update, params: { id: framework_request.id }
+ end
- context "when the user is not signed in" do
- include_examples "back url", "/procurement-support/email"
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
end
end
end
diff --git a/spec/controllers/framework_requests/categories_controller_spec.rb b/spec/controllers/framework_requests/categories_controller_spec.rb
index 670de7014..c6fe2a2d4 100644
--- a/spec/controllers/framework_requests/categories_controller_spec.rb
+++ b/spec/controllers/framework_requests/categories_controller_spec.rb
@@ -1,11 +1,10 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::CategoriesController, type: :controller do
- let(:framework_request) { create(:framework_request, category:, is_energy_request:, energy_request_about:, have_energy_bill:) }
+ let(:framework_request) { create(:framework_request, category:, group:, org_id:) }
let(:category) { nil }
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ let(:group) { nil }
+ let(:org_id) { nil }
let(:a) { create(:request_for_help_category, slug: "a") }
let(:b) { create(:request_for_help_category, slug: "b", parent: a) }
@@ -22,10 +21,53 @@
end
context "when the user is on the main categories page" do
- before { get :index, session: { framework_request_id: framework_request.id } }
+ context "and the user is signed in" do
+ before { user_is_signed_in(user:) }
- it "goes back to the message page" do
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/message"
+ context "and the user belongs to a MAT or federation with multiple schools" do
+ let(:user) { build(:user, :one_supported_group) }
+ let(:group) { true }
+ let(:org_id) { "2314" }
+
+ before do
+ establishment_group_type = create(:support_establishment_group_type, code: 6)
+ create(:support_establishment_group, name: "Testing Multi Academy Trust", uid: "2314", establishment_group_type:)
+ create_list(:support_organisation, 2, trust_code: "2314")
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the schools confirmation page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/confirm_schools"
+ end
+ end
+
+ context "and the user belongs to a single chosen organisation" do
+ let(:user) { build(:user, :many_supported_schools) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the select organisation page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/select_organisation"
+ end
+ end
+
+ context "and the user belongs to a single inferred organisation" do
+ let(:user) { build(:user, :one_supported_school) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the confirm sign-in page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/confirm_sign_in"
+ end
+ end
+ end
+
+ context "and the user is a guest" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the email page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/email"
+ end
end
end
@@ -92,22 +134,29 @@
end
context "when the user has chosen a final category" do
- before { post :create, params: { category_path: "a/b", framework_support_form: { category_slug: "c" } }, session: { framework_request_id: framework_request.id } }
+ before do
+ c.update!(flow:)
+ post :create, params: { category_path: "a/b", framework_support_form: { category_slug: "c" } }, session: { framework_request_id: framework_request.id }
+ end
+
+ context "and they are in the services flow" do
+ let(:flow) { :services }
+
+ it "redirects to the contract length page" do
+ expect(response).to redirect_to("/procurement-support/contract_length")
+ end
+ end
- context "and they have chosen to upload a bill" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { "energy_contract" }
- let(:have_energy_bill) { true }
+ context "and they are in the energy flow" do
+ let(:flow) { :energy }
- it "redirects to the accessibility page" do
- expect(response).to redirect_to("/procurement-support/special_requirements")
+ it "redirects to the contract length page" do
+ expect(response).to redirect_to("/procurement-support/contract_length")
end
end
- context "and they have chosen not to upload a bill" do
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ context "and they are not in the energy or services flow" do
+ let(:flow) { :goods }
it "redirects to the procurement amount page" do
expect(response).to redirect_to("/procurement-support/procurement_amount")
@@ -141,14 +190,29 @@
context "when the user has chosen a final category" do
let(:patch_action) { patch :update, params: { id: framework_request.id, category_path: "a/b", framework_support_form: { category_slug: "c" } } }
- it "redirects to the check-your-answers page" do
- patch_action
- expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
- end
-
it "persists the final category" do
expect { patch_action }.to change { framework_request.reload.category }.from(nil).to(c)
end
+
+ context "and the flow is finished" do
+ it "redirects to the check-your-answers page" do
+ patch_action
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+
+ context "and the flow is unfinished" do
+ let(:category) { create(:request_for_help_category, slug: "d", flow: :goods) }
+ let(:e) { create(:request_for_help_category, slug: "e", parent: b, flow: :services) }
+
+ before do
+ patch :update, params: { id: framework_request.id, category_path: "a/b", framework_support_form: { category_slug: e.slug } }
+ end
+
+ it "redirects to the contract length page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/contract_length/edit")
+ end
+ end
end
end
end
diff --git a/spec/controllers/framework_requests/confirm_schools_controller_spec.rb b/spec/controllers/framework_requests/confirm_schools_controller_spec.rb
index c25725cf4..8a9faa56d 100644
--- a/spec/controllers/framework_requests/confirm_schools_controller_spec.rb
+++ b/spec/controllers/framework_requests/confirm_schools_controller_spec.rb
@@ -1,10 +1,11 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::ConfirmSchoolsController, type: :controller do
- let(:framework_request) { create(:framework_request) }
+ let(:framework_request) { create(:framework_request, category:) }
let(:school_urns_confirmed) { false }
let(:school_urns) { %w[1 2] }
let(:framework_support_form) { { framework_support_form: { school_urns:, school_urns_confirmed: } } }
+ let(:category) { nil }
let(:params) { framework_support_form }
describe "create" do
@@ -13,21 +14,12 @@
context "when the schools are confirmed" do
let(:school_urns_confirmed) { true }
- context "and it is an energy request" do
- let(:framework_request) { create(:framework_request, :energy_request) }
-
- it "redirects to the bill upload page" do
- post(:create, params:, session:)
- expect(response).to redirect_to "/procurement-support/bill_uploads"
- end
- end
-
context "and the user is signed in" do
before { user_is_signed_in }
- it "redirects to the message page" do
+ it "redirects to the categories page" do
post(:create, params:, session:)
- expect(response).to redirect_to "/procurement-support/message"
+ expect(response).to redirect_to "/procurement-support/categories"
end
end
@@ -55,9 +47,35 @@
context "when the schools are confirmed" do
let(:school_urns_confirmed) { true }
- it "redirects to the request" do
- patch(:update, params:)
- expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ context "and a single school has been selected" do
+ let(:school_urns) { %w[1] }
+
+ it "redirects to the request" do
+ patch(:update, params:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "and multiple schools have been selected" do
+ let(:school_urns) { %w[1 2] }
+
+ context "and the user is in the services flow" do
+ let(:category) { create(:request_for_help_category, flow: :services) }
+
+ it "redirects to the same supplier page" do
+ patch(:update, params:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
+
+ context "and the user is in the energy flow" do
+ let(:category) { create(:request_for_help_category, flow: :energy) }
+
+ it "redirects to the same supplier page" do
+ patch(:update, params:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
end
end
diff --git a/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb b/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb
index a9e88ee13..11946f555 100644
--- a/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb
+++ b/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb
@@ -13,21 +13,23 @@
context "when the user belongs to one organisation" do
let(:user) { build(:user, :one_supported_school) }
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
-
- it "redirects to the message page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/message"
- end
+ it "redirects to the categories page" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/categories"
end
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ context "and the organisation is a MAT or federation with multiple schools" do
+ let(:user) { build(:user, :one_supported_group) }
+
+ before do
+ establishment_group_type = create(:support_establishment_group_type, code: 6)
+ create(:support_establishment_group, name: "Testing Multi Academy Trust", uid: "2314", establishment_group_type:)
+ create_list(:support_organisation, 2, trust_code: "2314")
+ end
- it "redirects to the bill upload page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/bill_uploads"
+ it "redirects to the school picker page" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/school_picker"
end
end
end
diff --git a/spec/controllers/framework_requests/contract_lengths_controller_spec.rb b/spec/controllers/framework_requests/contract_lengths_controller_spec.rb
new file mode 100644
index 000000000..7e63a6770
--- /dev/null
+++ b/spec/controllers/framework_requests/contract_lengths_controller_spec.rb
@@ -0,0 +1,73 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::ContractLengthsController, type: :controller do
+ include_examples "back url", "/procurement-support/categories"
+
+ describe "on create" do
+ it "redirects to the contract start date page" do
+ params = { framework_support_form: { contract_length: "not_sure" } }
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/contract_start_date"
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_length:, contract_start_date_known:) }
+
+ context "when the flow is unfinished" do
+ let(:contract_length) { nil }
+ let(:contract_start_date_known) { nil }
+
+ before do
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the categories page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/category/edit"
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:contract_length) { :one_year }
+ let(:contract_start_date_known) { false }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_start_date_known:) }
+
+ context "when the flow is unfinished" do
+ let(:contract_start_date_known) { nil }
+
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_length: "one_year" } }
+ end
+
+ it "redirects to the contract start date page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/contract_start_date/edit")
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:contract_start_date_known) { false }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_length: "one_year" } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/contract_start_dates_controller_spec.rb b/spec/controllers/framework_requests/contract_start_dates_controller_spec.rb
new file mode 100644
index 000000000..0fb1076ef
--- /dev/null
+++ b/spec/controllers/framework_requests/contract_start_dates_controller_spec.rb
@@ -0,0 +1,111 @@
+describe FrameworkRequests::ContractStartDatesController, type: :controller do
+ let(:framework_request) { create(:framework_request) }
+
+ it "goes back to the contract length page" do
+ get(:index, params: { framework_support_form: { contract_start_date_known: nil } })
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/contract_length"
+ end
+
+ describe "on create" do
+ let(:params) { { framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } } }
+ let(:session) { { framework_request_id: framework_request.id } }
+
+ context "when multiple schools are selected" do
+ before { framework_request.update!(school_urns: %w[1 2]) }
+
+ it "redirects to the all schools same supplier page" do
+ post(:create, params:, session:)
+ expect(response).to redirect_to "/procurement-support/same_supplier"
+ end
+ end
+
+ context "when a single organisation is selected" do
+ it "redirects to the procurement amount page" do
+ post(:create, params:, session:)
+ expect(response).to redirect_to "/procurement-support/procurement_amount"
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_length: :one_year, contract_start_date_known: false) }
+
+ context "when the flow is unfinished" do
+ before do
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the contract length page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_length/edit"
+ end
+ end
+
+ context "when the flow is finished" do
+ before do
+ framework_request.update!(document_types: %w[none])
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, contract_length: :one_year, category:) }
+ let(:category) { create(:request_for_help_category, flow: "services") }
+
+ context "when the flow is unfinished" do
+ context "and the organisation is a MAT with multiple selected schools" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } }
+ end
+
+ it "redirects to the same supplier page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/same_supplier/edit")
+ end
+ end
+
+ context "and the organisation is a single school" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } }
+ end
+
+ context "and the user has chosen gas or electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: "energy") }
+
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: false } }
+ end
+
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/energy_bill/edit")
+ end
+ end
+
+ context "and the user has chosen a service or a different energy category" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: false } }
+ end
+
+ it "redirects to the documents page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/documents/edit")
+ end
+ end
+ end
+ end
+
+ context "when the flow is finished" do
+ before do
+ framework_request.update!(document_types: %w[none])
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/document_uploads_controller_spec.rb b/spec/controllers/framework_requests/document_uploads_controller_spec.rb
new file mode 100644
index 000000000..d2992d505
--- /dev/null
+++ b/spec/controllers/framework_requests/document_uploads_controller_spec.rb
@@ -0,0 +1,49 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::DocumentUploadsController, type: :controller do
+ include_examples "back url", "/procurement-support/documents"
+
+ describe "on create" do
+ it "redirects to the accessibility needs page" do
+ post(:create)
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+
+ before do
+ patch :update, params: { id: framework_request.id }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+
+ context "when coming in from the check-your-answers page" do
+ let(:framework_support_form) { { framework_support_form: { source: "change_link" } } }
+ let(:params) { { id: framework_request.id, **framework_support_form } }
+
+ before { get :edit, params: }
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when coming in from elsewhere" do
+ let(:params) { { id: framework_request.id } }
+
+ before { get :edit, params: }
+
+ it "goes back to the documents page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/documents/edit"
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/documents_controller_spec.rb b/spec/controllers/framework_requests/documents_controller_spec.rb
new file mode 100644
index 000000000..c1ba75b8f
--- /dev/null
+++ b/spec/controllers/framework_requests/documents_controller_spec.rb
@@ -0,0 +1,75 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::DocumentsController, type: :controller do
+ include_examples "back url", "/procurement-support/message"
+
+ describe "on create" do
+ context "when the document type is none" do
+ let(:params) { { framework_support_form: { document_types: %w[none] } } }
+
+ it "redirects to the accessibility needs page" do
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ context "when the document types are anything else" do
+ let(:params) { { framework_support_form: { document_types: %w[floor_plans] } } }
+
+ it "redirects to the document upload page" do
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/document_uploads"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+
+ context "when the document type is none" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { document_types: %w[none] } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+
+ context "when the document types are anything else" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { document_types: %w[floor_plans] } }
+ end
+
+ it "redirects to the document uploads page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/document_uploads/edit")
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+ let(:params) { { id: framework_request.id } }
+
+ context "when the request is for a MAT with multiple schools" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :edit, params:
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
+
+ context "when the request is for a single school" do
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_start_date/edit"
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/emails_controller_spec.rb b/spec/controllers/framework_requests/emails_controller_spec.rb
index f7dfc1913..868edcbc2 100644
--- a/spec/controllers/framework_requests/emails_controller_spec.rb
+++ b/spec/controllers/framework_requests/emails_controller_spec.rb
@@ -3,21 +3,8 @@
describe FrameworkRequests::EmailsController, type: :controller do
include_examples "back url", "/procurement-support/name"
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
-
- it "redirects to the bill upload page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/bill_uploads"
- end
- end
-
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
-
- it "redirects to the message page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/message"
- end
+ it "redirects to the categories page" do
+ post :create, params: { framework_support_form: { email: "test@example.com" } }
+ expect(response).to redirect_to "/procurement-support/categories"
end
end
diff --git a/spec/controllers/framework_requests/energy_alternative_controller_spec.rb b/spec/controllers/framework_requests/energy_alternative_controller_spec.rb
deleted file mode 100644
index 5f44904c7..000000000
--- a/spec/controllers/framework_requests/energy_alternative_controller_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyAlternativeController, type: :controller do
- include_examples "back url", "/procurement-support/energy_bill"
-
- context "when the user has selected different format" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "different_format" } }
- end
-
- context "when the user has selected email later" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "email_later" } }
- end
-
- context "when the user has selected no bill" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "no_bill" } }
- end
-
- context "when the user has selected no thanks" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "no_thanks" } }
- end
-end
diff --git a/spec/controllers/framework_requests/energy_alternatives_controller_spec.rb b/spec/controllers/framework_requests/energy_alternatives_controller_spec.rb
new file mode 100644
index 000000000..4a79fad0c
--- /dev/null
+++ b/spec/controllers/framework_requests/energy_alternatives_controller_spec.rb
@@ -0,0 +1,88 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::EnergyAlternativesController, type: :controller do
+ include_examples "back url", "/procurement-support/energy_bill"
+
+ describe "on create" do
+ context "when the user has selected different format" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "different_format" } } }
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to "/procurement-support/bill_uploads"
+ end
+ end
+
+ context "when the user has selected to email later" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "email_later" } } }
+
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ context "when the user has selected no bill" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "no_bill" } } }
+
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ context "when the user has selected no thanks" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "no_thanks" } } }
+
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+
+ context "when the user has selected different format" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "different_format" } } }
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}/bill_uploads/edit"
+ end
+ end
+
+ context "when the user has selected to email later" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "email_later" } } }
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when the user has selected no bill" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "no_bill" } } }
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when the user has selected no thanks" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "no_thanks" } } }
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+ let(:params) { { id: framework_request.id } }
+
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the energy bill page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/energy_bill/edit"
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/energy_bill_controller_spec.rb b/spec/controllers/framework_requests/energy_bill_controller_spec.rb
deleted file mode 100644
index 9c848ebb9..000000000
--- a/spec/controllers/framework_requests/energy_bill_controller_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyBillController, type: :controller do
- include_examples "back url", "/procurement-support/energy_request_about"
-
- context "when the user has no bill" do
- before { post :create, params: { framework_support_form: { have_energy_bill: "false" } } }
-
- it "redirects to the energy alternative page" do
- expect(response).to redirect_to "/procurement-support/energy_alternative"
- end
- end
-
- context "when the user has a bill" do
- include_examples "sign-in redirects", { framework_support_form: { have_energy_bill: "true" } }
- end
-end
diff --git a/spec/controllers/framework_requests/energy_bills_controller_spec.rb b/spec/controllers/framework_requests/energy_bills_controller_spec.rb
new file mode 100644
index 000000000..d16e2926f
--- /dev/null
+++ b/spec/controllers/framework_requests/energy_bills_controller_spec.rb
@@ -0,0 +1,73 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::EnergyBillsController, type: :controller do
+ include_examples "back url", "/procurement-support/message"
+
+ describe "on create" do
+ context "when the user has no bill" do
+ before { post :create, params: { framework_support_form: { have_energy_bill: "false" } } }
+
+ it "redirects to the energy alternative page" do
+ expect(response).to redirect_to "/procurement-support/energy_alternative"
+ end
+ end
+
+ context "when the user has a bill" do
+ before { post :create, params: { framework_support_form: { have_energy_bill: "true" } } }
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to "/procurement-support/bill_uploads"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+
+ context "when the user has an energy bill" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { have_energy_bill: "true" } }
+ end
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/bill_uploads/edit")
+ end
+ end
+
+ context "when the user does not have an energy bill" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { have_energy_bill: "false" } }
+ end
+
+ it "redirects to the energy alternative page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/energy_alternative/edit")
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+ let(:params) { { id: framework_request.id } }
+
+ context "when the request is for a MAT with multiple schools" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :edit, params:
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
+
+ context "when the request is for a single school" do
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_start_date/edit"
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/energy_request_about_controller_spec.rb b/spec/controllers/framework_requests/energy_request_about_controller_spec.rb
deleted file mode 100644
index a2d4ed32c..000000000
--- a/spec/controllers/framework_requests/energy_request_about_controller_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyRequestAboutController, type: :controller do
- include_examples "back url", "/procurement-support/energy_request"
-
- context "when it is about an energy contract" do
- before { post :create, params: { framework_support_form: { energy_request_about: "energy_contract" } } }
-
- it "redirects to the energy bill page" do
- expect(response).to redirect_to "/procurement-support/energy_bill"
- end
- end
-
- context "when it is not about an energy contract" do
- include_examples "sign-in redirects", { framework_support_form: { energy_request_about: "not_energy_contract" } }
- end
-end
diff --git a/spec/controllers/framework_requests/energy_request_controller_spec.rb b/spec/controllers/framework_requests/energy_request_controller_spec.rb
deleted file mode 100644
index 062497ca8..000000000
--- a/spec/controllers/framework_requests/energy_request_controller_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyRequestController, type: :controller do
- include_examples "back url", "/procurement-support"
-
- context "when it is an energy request" do
- before { post :create, params: { framework_support_form: { is_energy_request: "true" } } }
-
- it "redirects to the energy request about page" do
- expect(response).to redirect_to "/procurement-support/energy_request_about"
- end
- end
-
- context "when it is not an energy request" do
- include_examples "sign-in redirects", { framework_support_form: { is_energy_request: "false" } }
- end
-end
diff --git a/spec/controllers/framework_requests/messages_controller_spec.rb b/spec/controllers/framework_requests/messages_controller_spec.rb
index eef68f367..4bd2e6c02 100644
--- a/spec/controllers/framework_requests/messages_controller_spec.rb
+++ b/spec/controllers/framework_requests/messages_controller_spec.rb
@@ -1,71 +1,70 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::MessagesController, type: :controller do
- context "when feature :energy_bill_flow is not enabled" do
- let(:framework_request) { create(:framework_request) }
+ let(:framework_request) { create(:framework_request, category:) }
+ let(:category) { nil }
- before { Flipper.disable(:energy_bill_flow) }
+ include_examples "back url", "/procurement-support/procurement_amount"
- it "redirects to the category page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/categories"
- end
- end
+ context "when the request is in the energy flow" do
+ context "and about electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: :energy) }
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
- it "redirects to the category page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/categories"
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to "/procurement-support/energy_bill"
+ end
end
- end
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
+ context "and about gas" do
+ let(:category) { create(:request_for_help_category, slug: "gas", flow: :energy) }
+
+ before { post :create, session: { framework_request_id: framework_request.id } }
- it "redirects to the category page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/categories"
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to "/procurement-support/energy_bill"
+ end
end
- end
- describe "back url" do
- context "when the user is signed in" do
- before { user_is_signed_in(user:) }
+ context "and about anything else" do
+ let(:category) { create(:request_for_help_category, slug: "water", flow: :energy) }
- context "when the user belongs to one organisation" do
- let(:user) { build(:user, :one_supported_school) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
+
+ it "redirects to the documents page" do
+ expect(response).to redirect_to "/procurement-support/documents"
+ end
+ end
+ end
- before { allow(controller).to receive(:last_energy_path).and_return("last_energy_path") }
+ context "when the request is in the services flow" do
+ let(:category) { create(:request_for_help_category, slug: "catering-services", flow: :services) }
- include_examples "back url", "last_energy_path"
+ before { post :create, session: { framework_request_id: framework_request.id } }
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
+ it "redirects to the documents page" do
+ expect(response).to redirect_to "/procurement-support/documents"
+ end
+ end
- include_examples "back url", "/procurement-support/select_organisation"
- end
- end
+ context "when the request is in the goods flow" do
+ let(:category) { create(:request_for_help_category, slug: "books", flow: :goods) }
- context "when the user belongs to multiple organisations" do
- let(:user) { build(:user, :many_supported_schools) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
- include_examples "back url", "/procurement-support/select_organisation"
- end
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
end
+ end
- context "when the user is not signed in" do
- include_examples "back url", "/procurement-support/email"
- end
+ context "when the request is in the not-fully-supported flow" do
+ let(:category) { create(:request_for_help_category, slug: "uniform", flow: :not_fully_supported) }
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
- it "goes back to the bill upload page" do
- get :index, session: { framework_request_id: framework_request.id }
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/bill_uploads"
- end
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
end
end
end
diff --git a/spec/controllers/framework_requests/origins_controller_spec.rb b/spec/controllers/framework_requests/origins_controller_spec.rb
new file mode 100644
index 000000000..58ea8e569
--- /dev/null
+++ b/spec/controllers/framework_requests/origins_controller_spec.rb
@@ -0,0 +1,14 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::OriginsController, type: :controller do
+ let(:framework_request) { create(:framework_request) }
+
+ include_examples "back url", "/procurement-support/special_requirements"
+
+ it "redirects to the framework request page" do
+ params = { framework_support_form: { origin: "website" } }
+ session = { framework_request_id: framework_request.id }
+ post(:create, params:, session:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+end
diff --git a/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb b/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb
index b94d64a28..368376d84 100644
--- a/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb
+++ b/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb
@@ -1,10 +1,69 @@
-require "./spec/support/shared/framework_request_controllers"
-
describe FrameworkRequests::ProcurementAmountsController, type: :controller do
- include_examples "back url", "/procurement-support/categories"
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow:)) }
+ let(:flow) { nil }
+
+ it "redirects to the message page" do
+ post :create, params: { framework_support_form: { procurement_amount: "205.13" } }
+ expect(response).to redirect_to "/procurement-support/message"
+ end
+
+ describe "back url" do
+ describe "on index" do
+ context "when the user is in the services flow" do
+ let(:flow) { "services" }
+
+ context "and it is not a multi-school request" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/contract_start_date"
+ end
+ end
+
+ context "and it is a multi-school request" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/same_supplier"
+ end
+ end
+ end
+
+ context "when the user is in the energy flow" do
+ let(:flow) { "energy" }
+
+ context "and it is not a multi-school request" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/contract_start_date"
+ end
+ end
+
+ context "and it is a multi-school request" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/same_supplier"
+ end
+ end
+ end
+
+ context "when the user is in a different flow" do
+ let(:flow) { "goods" }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
- it "redirects to the special requirements page" do
- post :create
- expect(response).to redirect_to "/procurement-support/special_requirements"
+ it "goes back to the categories page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/categories"
+ end
+ end
+ end
end
end
diff --git a/spec/controllers/framework_requests/same_suppliers_controller_spec.rb b/spec/controllers/framework_requests/same_suppliers_controller_spec.rb
new file mode 100644
index 000000000..f135576ad
--- /dev/null
+++ b/spec/controllers/framework_requests/same_suppliers_controller_spec.rb
@@ -0,0 +1,93 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::SameSuppliersController, type: :controller do
+ include_examples "back url", "/procurement-support/contract_start_date"
+
+ describe "on create" do
+ it "redirects to the procurement amount page" do
+ params = { framework_support_form: { same_supplier_used: "yes" } }
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/procurement_amount"
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_length: :one_year, contract_start_date_known: false) }
+
+ context "when coming in from the check-your-answers page" do
+ let(:framework_support_form) { { framework_support_form: { source: "change_link" } } }
+ let(:params) { { id: framework_request.id, **framework_support_form } }
+
+ before { get :edit, params: }
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when the flow is unfinished" do
+ let(:params) { { id: framework_request.id } }
+
+ before { get :edit, params: }
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_start_date/edit"
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:params) { { id: framework_request.id } }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ get :edit, params:
+ end
+
+ it "goes back to the confirm schools page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/confirm_schools/edit"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, contract_length: :one_year, contract_start_date_known: false, category:) }
+ let(:category) { create(:request_for_help_category, flow: "services") }
+
+ context "when the flow is unfinished" do
+ context "and the user has chosen gas or electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: "energy") }
+
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { same_supplier_used: "yes" } }
+ end
+
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/energy_bill/edit")
+ end
+ end
+
+ context "and the user has chosen a service or a different energy category" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { same_supplier_used: "yes" } }
+ end
+
+ it "redirects to the documents page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/documents/edit")
+ end
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:contract_start_date) { Date.parse("2023-09-21") }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ patch :update, params: { id: framework_request.id, framework_support_form: { same_supplier_used: "yes" } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/select_organisations_controller_spec.rb b/spec/controllers/framework_requests/select_organisations_controller_spec.rb
index 4b7560a06..27c7cffc9 100644
--- a/spec/controllers/framework_requests/select_organisations_controller_spec.rb
+++ b/spec/controllers/framework_requests/select_organisations_controller_spec.rb
@@ -3,26 +3,34 @@
describe FrameworkRequests::SelectOrganisationsController, type: :controller do
before do
user_is_signed_in
- allow(controller).to receive(:last_energy_path).and_return "last_energy_path"
end
- include_examples "back url", "last_energy_path"
+ include_examples "back url", "/procurement-support/confirm_sign_in"
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ context "when the user has chosen a MAT or federation" do
+ let(:framework_request) { create(:framework_request) }
- it "redirects to the bill upload page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/bill_uploads"
+ before do
+ create(:support_establishment_group, uid: "123", establishment_group_type: create(:support_establishment_group_type, code: 2))
+ create(:support_organisation, trust_code: "123")
+ end
+
+ it "redirects to the school picker" do
+ post :create, params: { framework_support_form: { group: "true", org_id: "123" } }, session: { framework_request_id: framework_request.id }
+ expect(response).to redirect_to "/procurement-support/school_picker"
end
end
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
+ context "when the user has chosen a single school" do
+ let(:framework_request) { create(:framework_request) }
+
+ before do
+ create(:support_organisation, urn: "123")
+ end
- it "redirects to the message page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/message"
+ it "redirects to the categories page" do
+ post :create, params: { framework_support_form: { group: "false", org_id: "123" } }, session: { framework_request_id: framework_request.id }
+ expect(response).to redirect_to "/procurement-support/categories"
end
end
end
diff --git a/spec/controllers/framework_requests/sign_in_controller_spec.rb b/spec/controllers/framework_requests/sign_in_controller_spec.rb
index 4f48b0410..e3b6b7a25 100644
--- a/spec/controllers/framework_requests/sign_in_controller_spec.rb
+++ b/spec/controllers/framework_requests/sign_in_controller_spec.rb
@@ -18,16 +18,7 @@
end
context "when a back url is not provided" do
- include_examples "back url", "/procurement-support/energy_request"
-
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
-
- it "goes back to the start" do
- get :index
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support"
- end
- end
+ include_examples "back url", "/procurement-support"
end
end
end
diff --git a/spec/controllers/framework_requests/special_requirements_controller_spec.rb b/spec/controllers/framework_requests/special_requirements_controller_spec.rb
index 8dd8578f0..800e5e5aa 100644
--- a/spec/controllers/framework_requests/special_requirements_controller_spec.rb
+++ b/spec/controllers/framework_requests/special_requirements_controller_spec.rb
@@ -1,36 +1,117 @@
describe FrameworkRequests::SpecialRequirementsController, type: :controller do
- let(:framework_request) { create(:framework_request, is_energy_request:, energy_request_about:, have_energy_bill:) }
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ let(:framework_request) { create(:framework_request, category:) }
+ let(:category) { create(:request_for_help_category, flow:) }
+ let(:flow) { nil }
- it "redirects to the framework request page" do
+ it "redirects to the origin page" do
params = { framework_support_form: { special_requirements_choice: "no" } }
session = { framework_request_id: framework_request.id }
post(:create, params:, session:)
- expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ expect(response).to redirect_to "/procurement-support/origin?#{params.to_query}"
end
describe "back url" do
- context "when the user has chosen to upload a bill" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { "energy_contract" }
- let(:have_energy_bill) { true }
-
- it "goes back to the categories page" do
- get :index, session: { framework_request_id: framework_request.id }
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/categories"
+ context "when the request is in the energy flow" do
+ context "and about electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: :energy) }
+
+ context "and has bills" do
+ before do
+ framework_request.update!(energy_bills: create_list(:energy_bill, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the bill uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/bill_uploads"
+ end
+ end
+
+ context "and does not have bills" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/energy_alternative"
+ end
+ end
+ end
+
+ context "and about gas" do
+ let(:category) { create(:request_for_help_category, slug: "gas", flow: :energy) }
+
+ context "and has bills" do
+ before do
+ framework_request.update!(energy_bills: create_list(:energy_bill, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the bill uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/bill_uploads"
+ end
+ end
+
+ context "and does not have bills" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/energy_alternative"
+ end
+ end
+ end
+
+ context "and about anything else" do
+ let(:category) { create(:request_for_help_category, slug: "water", flow: :energy) }
+
+ context "and has documents" do
+ before do
+ framework_request.update!(documents: create_list(:document, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the document uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/document_uploads"
+ end
+ end
+
+ context "and does not have documents" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the documents page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/documents"
+ end
+ end
+ end
+ end
+
+ context "when the request is in the services flow" do
+ let(:category) { create(:request_for_help_category, slug: "legal_services", flow: :services) }
+
+ context "and has documents" do
+ before do
+ framework_request.update!(documents: create_list(:document, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the document uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/document_uploads"
+ end
+ end
+
+ context "and does not have documents" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the documents page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/documents"
+ end
end
end
- context "when the user has chosen not to upload a bill" do
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ context "when the request is in any other flow" do
+ let(:category) { create(:request_for_help_category, slug: "books", flow: :goods) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
- it "goes back to procurement amount page" do
- get :index, session: { framework_request_id: framework_request.id }
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/procurement_amount"
+ it "goes back to the message page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/message"
end
end
end
diff --git a/spec/controllers/framework_requests/start_controller_spec.rb b/spec/controllers/framework_requests/start_controller_spec.rb
index 2bec5005a..d3eecbb9c 100644
--- a/spec/controllers/framework_requests/start_controller_spec.rb
+++ b/spec/controllers/framework_requests/start_controller_spec.rb
@@ -1,26 +1,17 @@
describe FrameworkRequests::StartController, type: :controller do
- it "redirects to the energy request page" do
- post :create
- expect(response).to redirect_to "/procurement-support/energy_request"
- end
-
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
-
- context "when user is a guest" do
- it "redirects to dfe sign in" do
- post :create
- expect(response).to redirect_to "/procurement-support/sign_in"
- end
+ context "when user is a guest" do
+ it "redirects to dfe sign in" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/sign_in"
end
+ end
- context "when user is signed in" do
- before { user_is_signed_in }
+ context "when user is signed in" do
+ before { user_is_signed_in }
- it "confirms the user sign in" do
- post :create
- expect(response).to redirect_to "/procurement-support/confirm_sign_in"
- end
+ it "confirms the user sign in" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/confirm_sign_in"
end
end
end
diff --git a/spec/factories/document.rb b/spec/factories/document.rb
new file mode 100644
index 000000000..9ef8992bb
--- /dev/null
+++ b/spec/factories/document.rb
@@ -0,0 +1,17 @@
+FactoryBot.define do
+ factory :document do
+ submission_status { :pending }
+ filename { "MyString" }
+ filesize { 1 }
+
+ association :framework_request, factory: :framework_request
+
+ trait :pending do
+ submission_status { :pending }
+ end
+
+ trait :submitted do
+ submission_status { :submitted }
+ end
+ end
+end
diff --git a/spec/factories/framework_requests.rb b/spec/factories/framework_requests.rb
index 9c7968ec2..0139200ac 100644
--- a/spec/factories/framework_requests.rb
+++ b/spec/factories/framework_requests.rb
@@ -16,6 +16,7 @@
energy_alternative {}
category {}
category_other {}
+ origin { :recommendation }
trait :energy_request do
is_energy_request { true }
diff --git a/spec/features/specify/auth/supported_user_spec.rb b/spec/features/specify/auth/supported_user_spec.rb
index 464603c76..78296bf70 100644
--- a/spec/features/specify/auth/supported_user_spec.rb
+++ b/spec/features/specify/auth/supported_user_spec.rb
@@ -86,8 +86,6 @@
before do
visit "/procurement-support"
click_on "Start now"
- choose "No"
- click_continue
choose "Yes, use my DfE Sign-in"
click_continue
end
diff --git a/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb b/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb
index 45910538c..cce664134 100644
--- a/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb
+++ b/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb
@@ -21,7 +21,7 @@
before do
create(:support_organisation, urn: "100253", name: "Specialist School for Testing")
- create(:request_for_help_category, title: "A category", slug: "a")
+ create(:request_for_help_category, title: "A category", slug: "a", flow: :goods)
user_is_signed_in(user:)
visit "/procurement-support/confirm_sign_in"
click_on "Yes, continue"
@@ -29,13 +29,16 @@
describe "CYA page" do
before do
- fill_in "framework_support_form[message_body]", with: "I have a problem"
- click_continue
choose "A category"
click_continue
+ fill_in "Approximately how much will the school be spending on this procurement in total?", with: "10.99"
+ click_continue
+ fill_in "framework_support_form[message_body]", with: "I have a problem"
click_continue
choose "No"
click_continue
+ choose "Recommendation"
+ click_continue
end
it "shows the inferred organisation" do
diff --git a/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb b/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb
index ab7683668..4fbda6b87 100644
--- a/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb
+++ b/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb
@@ -56,7 +56,7 @@ def complete_procurement_amount_step
let(:actions) { all("dd.govuk-summary-list__actions") }
before do
- create(:request_for_help_category, title: "A category", slug: "a")
+ create(:request_for_help_category, title: "A category", slug: "a", flow: :goods)
visit "/procurement-support/sign_in"
choose "No, continue without a DfE Sign-in account"
@@ -217,13 +217,26 @@ def complete_procurement_amount_step
fill_in "framework_support_form[email]", with: "test@sky.learnmat.uk"
click_continue
- expect(page).to have_text "How can we help?"
+ expect(page).to have_text "What type of goods or service do you need?"
click_link "Back"
fill_in "framework_support_form[email]", with: "test@sch.uk"
click_continue
- expect(page).to have_text "How can we help?"
+ expect(page).to have_text "What type of goods or service do you need?"
+ end
+ end
+
+ describe "the categories page" do
+ before do
+ autocomplete_school_step
+ confirm_choice_step
+ complete_name_step
+ complete_email_step
+ end
+
+ it "has the correct attributes" do
+ expect(page).to have_title "What type of goods or service do you need?"
end
end
@@ -233,6 +246,8 @@ def complete_procurement_amount_step
confirm_choice_step
complete_name_step
complete_email_step
+ complete_category_step
+ complete_procurement_amount_step
end
it "has the correct attributes" do
@@ -251,7 +266,6 @@ def complete_procurement_amount_step
confirm_choice_step
complete_name_step
complete_email_step
- complete_help_message_step
complete_category_step
end
@@ -272,9 +286,9 @@ def complete_procurement_amount_step
confirm_choice_step
complete_name_step
complete_email_step
- complete_help_message_step
complete_category_step
complete_procurement_amount_step
+ complete_help_message_step
end
it "has the correct attributes" do
diff --git a/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb b/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb
index c53c9c0d8..47e13ffe4 100644
--- a/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb
+++ b/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb
@@ -1,7 +1,8 @@
RSpec.feature "Editing a 'Find a Framework' request as a user" do
subject(:request) do
# Specialist School for Testing
- create(:framework_request, user:, org_id: "100253", group: false)
+ category = create(:request_for_help_category, title: "A category", slug: "a", flow: :goods)
+ create(:framework_request, user:, org_id: "100253", group: false, procurement_amount: "10.99", category:)
end
include_context "with schools and groups"
@@ -15,10 +16,9 @@
visit "/procurement-support/#{request.id}"
end
- it "goes back to the special requirements page" do
+ it "goes back to the origin page" do
click_on "Back"
- expect(page).to have_current_path "/procurement-support/#{request.id}/special_requirements/edit"
- expect(page).to have_text "Accessibility"
+ expect(page).to have_current_path "/procurement-support/#{request.id}/origin/edit"
end
it "has submission information" do
@@ -44,9 +44,25 @@
expect(values[3]).to have_text "Single"
expect(actions[3]).not_to have_link "Change"
- expect(keys[4]).to have_text "Description of request"
- expect(values[4]).to have_text "please help!"
+ expect(keys[4]).to have_text "Type of goods or service"
+ expect(values[4]).to have_text "A category"
expect(actions[4]).to have_link "Change"
+
+ expect(keys[5]).to have_text "Procurement amount"
+ expect(values[5]).to have_text "£10.99"
+ expect(actions[5]).to have_link "Change"
+
+ expect(keys[6]).to have_text "Description of request"
+ expect(values[6]).to have_text "please help!"
+ expect(actions[6]).to have_link "Change"
+
+ expect(keys[7]).to have_text "Accessibility"
+ expect(values[7]).to have_text "special_requirements"
+ expect(actions[7]).to have_link "Change"
+
+ expect(keys[8]).to have_text "Origin"
+ expect(values[8]).to have_text "Recommendation"
+ expect(actions[8]).to have_link "Change"
end
it "edit message" do
@@ -60,7 +76,7 @@
expect(page).to have_current_path "/procurement-support/#{request.id}"
- expect(values[4]).to have_text "I have a problem"
+ expect(values[6]).to have_text "I have a problem"
end
context "with many supported schools and groups", js: true do
diff --git a/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb b/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb
index 1ee1d965e..c4f7cc7e1 100644
--- a/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb
+++ b/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb
@@ -7,7 +7,7 @@
include_context "with schools and groups"
let(:fm_category) { create(:request_for_help_category, title: "FM", slug: "fm") }
- let(:catering_category) { create(:request_for_help_category, title: "Catering", slug: "catering", parent: fm_category) }
+ let(:catering_category) { create(:request_for_help_category, title: "Catering", slug: "catering", parent: fm_category, flow: :goods) }
let(:ict_category) { create(:request_for_help_category, title: "ICT", slug: "ict") }
let(:keys) { all("dt.govuk-summary-list__key") }
@@ -20,10 +20,9 @@
visit "/procurement-support/#{request.id}"
end
- it "goes back to the special requirements page" do
+ it "goes back to the origin page" do
click_on "Back"
- expect(page).to have_current_path "/procurement-support/#{request.id}/special_requirements/edit"
- expect(page).to have_text "Accessibility"
+ expect(page).to have_current_path "/procurement-support/#{request.id}/origin/edit"
end
it "has submission information" do
@@ -49,13 +48,25 @@
expect(values[3]).to have_text "Single"
expect(actions[3]).to have_link "Change"
- expect(keys[4]).to have_text "Description of request"
- expect(values[4]).to have_text "please help!"
+ expect(keys[4]).to have_text "Type of goods or service"
+ expect(values[4]).to have_text "Catering"
expect(actions[4]).to have_link "Change"
- expect(keys[5]).to have_text "Type of goods or service"
- expect(values[5]).to have_text "Catering"
+ expect(keys[5]).to have_text "Procurement amount"
+ expect(values[5]).to have_text "£10.50"
expect(actions[5]).to have_link "Change"
+
+ expect(keys[6]).to have_text "Description of request"
+ expect(values[6]).to have_text "please help!"
+ expect(actions[6]).to have_link "Change"
+
+ expect(keys[7]).to have_text "Accessibility"
+ expect(values[7]).to have_text "special_requirements"
+ expect(actions[7]).to have_link "Change"
+
+ expect(keys[8]).to have_text "Origin"
+ expect(values[8]).to have_text "Recommendation"
+ expect(actions[8]).to have_link "Change"
end
it "edit name" do
@@ -101,7 +112,7 @@
click_continue
expect(page).to have_current_path "/procurement-support/#{request.id}"
- expect(values[4]).to have_text "I have a problem"
+ expect(values[6]).to have_text "I have a problem"
end
describe "change organisation type and reselect", js: true do
diff --git a/spec/features/specify/framework_requests/start_page_spec.rb b/spec/features/specify/framework_requests/start_page_spec.rb
index a0f8e612b..becd9612a 100644
--- a/spec/features/specify/framework_requests/start_page_spec.rb
+++ b/spec/features/specify/framework_requests/start_page_spec.rb
@@ -17,8 +17,6 @@
visit "/procurement-support"
click_on "Start now"
- choose "No"
- click_continue
choose "Yes, use my DfE Sign-in"
click_continue
end
diff --git a/spec/forms/framework_requests/base_form_spec.rb b/spec/forms/framework_requests/base_form_spec.rb
index b70a97635..c2ed9321d 100644
--- a/spec/forms/framework_requests/base_form_spec.rb
+++ b/spec/forms/framework_requests/base_form_spec.rb
@@ -3,8 +3,6 @@
let(:data) { {} }
- it { is_expected.to delegate_method(:allow_bill_upload?).to(:framework_request) }
-
describe "#dsi?" do
let(:data) { { dsi: "true" } }
diff --git a/spec/forms/framework_requests/procurement_amount_form_spec.rb b/spec/forms/framework_requests/procurement_amount_form_spec.rb
index 5c541d291..765838241 100644
--- a/spec/forms/framework_requests/procurement_amount_form_spec.rb
+++ b/spec/forms/framework_requests/procurement_amount_form_spec.rb
@@ -22,14 +22,14 @@
subject(:form) { described_class.new(procurement_amount: "abc") }
before do
- allow(validator).to receive(:invalid_number?).and_return(true)
+ # allow(validator).to receive(:invalid_number?).and_return(true)
allow(validator).to receive(:too_large?).and_return(false)
end
it "returns the right error message" do
expect(form).not_to be_valid
expect(form.errors.messages[:procurement_amount]).to eq ["Enter a valid number"]
- expect(validator).to have_received(:invalid_number?).once
+ # expect(validator).to have_received(:invalid_number?).once
end
end
@@ -37,7 +37,7 @@
subject(:form) { described_class.new(procurement_amount: "10000000") }
before do
- allow(validator).to receive(:invalid_number?).and_return(false)
+ # allow(validator).to receive(:invalid_number?).and_return(false)
allow(validator).to receive(:too_large?).and_return(true)
end
diff --git a/spec/models/specify/framework_request_spec.rb b/spec/models/specify/framework_request_spec.rb
index b784dfd19..e1205ce7f 100644
--- a/spec/models/specify/framework_request_spec.rb
+++ b/spec/models/specify/framework_request_spec.rb
@@ -1,5 +1,5 @@
RSpec.describe FrameworkRequest, type: :model do
- subject(:framework_request) { build(:framework_request, group:, org_id:, is_energy_request:, energy_request_about:, have_energy_bill:, energy_alternative:, school_urns:) }
+ subject(:framework_request) { create(:framework_request, group:, org_id:, is_energy_request:, energy_request_about:, have_energy_bill:, energy_alternative:, school_urns:, category:, contract_length:, contract_start_date_known:, contract_start_date:, same_supplier_used:, document_type_other:) }
let(:is_energy_request) { false }
let(:energy_request_about) { nil }
@@ -8,70 +8,16 @@
let(:school_urns) { [] }
let(:group) { false }
let(:org_id) { nil }
+ let(:category) { nil }
+ let(:contract_length) { nil }
+ let(:contract_start_date_known) { nil }
+ let(:contract_start_date) { nil }
+ let(:same_supplier_used) { nil }
+ let(:document_type_other) { nil }
it { is_expected.to belong_to(:user).optional }
it { is_expected.to belong_to(:category).class_name("RequestForHelpCategory").optional }
- describe "#allow_bill_upload?" do
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
-
- it "returns false" do
- framework_request = described_class.new
- expect(framework_request.allow_bill_upload?).to be(false)
- end
- end
-
- context "when it's an energy request about a contract and they have a bill to upload" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :energy_contract }
- let(:have_energy_bill) { true }
-
- it "returns true" do
- expect(framework_request.allow_bill_upload?).to eq true
- end
- end
-
- context "when it's an energy request about a contract and they have a bill in a different format" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :energy_contract }
- let(:have_energy_bill) { false }
- let(:energy_alternative) { :different_format }
-
- it "returns true" do
- expect(framework_request.allow_bill_upload?).to eq true
- end
- end
-
- context "when it's not an energy request" do
- let(:is_energy_request) { false }
-
- it "returns false" do
- expect(framework_request.allow_bill_upload?).to eq false
- end
- end
-
- context "when it's an energy request not about a contract" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :not_energy_contract }
-
- it "returns false" do
- expect(framework_request.allow_bill_upload?).to eq false
- end
- end
-
- context "when it's an energy request about a contract but they don't have a bill in a different format" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :energy_contract }
- let(:have_energy_bill) { false }
- let(:energy_alternative) { :no_bill }
-
- it "returns false" do
- expect(framework_request.allow_bill_upload?).to eq false
- end
- end
- end
-
describe "#has_bills?" do
context "when there are associated energy bills" do
before { create(:energy_bill, framework_request:) }
@@ -118,4 +64,149 @@
expect(framework_request.school_urns).to match_array(%w[456])
end
end
+
+ describe "changes to the request category" do
+ context "when changed to the 'Goods' flow" do
+ let(:category) { create(:request_for_help_category, flow: :services) }
+ let(:contract_length) { :three_years }
+ let(:contract_start_date_known) { true }
+ let(:contract_start_date) { Date.parse("2023-09-20") }
+ let(:same_supplier_used) { :yes }
+ let(:document_types) { %w[other quotes] }
+ let(:document_type_other) { "other" }
+ let(:update) { { category: create(:request_for_help_category, flow: :goods) } }
+
+ before do
+ framework_request.update!(document_types:)
+ create(:energy_bill, framework_request:)
+ create(:document, framework_request:)
+ end
+
+ it "clears the contract length" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_length).from(contract_length.to_s).to(nil)
+ end
+
+ it "clears the contract start date known" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date_known).from(contract_start_date_known).to(nil)
+ end
+
+ it "clears the contract start date" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date).from(contract_start_date).to(nil)
+ end
+
+ it "clears the 'same supplier used' value" do
+ expect { framework_request.update!(update) }.to change(framework_request, :same_supplier_used).from(same_supplier_used.to_s).to(nil)
+ end
+
+ it "clears the document types" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_types).from(document_types).to([])
+ end
+
+ it "clears the document type other" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_type_other).from(document_type_other).to(nil)
+ end
+
+ it "removes all bills" do
+ expect { framework_request.update!(update) }.to change { framework_request.reload.energy_bills.count }.from(1).to(0)
+ end
+
+ it "removes all documents" do
+ expect { framework_request.update!(update) }.to change { framework_request.reload.documents.count }.from(1).to(0)
+ end
+ end
+
+ context "when changed to the 'Not fully supported' flow" do
+ let(:category) { create(:request_for_help_category, flow: nil) }
+ let(:contract_length) { :two_years }
+ let(:contract_start_date_known) { true }
+ let(:contract_start_date) { Date.parse("2025-02-10") }
+ let(:same_supplier_used) { :not_sure }
+ let(:document_types) { %w[other quotes] }
+ let(:document_type_other) { "other" }
+ let(:update) { { category: create(:request_for_help_category, flow: :not_fully_supported) } }
+
+ before do
+ framework_request.update!(document_types:)
+ create_list(:energy_bill, 2, framework_request:)
+ create(:document, framework_request:)
+ end
+
+ it "clears the contract length" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_length).from(contract_length.to_s).to(nil)
+ end
+
+ it "clears the contract start date known" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date_known).from(contract_start_date_known).to(nil)
+ end
+
+ it "clears the contract start date" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date).from(contract_start_date).to(nil)
+ end
+
+ it "clears the 'same supplier used' value" do
+ expect { framework_request.update!(update) }.to change(framework_request, :same_supplier_used).from(same_supplier_used.to_s).to(nil)
+ end
+
+ it "clears the document types" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_types).from(document_types).to([])
+ end
+
+ it "clears the document type other" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_type_other).from(document_type_other).to(nil)
+ end
+
+ it "removes all bills" do
+ expect { framework_request.update!(update) }.to change { framework_request.energy_bills.count }.from(2).to(0)
+ end
+
+ it "removes all documents" do
+ expect { framework_request.update!(update) }.to change { framework_request.reload.documents.count }.from(1).to(0)
+ end
+ end
+
+ context "when changed to the 'Services' flow" do
+ let(:category) { create(:request_for_help_category, flow: :energy) }
+ let(:have_energy_bill) { true }
+ let(:energy_alternative) { :different_format }
+ let(:update) { { category: create(:request_for_help_category, flow: :services) } }
+
+ before { create_list(:energy_bill, 2, framework_request:) }
+
+ it "clears the have energy bill value" do
+ expect { framework_request.update!(update) }.to change(framework_request, :have_energy_bill).from(have_energy_bill).to(nil)
+ end
+
+ it "clears the energy alternative" do
+ expect { framework_request.update!(update) }.to change(framework_request, :energy_alternative).from(energy_alternative.to_s).to(nil)
+ end
+
+ it "removes all bills" do
+ expect { framework_request.update!(update) }.to change { framework_request.energy_bills.count }.from(2).to(0)
+ end
+ end
+
+ context "when changed to the 'Energy' flow" do
+ let(:category) { create(:request_for_help_category, flow: :services) }
+ let(:document_types) { %w[other quotes] }
+ let(:document_type_other) { "other" }
+ let(:update) { { category: create(:request_for_help_category, flow: :energy) } }
+
+ before do
+ framework_request.update!(document_types:)
+ create_list(:document, 2, framework_request:)
+ end
+
+ it "clears the document types" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_types).from(document_types).to([])
+ end
+
+ it "clears the document type other" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_type_other).from(document_type_other).to(nil)
+ end
+
+ it "removes all documents" do
+ expect { framework_request.update!(update) }.to change { framework_request.documents.count }.from(2).to(0)
+ end
+ end
+ end
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index a4dc10dd4..26f9cc6ca 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -84,7 +84,6 @@
config.before do
# Configure feature flags for test here
- Flipper.enable(:energy_bill_flow)
Flipper.enable(:email_templates)
Flipper.enable(:cms_triage_view)
Flipper.enable(:cms_panel_view)
diff --git a/spec/services/request_for_help/seed_categories_spec.rb b/spec/services/request_for_help/seed_categories_spec.rb
index 9cac9237f..503dd1f3a 100644
--- a/spec/services/request_for_help/seed_categories_spec.rb
+++ b/spec/services/request_for_help/seed_categories_spec.rb
@@ -36,4 +36,15 @@
expect(passenger_transport.support_category).to eq(support_category)
end
end
+
+ context "when a category is archived" do
+ before { service.call }
+
+ it "persists it as archived with an archive date" do
+ ict_funding = RequestForHelpCategory.find_by(title: "ICT funding")
+
+ expect(ict_funding.archived).to eq(true)
+ expect(ict_funding.archived_at).to be_within(1.second).of(Time.zone.now)
+ end
+ end
end
diff --git a/spec/services/specify/submit_framework_request_spec.rb b/spec/services/specify/submit_framework_request_spec.rb
index ba04733a9..0f7706638 100644
--- a/spec/services/specify/submit_framework_request_spec.rb
+++ b/spec/services/specify/submit_framework_request_spec.rb
@@ -8,7 +8,8 @@
let(:email_confirmation_parameters) { anything }
let(:support_category) { create(:support_category, title: "Other (Energy)", slug: "other-energy") }
let(:parent_rfh_category) { create(:request_for_help_category, title: "Energy and utilities", slug: "energy-and-utilities") }
- let(:rfh_category) { create(:request_for_help_category, title: "Other", slug: "other", support_category:, parent: parent_rfh_category) }
+ let(:rfh_category) { create(:request_for_help_category, title: "Other", slug: "other", support_category:, parent: parent_rfh_category, flow:) }
+ let(:flow) { :services }
let(:category_other) { "other energy requirements" }
before do
@@ -56,7 +57,7 @@
end
context "when it's an energy request" do
- let(:energy_alternative) { :email_later }
+ let(:flow) { :energy }
it "sends out the confirmation email for energy requests" do
allow(Emails::ConfirmationEnergy).to receive(:new).with(email_confirmation_parameters).and_return(email_confirmation)
@@ -92,5 +93,31 @@
expect(Support::CaseAttachment.find_by(attachable: bill_2).case).to eq(Support::Case.last)
end
end
+
+ context "when documents have been uploaded" do
+ let!(:doc_1) { create(:document, :pending, framework_request: request) }
+ let!(:doc_2) { create(:document, :pending, framework_request: request) }
+
+ it "sets their status to submitted" do
+ described_class.new(request:, referrer:).call
+
+ expect(doc_1.reload).to be_submitted
+ expect(doc_2.reload).to be_submitted
+ end
+
+ it "connects them with the newly created case" do
+ described_class.new(request:, referrer:).call
+
+ expect(doc_1.reload.support_case).to eq(Support::Case.last)
+ expect(doc_2.reload.support_case).to eq(Support::Case.last)
+ end
+
+ it "creates CaseAttachment records for each bill" do
+ described_class.new(request:, referrer:).call
+
+ expect(Support::CaseAttachment.find_by(attachable: doc_1).case).to eq(Support::Case.last)
+ expect(Support::CaseAttachment.find_by(attachable: doc_2).case).to eq(Support::Case.last)
+ end
+ end
end
end