diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6a75bbb2a..2c4902d77 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,7 +59,7 @@ 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 @@ -58,7 +67,7 @@ RSpec/VerifiedDoubles: # Offense count: 13 # 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' @@ -72,16 +81,17 @@ Rails/BulkChangeTable: - 'db/migrate/20221014140003_add_more_trust_fields_to_support_organisations.rb' - 'db/migrate/20230210133230_refactor_notifications_into_one_table.rb' -# Offense count: 2 +# Offense count: 3 # 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/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' @@ -119,6 +129,3 @@ Style/DateTime: - 'lib/microsoft_graph/transformer/attachment.rb' - 'lib/microsoft_graph/transformer/message.rb' - 'lib/microsoft_graph/transformer/update_message.rb' - -Rails/UniqueValidationWithoutIndex: - Enabled: false diff --git a/app/controllers/framework_requests/base_controller.rb b/app/controllers/framework_requests/base_controller.rb index 549e65a25..d488977e7 100644 --- a/app/controllers/framework_requests/base_controller.rb +++ b/app/controllers/framework_requests/base_controller.rb @@ -74,12 +74,12 @@ 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? + def set_flow(flow) + session[:framework_request_flow] = flow + end - energy_request_framework_requests_path(framework_support_form: form.common) + def flow + (session[:framework_request_flow] || "").inquiry 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..d68fcf2f0 100644 --- a/app/controllers/framework_requests/bill_uploads_controller.rb +++ b/app/controllers/framework_requests/bill_uploads_controller.rb @@ -61,11 +61,9 @@ 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? - select_organisation_framework_requests_path(framework_support_form: form.common) + energy_bill_framework_requests_path(framework_support_form: form.common) end end end diff --git a/app/controllers/framework_requests/categories_controller.rb b/app/controllers/framework_requests/categories_controller.rb index 0bcc1caa0..498f48f74 100644 --- a/app/controllers/framework_requests/categories_controller.rb +++ b/app/controllers/framework_requests/categories_controller.rb @@ -22,6 +22,7 @@ def create @form.save! if @form.new_path? + set_flow(framework_request.flow) redirect_to create_redirect_path end @@ -42,8 +43,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? || flow.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 +61,30 @@ 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) + # return categories_framework_requests_path(framework_support_form: @form.common.merge(category_slug: "multiple")) if category_path == "multiple" + # return email_framework_requests_path(framework_support_form: @form.common) if category_path.nil? && @current_user.guest? + # return confirm_schools_framework_requests_path(framework_support_form: @form.common) if category_path.nil? && form.eligible_for_school_picker? + # return confirm_sign_in_framework_requests_path(framework_support_form: @form.common) if category_path.nil? && @current_user.single_org? + # return select_organisation_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) + + 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..19723e3a0 100644 --- a/app/controllers/framework_requests/confirm_schools_controller.rb +++ b/app/controllers/framework_requests/confirm_schools_controller.rb @@ -45,12 +45,10 @@ 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 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..8999b9b2e --- /dev/null +++ b/app/controllers/framework_requests/contract_lengths_controller.rb @@ -0,0 +1,23 @@ +module FrameworkRequests + class ContractLengthsController < BaseController + skip_before_action :authenticate_user! + + 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 + 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..ec9166af5 --- /dev/null +++ b/app/controllers/framework_requests/contract_start_dates_controller.rb @@ -0,0 +1,35 @@ +module FrameworkRequests + class ContractStartDatesController < BaseController + include Support::Concerns::HasDateParams + + skip_before_action :authenticate_user! + + 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? + 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 + 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..1c9005584 --- /dev/null +++ b/app/controllers/framework_requests/document_uploads_controller.rb @@ -0,0 +1,71 @@ +module FrameworkRequests + class DocumentUploadsController < BaseController + skip_before_action :authenticate_user! + + before_action :set_document_types, only: %i[index edit] + + 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]) + true + 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 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..d2839bfe7 --- /dev/null +++ b/app/controllers/framework_requests/documents_controller.rb @@ -0,0 +1,25 @@ +module FrameworkRequests + class DocumentsController < BaseController + skip_before_action :authenticate_user! + + 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 + 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 index 735a96c8f..20492a451 100644 --- a/app/controllers/framework_requests/energy_alternative_controller.rb +++ b/app/controllers/framework_requests/energy_alternative_controller.rb @@ -12,7 +12,11 @@ def form_params [:energy_alternative] end - def create_redirect_path = sign_in_path + 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) diff --git a/app/controllers/framework_requests/energy_bill_controller.rb b/app/controllers/framework_requests/energy_bill_controller.rb index 31d997ec1..98a2ade52 100644 --- a/app/controllers/framework_requests/energy_bill_controller.rb +++ b/app/controllers/framework_requests/energy_bill_controller.rb @@ -13,13 +13,13 @@ def form_params end def create_redirect_path - return sign_in_path if @form.have_energy_bill? + 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 = energy_request_about_framework_requests_path(framework_support_form: @form.common) + @back_url = message_framework_requests_path(framework_support_form: @form.common) 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..78cfb92ca 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.category.gas? || framework_request.category.electricity? + 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..a1dc55307 --- /dev/null +++ b/app/controllers/framework_requests/origins_controller.rb @@ -0,0 +1,31 @@ +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) + session.delete(:framework_request_flow) + 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..e79c95072 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? + 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..7776c2eed --- /dev/null +++ b/app/controllers/framework_requests/same_suppliers_controller.rb @@ -0,0 +1,23 @@ +module FrameworkRequests + class SameSuppliersController < BaseController + skip_before_action :authenticate_user! + + 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 + end +end 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..d3c0236f5 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.category.gas? || framework_request.category.electricity? + 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/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 916a4a223..47959502e 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..6fe14443d 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, 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..a76e051e6 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 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..19de44009 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 :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, newsletter: 2, recommendation: 3, search_engine: 4, social_media: 5, website: 6, other: 7 }, 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 + + delegate :flow, to: :category, 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 @@ -44,10 +55,14 @@ def clear_school_urns self.school_urns = [] end + def submit_documents + documents.each(&:submit) + 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 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..ce727cbf7 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 diff --git a/app/views/framework_request_submissions/_default.html.erb b/app/views/framework_request_submissions/_default.html.erb index c400b176d..bd5cc656b 100644 --- a/app/views/framework_request_submissions/_default.html.erb +++ b/app/views/framework_request_submissions/_default.html.erb @@ -1,31 +1,9 @@ -

- <%= I18n.t("faf_submissions.header.what_happens_next") %> -

- <%= I18n.t("faf_submissions.body.what_happens_next.default", days: 2)[0] %> -

-

- <%= I18n.t("faf_submissions.body.what_happens_next.common")[0] %> + <%= I18n.t("faf_submissions.body.what_happens_next.common", days: 2)[0] %>

<%= I18n.t("faf_submissions.body.what_happens_next.common")[1] %>

- -

- <%= I18n.t("faf_submissions.header.what_you_can_do_next") %> -

-

- <%= I18n.t("faf_submissions.what_you_can_do_next.default.list_start") %> -

+ <%= I18n.t("faf_submissions.body.what_happens_next.common")[2] %>

diff --git a/app/views/framework_request_submissions/_energy.html.erb b/app/views/framework_request_submissions/_energy.html.erb index 1473e4dc1..157e16a5c 100644 --- a/app/views/framework_request_submissions/_energy.html.erb +++ b/app/views/framework_request_submissions/_energy.html.erb @@ -1,28 +1,12 @@ -

- <%= I18n.t("faf_submissions.header.what_happens_next") %> -

- <%= I18n.t("faf_submissions.body.what_happens_next.energy", days: 2)[0] %> + <%= I18n.t("faf_submissions.body.what_happens_next.common", days: 2)[0] %>

- <%= I18n.t("faf_submissions.body.what_happens_next.energy")[1] %> -

-

- <%= I18n.t("faf_submissions.body.what_happens_next.common")[0] %> + <%= I18n.t("faf_submissions.body.what_happens_next.energy")[0] %>

<%= I18n.t("faf_submissions.body.what_happens_next.common")[1] %>

- -

- <%= I18n.t("faf_submissions.header.what_you_can_do_next") %> -

-

- <%= I18n.t("faf_submissions.what_you_can_do_next.energy.list_start", guidance_link: link_to(I18n.t("faf_submissions.what_you_can_do_next.energy.guidance_link"), "https://www.gov.uk/guidance/buying-for-schools/energy", class: "govuk-link govuk-link--no-visited-state")).html_safe %> -

+ <%= I18n.t("faf_submissions.body.what_happens_next.common")[2] %>

diff --git a/app/views/framework_request_submissions/show.html.erb b/app/views/framework_request_submissions/show.html.erb index 881f8cc36..5dc1aa296 100644 --- a/app/views/framework_request_submissions/show.html.erb +++ b/app/views/framework_request_submissions/show.html.erb @@ -13,11 +13,34 @@ - <% if @framework_request.is_energy_request %> +

+ <%= I18n.t("faf_submissions.header.what_happens_next") %> +

+ + <% if @framework_request.flow == "energy" %> <%= render "energy" %> <% else %> <%= render "default" %> <% end %> + +

+ <%= I18n.t("faf_submissions.header.what_you_can_do_next") %> +

+ +

+ <%= I18n.t("faf_submissions.what_you_can_do_next.list_start") %> +

+

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.

+
+ +<%= render "framework_requests/common_form_fields", form: form %> + +<%= form.govuk_collection_radio_buttons :contract_length, available_contract_lengths, :id, :title, + caption: { text: I18n.t("faf.contract_length.caption"), size: "l" }, + legend: { text: I18n.t("faf.contract_length.title"), size: "l" }, + hint: { text: I18n.t("faf.contract_length.hint") } %> diff --git a/app/views/framework_requests/contract_lengths/edit.html.erb b/app/views/framework_requests/contract_lengths/edit.html.erb new file mode 100644 index 000000000..c3093ccc8 --- /dev/null +++ b/app/views/framework_requests/contract_lengths/edit.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "contract_lengths", verb: :patch, path: framework_request_contract_length_path %> diff --git a/app/views/framework_requests/contract_lengths/index.html.erb b/app/views/framework_requests/contract_lengths/index.html.erb new file mode 100644 index 000000000..7b0b1eea6 --- /dev/null +++ b/app/views/framework_requests/contract_lengths/index.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "contract_lengths", verb: :post, path: contract_length_framework_requests_path %> diff --git a/app/views/framework_requests/contract_start_dates/_form.html.erb b/app/views/framework_requests/contract_start_dates/_form.html.erb new file mode 100644 index 000000000..51a31bc8f --- /dev/null +++ b/app/views/framework_requests/contract_start_dates/_form.html.erb @@ -0,0 +1,12 @@ +<%= content_for :title, I18n.t("faf.contract_start_date.title") %> + +<%= render "framework_requests/common_form_fields", form: form %> + +<%= form.govuk_radio_buttons_fieldset :contract_start_date_known, + legend: { text: I18n.t("faf.contract_start_date.title"), size: "l" }, + caption: { text: I18n.t("faf.contract_start_date.caption"), size: "l" } do %> + <%= form.govuk_radio_button :contract_start_date_known, true, label: { text: I18n.t("faf.contract_start_date.options.yes") } do %> + <%= form.govuk_date_field :contract_start_date, legend: { text: I18n.t("faf.contract_start_date.date.label"), size: "s", class: "govuk-!-font-weight-regular" }, hint: { text: I18n.t("faf.contract_start_date.date.hint") } %> + <% end %> + <%= form.govuk_radio_button :contract_start_date_known, false, label: { text: I18n.t("faf.contract_start_date.options.no") } %> +<% end %> diff --git a/app/views/framework_requests/contract_start_dates/edit.html.erb b/app/views/framework_requests/contract_start_dates/edit.html.erb new file mode 100644 index 000000000..08d20940f --- /dev/null +++ b/app/views/framework_requests/contract_start_dates/edit.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "contract_start_dates", verb: :patch, path: framework_request_contract_start_date_path %> diff --git a/app/views/framework_requests/contract_start_dates/index.html.erb b/app/views/framework_requests/contract_start_dates/index.html.erb new file mode 100644 index 000000000..86cbc4a61 --- /dev/null +++ b/app/views/framework_requests/contract_start_dates/index.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "contract_start_dates", verb: :post, path: contract_start_date_framework_requests_path %> diff --git a/app/views/framework_requests/document_uploads/_form.html.erb b/app/views/framework_requests/document_uploads/_form.html.erb new file mode 100644 index 000000000..a72137357 --- /dev/null +++ b/app/views/framework_requests/document_uploads/_form.html.erb @@ -0,0 +1,110 @@ +<%= content_for :title, I18n.t("faf.document_upload.title") %> + +
" + 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"> + +
+
+

+ There is a problem +

+
+
+
+
+ + <%= I18n.t("faf.document_upload.caption") %> +

+ <%= I18n.t("faf.document_upload.title") %> +

+ +
+

<%= I18n.t("faf.document_upload.hint") %>

+
    + <% selected_document_types(@document_types, @other).each do |document_type| %> +
  • <%= document_type %>
  • + <% end %> +
+

<%= I18n.t("faf.document_upload.body") %>

+
+ +
+ data-dropzone-add-file-url-value=<%= upload_document_uploads_framework_requests_url(@framework_request) %> + data-dropzone-remove-file-url-value=<%= remove_document_uploads_framework_requests_url(@framework_request) %>> +
+
+
+

()

+ Remove +
+
+

+ +
+
+
+
+
+
+ +
+

Drag and drop files here or

+ + + Choose files + +
+ +
+
+

+ Files added +

+
+ +
+

+ Files already uploaded +

+
+
+
+ + + + + + +
+ +<%= render "framework_requests/common_form_fields", form: form %> diff --git a/app/views/framework_requests/document_uploads/edit.html.erb b/app/views/framework_requests/document_uploads/edit.html.erb new file mode 100644 index 000000000..2527733f4 --- /dev/null +++ b/app/views/framework_requests/document_uploads/edit.html.erb @@ -0,0 +1,5 @@ +<%= render "framework_requests/form", + route: "document_uploads", + verb: :patch, + path: framework_request_document_uploads_path, + hide_submit_button: true %> diff --git a/app/views/framework_requests/document_uploads/index.html.erb b/app/views/framework_requests/document_uploads/index.html.erb new file mode 100644 index 000000000..2a832e98d --- /dev/null +++ b/app/views/framework_requests/document_uploads/index.html.erb @@ -0,0 +1,5 @@ +<%= render "framework_requests/form", + route: "document_uploads", + verb: :post, + path: document_uploads_framework_requests_path, + hide_submit_button: true %> diff --git a/app/views/framework_requests/documents/_form.html.erb b/app/views/framework_requests/documents/_form.html.erb new file mode 100644 index 000000000..6233a6cfb --- /dev/null +++ b/app/views/framework_requests/documents/_form.html.erb @@ -0,0 +1,16 @@ +<%= content_for :title, I18n.t("faf.documents.title") %> + +<%= render "framework_requests/common_form_fields", form: form %> + +<%= form.govuk_check_boxes_fieldset :document_types, + caption: { text: I18n.t("faf.documents.caption"), size: "l" }, + legend: { text: I18n.t("faf.documents.title"), size: "l" }, + hint: -> { render "form_hint" } do %> + <% available_document_types.each do |document_type| %> + <%= form.govuk_check_box :document_types, document_type.id, label: { text: document_type.title }, exclusive: document_type.exclusive do %> + <% if document_type.id == "other" %> + <%= form.govuk_text_field :document_type_other, label: nil %> + <% end %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/framework_requests/documents/_form_hint.html.erb b/app/views/framework_requests/documents/_form_hint.html.erb new file mode 100644 index 000000000..cb350fb90 --- /dev/null +++ b/app/views/framework_requests/documents/_form_hint.html.erb @@ -0,0 +1,3 @@ +<% I18n.t("faf.documents.hint").each do |p| %> +

<%= p %>

+<% end %> \ No newline at end of file diff --git a/app/views/framework_requests/documents/edit.html.erb b/app/views/framework_requests/documents/edit.html.erb new file mode 100644 index 000000000..76f61a213 --- /dev/null +++ b/app/views/framework_requests/documents/edit.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "documents", verb: :patch, path: framework_request_documents_path %> diff --git a/app/views/framework_requests/documents/index.html.erb b/app/views/framework_requests/documents/index.html.erb new file mode 100644 index 000000000..d47ec2150 --- /dev/null +++ b/app/views/framework_requests/documents/index.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "documents", verb: :post, path: documents_framework_requests_path %> diff --git a/app/views/framework_requests/energy_request/_form.html.erb b/app/views/framework_requests/energy_request/_form.html.erb deleted file mode 100644 index 80d853acc..000000000 --- a/app/views/framework_requests/energy_request/_form.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%= content_for :title, I18n.t("faf.energy_request.header") %> - -<%= render "framework_requests/common_form_fields", form: form %> - -<%= form.govuk_radio_buttons_fieldset :is_energy_request, - legend: { text: I18n.t("faf.energy_request.header"), size: "l" }, - caption: { text: I18n.t("faf.energy_request.subtitle"), size: "l" }, - hint: -> { render "form_hint" } do %> - <%= form.govuk_radio_button :is_energy_request, :true, label: { text: I18n.t("generic.yes") } %> - <%= form.govuk_radio_button :is_energy_request, :false, label: { text: I18n.t("generic.no") } %> -<% end %> diff --git a/app/views/framework_requests/energy_request/_form_hint.html.erb b/app/views/framework_requests/energy_request/_form_hint.html.erb deleted file mode 100644 index 7ee456b9d..000000000 --- a/app/views/framework_requests/energy_request/_form_hint.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -

- <%= I18n.t("faf.energy_request.body", guidance_link: link_to(I18n.t("faf.energy_request.guidance_link"), "https://www.gov.uk/guidance/buying-for-schools/energy", class: "govuk-link govuk-link--no-visited-state")).html_safe %> -

- - diff --git a/app/views/framework_requests/energy_request/index.html.erb b/app/views/framework_requests/energy_request/index.html.erb deleted file mode 100644 index efbcd2abc..000000000 --- a/app/views/framework_requests/energy_request/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render "framework_requests/form", route: "energy_request", verb: :post, path: energy_request_framework_requests_path %> diff --git a/app/views/framework_requests/energy_request_about/_form.html.erb b/app/views/framework_requests/energy_request_about/_form.html.erb deleted file mode 100644 index c83509496..000000000 --- a/app/views/framework_requests/energy_request_about/_form.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%= content_for :title, I18n.t("faf.energy_request_about.header") %> - -<%= render "framework_requests/common_form_fields", form: form %> - -<%= form.govuk_radio_buttons_fieldset :energy_request_about, - legend: { text: I18n.t("faf.energy_request_about.header"), size: "l" }, - caption: { text: I18n.t("faf.energy_request_about.subtitle"), size: "l" } do %> - <% form.object.energy_request_about_options.each do |option| %> - <%= form.govuk_radio_button :energy_request_about, option, label: { text: I18n.t("faf.energy_request_about.options.#{option}") } %> - <% end %> -<% end %> diff --git a/app/views/framework_requests/energy_request_about/index.html.erb b/app/views/framework_requests/energy_request_about/index.html.erb deleted file mode 100644 index 72a06efe8..000000000 --- a/app/views/framework_requests/energy_request_about/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render "framework_requests/form", route: "energy_request_about", verb: :post, path: energy_request_about_framework_requests_path %> diff --git a/app/views/framework_requests/messages/_form_hint.html.erb b/app/views/framework_requests/messages/_form_hint.html.erb index a928f3db4..e587db19f 100644 --- a/app/views/framework_requests/messages/_form_hint.html.erb +++ b/app/views/framework_requests/messages/_form_hint.html.erb @@ -1,21 +1,17 @@ -<% if Flipper.enabled?(:energy_bill_flow) %> -

- <%= I18n.t("faf.user_query.hint") %> -

+

+ <%= I18n.t("faf.user_query.hint") %> +

-

- <%= I18n.t("faf.user_query.hint_list_start") %> -

+

+ <%= I18n.t("faf.user_query.hint_list_start") %> +

- + -

- <%= I18n.t("faf.user_query.hint_list_end") %> -

-<% else %> - <%= I18n.t("faf.user_query.hint") %> -<% end %> +

+ <%= I18n.t("faf.user_query.hint_list_end") %> +

diff --git a/app/views/framework_requests/origins/_form.html.erb b/app/views/framework_requests/origins/_form.html.erb new file mode 100644 index 000000000..3aa7dba22 --- /dev/null +++ b/app/views/framework_requests/origins/_form.html.erb @@ -0,0 +1,16 @@ +<%= content_for :title, I18n.t("faf.origin.title") %> + +<%= render "framework_requests/common_form_fields", form: form %> + +<%= form.govuk_radio_buttons_fieldset :origin, + caption: { text: I18n.t("faf.origin.caption"), size: "l" }, + legend: { text: I18n.t("faf.origin.title"), size: "l" }, + hint: { text: I18n.t("faf.origin.hint") } do %> + <% available_origins.each do |origin| %> + <%= form.govuk_radio_button :origin, origin.id, label: { text: origin.title } do %> + <% if origin.id == "other" %> + <%= form.govuk_text_field :origin_other, label: { text: I18n.t("faf.origin.please_specify") } %> + <% end %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/framework_requests/origins/edit.html.erb b/app/views/framework_requests/origins/edit.html.erb new file mode 100644 index 000000000..810477a4f --- /dev/null +++ b/app/views/framework_requests/origins/edit.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "origins", verb: :patch, path: framework_request_origin_path %> diff --git a/app/views/framework_requests/origins/index.html.erb b/app/views/framework_requests/origins/index.html.erb new file mode 100644 index 000000000..5133b477c --- /dev/null +++ b/app/views/framework_requests/origins/index.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "origins", verb: :post, path: origin_framework_requests_path %> diff --git a/app/views/framework_requests/same_suppliers/_form.html.erb b/app/views/framework_requests/same_suppliers/_form.html.erb new file mode 100644 index 000000000..66ef00dc8 --- /dev/null +++ b/app/views/framework_requests/same_suppliers/_form.html.erb @@ -0,0 +1,7 @@ +<%= content_for :title, I18n.t("faf.same_supplier.title") %> + +<%= render "framework_requests/common_form_fields", form: form %> + +<%= form.govuk_collection_radio_buttons :same_supplier_used, available_same_supplier_options, :id, :title, + caption: { text: I18n.t("faf.same_supplier.caption"), size: "l" }, + legend: { text: I18n.t("faf.same_supplier.title"), size: "l" } %> diff --git a/app/views/framework_requests/same_suppliers/edit.html.erb b/app/views/framework_requests/same_suppliers/edit.html.erb new file mode 100644 index 000000000..b528e6c09 --- /dev/null +++ b/app/views/framework_requests/same_suppliers/edit.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "same_suppliers", verb: :patch, path: framework_request_same_supplier_path %> diff --git a/app/views/framework_requests/same_suppliers/index.html.erb b/app/views/framework_requests/same_suppliers/index.html.erb new file mode 100644 index 000000000..a1f4960ad --- /dev/null +++ b/app/views/framework_requests/same_suppliers/index.html.erb @@ -0,0 +1 @@ +<%= render "framework_requests/form", route: "same_suppliers", verb: :post, path: same_supplier_framework_requests_path %> diff --git a/app/views/framework_requests/show.html.erb b/app/views/framework_requests/show.html.erb index f6e214ec0..d8c3d0fb2 100644 --- a/app/views/framework_requests/show.html.erb +++ b/app/views/framework_requests/show.html.erb @@ -79,63 +79,112 @@ <% end %>
- <%= I18n.t("faf.check_answers.details.problem") %> + <%= I18n.t("faf.check_answers.details.category") %>
- <%= @framework_request.message_body %> + <%= @framework_request.category&.title %> + <% if @framework_request.category&.other? %> +

+ <%= @framework_request.category_other %> + <% end %>
- <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_message_path(@framework_request), class: "govuk-link", id: "edit-message", "aria-label": I18n.t("faf.check_answers.aria.change_message") %> + <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_category_path(@framework_request), class: "govuk-link", id: "edit-category", "aria-label": I18n.t("faf.check_answers.aria.change_category") %>
+ <% if @framework_request.contract_length.present? %> +
+
+ <%= I18n.t("faf.check_answers.details.contract_length") %> +
+
+ <%= @framework_request.contract_length %> +
+
+ <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_contract_length_path(@framework_request), class: "govuk-link", id: "edit-contract-length", "aria-label": I18n.t("faf.check_answers.aria.change_contract_length") %> +
+
+ <% end %> + <% if @framework_request.flow.in?(["energy", "services"]) %> +
+
+ <%= I18n.t("faf.check_answers.details.contract_start_date") %> +
+
+ <%= @framework_request.contract_start_date || I18n.t("faf.check_answers.not_known") %> +
+
+ <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_contract_start_date_path(@framework_request), class: "govuk-link", id: "edit-contract-start-date", "aria-label": I18n.t("faf.check_answers.aria.change_contract_start_date") %> +
+
+ <% end %> + <% if @framework_request.same_supplier_used.present? %> +
+
+ <%= I18n.t("faf.check_answers.details.same_supplier_used") %> +
+
+ <%= @framework_request.same_supplier_used %> +
+
+ <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_same_supplier_path(@framework_request), class: "govuk-link", id: "edit-same-supplier", "aria-label": I18n.t("faf.check_answers.aria.change_same_supplier_used") %> +
+
+ <% end %>
- <%= I18n.t("faf.check_answers.details.category") %> + <%= I18n.t("request.label.procurement_amount") %>
- <%= @framework_request.category&.title %> - <% if @framework_request.category&.other? %> -

- <%= @framework_request.category_other %> + <%= @framework_request.procurement_amount %> +
+
+ <% unless @framework_request.submitted? %> + <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_procurement_amount_path(@framework_request), class: "govuk-link", id: "edit-procurement-amount", "aria-label": I18n.t("faf.check_answers.aria.change_procurement_amount") %> <% end %>
+
+
+
+ <%= I18n.t("faf.check_answers.details.problem") %> +
+
+ <%= @framework_request.message_body %> +
- <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_category_path(@framework_request), class: "govuk-link", id: "edit-category", "aria-label": I18n.t("faf.check_answers.aria.change_category") %> + <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_message_path(@framework_request), class: "govuk-link", id: "edit-message", "aria-label": I18n.t("faf.check_answers.aria.change_message") %>
- - <% unless @framework_request.allow_bill_upload? %> + <% if @framework_request.has_bills? %>
- <%= I18n.t("request.label.procurement_amount") %> + <%= I18n.t("faf.check_answers.details.bills_attached") %>
- <%= @framework_request.procurement_amount %> + <%= @framework_request.bill_count %>
<% unless @framework_request.submitted? %> - <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_procurement_amount_path(@framework_request), class: "govuk-link", id: "edit-procurement-amount", "aria-label": I18n.t("faf.check_answers.aria.change_procurement_amount") %> + <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_bill_uploads_path(@framework_request), class: "govuk-link", id: "edit-bill-uploads", "aria-label": I18n.t("faf.check_answers.aria.change_bills_attached") %> <% end %>
<% end %> - - <% if @framework_request.allow_bill_upload? %> + <% if @framework_request.has_documents? %>
- <%= I18n.t("faf.check_answers.details.bills_attached") %> + <%= I18n.t("faf.check_answers.details.documents_attached") %>
- <%= @framework_request.bill_count %> + <%= @framework_request.document_count %>
<% unless @framework_request.submitted? %> - <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_bill_uploads_path(@framework_request), class: "govuk-link", id: "edit-bill-uploads", "aria-label": I18n.t("faf.check_answers.aria.change_bills_attached") %> + <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_document_uploads_path(@framework_request), class: "govuk-link", id: "edit-document-uploads", "aria-label": I18n.t("faf.check_answers.aria.change_documents_attached") %> <% end %>
<% end %> -
<%= I18n.t("request.label.special_requirements") %> @@ -149,6 +198,17 @@ <% end %>
+
+
+ <%= I18n.t("faf.check_answers.details.origin") %> +
+
+ <%= @framework_request.origin %> +
+
+ <%= link_to I18n.t("generic.button.change_answer"), edit_framework_request_origin_path(@framework_request), class: "govuk-link", id: "edit-origin", "aria-label": I18n.t("faf.check_answers.aria.change_origin") %> +
+

diff --git a/app/views/support/cases/requests/show.html.erb b/app/views/support/cases/requests/show.html.erb index 1a33ffaf9..812a366cb 100644 --- a/app/views/support/cases/requests/show.html.erb +++ b/app/views/support/cases/requests/show.html.erb @@ -105,6 +105,28 @@

+ <% if @request&.contract_length.present? %> +
+
+ <%= I18n.t("support.case.label.contract_length") %> +
+
+ <%= @request.contract_length %> +
+
+
+ <% end %> + <% if @request&.flow.in?(["energy", "services"]) %> +
+
+ <%= I18n.t("support.case.label.contract_start_date") %> +
+
+ <%= @request.contract_start_date || I18n.t("support.case.label.not_known") %> +
+
+
+ <% end %> <% if @request&.school_urns.present? %>
@@ -119,6 +141,18 @@
<% end %> + <% if @request&.same_supplier_used.present? %> +
+
+ <%= I18n.t("support.case.label.same_supplier_used") %> +
+
+ <%= @request.same_supplier_used %> +
+
+
+ <% end %> + <% if @current_case.case_attachments.present? %>
@@ -136,6 +170,18 @@
<% end %> + + <% if @request&.origin.present? %> +
+
+ <%= I18n.t("support.case.label.origin") %> +
+
+ <%= @request.origin %> +
+
+
+ <% end %> <% end %> diff --git a/app/views/support/cases/show/_case_details.html.erb b/app/views/support/cases/show/_case_details.html.erb index d7bf6074e..c695b06d7 100644 --- a/app/views/support/cases/show/_case_details.html.erb +++ b/app/views/support/cases/show/_case_details.html.erb @@ -91,6 +91,18 @@
+ + <% if @request&.origin.present? %> +
+
+ <%= I18n.t("support.case.label.origin") %> +
+
+ <%= @request.origin %> +
+
+
+ <% end %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 457f011c6..4416a21fa 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? + hint: Select all that apply options: - energy_contract: "Yes" - not_energy_contract: "No" + used_before: I've used this service before + meeting_or_event: Meeting or event + newsletter: Newsletter + recommendation: Recommendation + search_engine: Search engine, such as Google + social_media: Social media, such as 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: + '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? @@ -562,12 +619,10 @@ en: title: Support Request Confirmed - Get help buying for schools body: what_happens_next: - default: - - The Get help buying for schools team will review your request. We'll be in touch within %{days} working days. energy: - - The Get help buying for schools team will now review your request and energy bills if you've sent them. We'll be in touch within %{days} working days to find a convenient time to discuss your options. - If you chose to email your bills, there will be instructions in the confirmation email telling you how to do this. common: + - The Get help buying for schools team will review your request. We'll be in touch within %{days} working days. - Please check to make sure you receive an email confirmation from us within the next 10 minutes. Check your junk folder if you do not see it. - You'll need to submit your request again if you do not receive an email from us because this is how we'll be contacting you. header: @@ -577,22 +632,14 @@ en: sub_header: confirmation: 'We have sent a confirmation email to:' what_you_can_do_next: - default: - list_start: 'Read guidance about:' - how_to_buy_what_you_need_link: how to buy what you need - what_to_consider_link: what to consider before buying specific goods and services - agreements_and_faf_link: framework agreements and the find a framework tool - bullets: - how_to_buy_what_you_need: "%{how_to_buy_what_you_need_link} to learn more about the buying process" - what_to_consider: "%{what_to_consider_link}" - agreements_and_faf: "%{agreements_and_faf_link}" - energy: - list_start: 'You can read our guidance about %{guidance_link}. It includes:' - guidance_link: buying energy for your school - 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 + list_start: 'Read guidance about:' + how_to_buy_what_you_need_link: how to buy what you need + what_to_consider_link: what to consider before buying specific goods and services + agreements_and_faf_link: framework agreements and the find a framework tool + bullets: + how_to_buy_what_you_need: "%{how_to_buy_what_you_need_link} to learn more about the buying process" + what_to_consider: "%{what_to_consider_link}" + agreements_and_faf: "%{agreements_and_faf_link}" feedback: confirmation_details: message: Thank you for opting in to take part in user research. @@ -821,6 +868,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 +951,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 +994,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 381c1838a..555917439 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 b208acd21..0bcdd31a7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -95,12 +95,6 @@ collection do post "/start", to: "start#create" - get "/energy_request", to: "energy_request#index" - post "/energy_request", to: "energy_request#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" @@ -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 @@ -170,8 +185,14 @@ 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 cabebdc09..0a6d39074 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_13_084703) do +ActiveRecord::Schema[7.0].define(version: 2023_09_18_155242) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_trgm" @@ -119,6 +119,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" @@ -202,6 +214,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" @@ -322,6 +342,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" @@ -859,6 +880,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/categories_controller_spec.rb b/spec/controllers/framework_requests/categories_controller_spec.rb index 670de7014..227e7de0f 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") diff --git a/spec/controllers/framework_requests/confirm_schools_controller_spec.rb b/spec/controllers/framework_requests/confirm_schools_controller_spec.rb index c25725cf4..62d97427a 100644 --- a/spec/controllers/framework_requests/confirm_schools_controller_spec.rb +++ b/spec/controllers/framework_requests/confirm_schools_controller_spec.rb @@ -13,21 +13,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 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..12275836f --- /dev/null +++ b/spec/controllers/framework_requests/contract_lengths_controller_spec.rb @@ -0,0 +1,11 @@ +require "./spec/support/shared/framework_request_controllers" + +describe FrameworkRequests::ContractLengthsController, type: :controller do + include_examples "back url", "/procurement-support/categories" + + 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 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..4ba5f989d --- /dev/null +++ b/spec/controllers/framework_requests/contract_start_dates_controller_spec.rb @@ -0,0 +1,29 @@ +describe FrameworkRequests::ContractStartDatesController, type: :controller do + let(:framework_request) { create(:framework_request) } + + describe "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 + + 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 +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..a41fd8626 --- /dev/null +++ b/spec/controllers/framework_requests/document_uploads_controller_spec.rb @@ -0,0 +1,10 @@ +require "./spec/support/shared/framework_request_controllers" + +describe FrameworkRequests::DocumentUploadsController, type: :controller do + include_examples "back url", "/procurement-support/documents" + + it "redirects to the accessibility needs page" do + post(:create) + expect(response).to redirect_to "/procurement-support/special_requirements" + 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..04e43bbf7 --- /dev/null +++ b/spec/controllers/framework_requests/documents_controller_spec.rb @@ -0,0 +1,23 @@ +require "./spec/support/shared/framework_request_controllers" + +describe FrameworkRequests::DocumentsController, type: :controller do + include_examples "back url", "/procurement-support/message" + + 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 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 index 5f44904c7..a84ddef23 100644 --- a/spec/controllers/framework_requests/energy_alternative_controller_spec.rb +++ b/spec/controllers/framework_requests/energy_alternative_controller_spec.rb @@ -4,18 +4,34 @@ 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" } } + 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 email later" do - include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "email_later" } } + 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 - include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "no_bill" } } + 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 - include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "no_thanks" } } + 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 diff --git a/spec/controllers/framework_requests/energy_bill_controller_spec.rb b/spec/controllers/framework_requests/energy_bill_controller_spec.rb index 9c848ebb9..ab519e8b9 100644 --- a/spec/controllers/framework_requests/energy_bill_controller_spec.rb +++ b/spec/controllers/framework_requests/energy_bill_controller_spec.rb @@ -1,7 +1,7 @@ require "./spec/support/shared/framework_request_controllers" describe FrameworkRequests::EnergyBillController, type: :controller do - include_examples "back url", "/procurement-support/energy_request_about" + include_examples "back url", "/procurement-support/message" context "when the user has no bill" do before { post :create, params: { framework_support_form: { have_energy_bill: "false" } } } @@ -12,6 +12,10 @@ end context "when the user has a bill" do - include_examples "sign-in redirects", { framework_support_form: { have_energy_bill: "true" } } + 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 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..4b50d9498 100644 --- a/spec/controllers/framework_requests/messages_controller_spec.rb +++ b/spec/controllers/framework_requests/messages_controller_spec.rb @@ -1,71 +1,76 @@ 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) } + let(:framework_request_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, framework_request_flow: } } - 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) } + let(:framework_request_flow) { "energy" } + + before { post :create, session: { framework_request_id: framework_request.id, framework_request_flow: } } - 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) } + let(:framework_request_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, framework_request_flow: } } + + 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) } + let(:framework_request_flow) { "services" } - include_examples "back url", "last_energy_path" + before { post :create, session: { framework_request_id: framework_request.id, framework_request_flow: } } - 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) } + let(:framework_request_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, framework_request_flow: } } - 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) } + let(:framework_request_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, framework_request_flow: } } - 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..c53482f1d 100644 --- a/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb +++ b/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb @@ -1,10 +1,68 @@ -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) } + + 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(:framework_request_flow) { "services" } + + context "and it is not a multi-school request" do + before { get :index, session: { framework_request_id: framework_request.id, framework_request_flow: } } + + 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, framework_request_flow: } + 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(:framework_request_flow) { "energy" } + + context "and it is not a multi-school request" do + before { get :index, session: { framework_request_id: framework_request.id, framework_request_flow: } } + + 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, framework_request_flow: } + 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(:framework_request_flow) { nil } + + before { get :index, session: { framework_request_id: framework_request.id, framework_request_flow: } } - 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..f987c9c5c --- /dev/null +++ b/spec/controllers/framework_requests/same_suppliers_controller_spec.rb @@ -0,0 +1,11 @@ +require "./spec/support/shared/framework_request_controllers" + +describe FrameworkRequests::SameSuppliersController, type: :controller do + include_examples "back url", "/procurement-support/contract_start_date" + + 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 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..0fe96a7e6 100644 --- a/spec/controllers/framework_requests/special_requirements_controller_spec.rb +++ b/spec/controllers/framework_requests/special_requirements_controller_spec.rb @@ -1,36 +1,120 @@ 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) } - 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 + let(:framework_request_flow) { "energy" } + + 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, framework_request_flow: } + 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, framework_request_flow: } } + + 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, framework_request_flow: } + 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, framework_request_flow: } } + + 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, framework_request_flow: } + 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, framework_request_flow: } } + + 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 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 the services flow" do + let(:framework_request_flow) { "services" } + 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, framework_request_flow: } + 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, framework_request_flow: } } + + 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 request is in any other flow" do + let(:framework_request_flow) { "goods" } + let(:category) { create(:request_for_help_category, slug: "books", flow: :goods) } + + before { get :index, session: { framework_request_id: framework_request.id, framework_request_flow: } } - 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/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/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/models/specify/framework_request_spec.rb b/spec/models/specify/framework_request_spec.rb index b784dfd19..d7748e26a 100644 --- a/spec/models/specify/framework_request_spec.rb +++ b/spec/models/specify/framework_request_spec.rb @@ -12,66 +12,6 @@ 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:) } 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