+
diff --git a/app/views/framework_requests/bill_uploads/_form.html.erb b/app/views/framework_requests/bill_uploads/_form.html.erb
index d643662e1..919a6955b 100644
--- a/app/views/framework_requests/bill_uploads/_form.html.erb
+++ b/app/views/framework_requests/bill_uploads/_form.html.erb
@@ -27,7 +27,10 @@
Upload your energy information
-
Please upload your most recent energy bill. You can upload multiple bills if you have more than one meter. You can also upload your energy information in another format, like a spreadsheet.
+
+
Please upload your most recent energy bill. You can upload multiple bills if you have more than one meter. You can also upload your energy information in another format, like a spreadsheet.
+
Documents can be any type and must be smaller than 30MB. Upload as many documents as you want.
"
+ data-energy-bill-upload-page-one-continue-button-value="Continue to upload"
+ data-energy-bill-upload-page-two-title-value="Your files are uploading"
+ data-energy-bill-upload-page-two-continue-button-value="Continue to upload"
+ data-energy-bill-upload-page-three-title-value="Your files have been uploaded"
+ data-energy-bill-upload-page-three-continue-button-value="Continue">
+
+
+ <% end %>
<% end %>
<% if @current_case.case_attachments.present? %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9959e11e7..674f4a77e 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -344,15 +344,21 @@ en:
email: Your email address
name: Your name
problem: Description of request
+ contract_length: Contract length
+ contract_start_date: Contract start date
+ same_supplier_used: Same supplier used
school: Your school
school_type: School type
schools_buying_for: Schools you're buying for
school_number: "%{selected} of %{total} schools"
single: Single
bills_attached: Bills attached
+ documents_attached: Documents attached
category: Type of goods or service
+ origin: Origin
header: Send your request
response_time: Once you send this request, we will review it and get in touch within 2 working days.
+ not_known: Not known
aria:
change_name: "Change your name"
change_email: "Change your email"
@@ -360,10 +366,15 @@ en:
change_school_type: "Change your school type"
change_school_picker: "Change the schools you're buying for"
change_message: "Change the description of your request"
+ change_contract_length: "Change the length of your contract"
+ change_contract_start_date: "Change the start date of your contract"
+ change_same_supplier_used: "Change whether the same supplier is used for all your schools"
change_procurement_amount: "Change procurement amount"
change_bills_attached: "Change bills attached"
+ change_documents_attached: "Change documents attached"
change_special_requirements: "Change special requirements"
change_category: "Change type of goods or service"
+ change_origin: "Change the origin of your request"
confirm_group_or_trust:
caption: About your school
choice:
@@ -398,6 +409,47 @@ en:
'no': No, I need to change my selection
table:
school_name: School name
+ contract_length:
+ caption: About your procurement
+ title: How long do you want the contract for including any extensions?
+ hint: Tell us how long you want the contract for at this time. We know this can change. We do not recommend contracts that are shorter than one year.
+ options:
+ one_year: 1 year
+ two_years: 2 years
+ three_years: 3 years
+ four_years: 4 years
+ five_years: 5 years
+ not_sure: Not sure
+ contract_start_date:
+ caption: About your procurement
+ title: Do you know when you want the contract to start?
+ options:
+ 'yes': "Yes"
+ 'no': "No"
+ date:
+ label: Enter the date
+ hint: For example, 27 3 2007
+ invalid: Provide a valid date
+ documents:
+ caption: About your request
+ title: Are there any documents that you would like to upload and share with us?
+ hint:
+ - This may help us to answer your query. We can still help if you cannot upload any documents right now.
+ - You'll also be able to share documents with us at a later date.
+ - Select all that apply.
+ options:
+ current_contract: Current contract
+ communications_with_supplier: Communications with your supplier, such as an email
+ floor_plans: Floor plans or site maps
+ quotes: Quotes
+ specifications: Specifications
+ other: Other, please specify
+ none: I do not have anything to upload right now
+ document_upload:
+ caption: About your request
+ title: Upload your documents
+ body: You can upload any type of document smaller than 30MB. Upload as many documents as you want.
+ hint: "Upload the documents you told us about. These were:"
dsi_or_search:
header: Do you have a DfE Sign-in account linked to the school that your request is about?
link:
@@ -433,21 +485,27 @@ en:
body:
- Your recent energy bills give us the information we need to help you. You'll be able to upload more than one bill if you have them.
- We'll review your bills and use the information to suggest a suitable framework for buying energy. We won't share this information without your permission.
- energy_request:
- header: Is your request about energy?
- subtitle: About your request
- body: 'You can read our guidance about %{guidance_link}. It includes:'
- guidance_link: buying energy for your school
- body_bullets:
- - whether you can get a reduced rate VAT
- - how to choose between fixed, flexible or variable price contracts
- - what to think about when choosing contract length
- energy_request_about:
- header: Is your request about an energy contract, for example, a renewal?
- subtitle: About your request
+ origin:
+ caption: About your procurement
+ title: How did you first find out about this service?
options:
- energy_contract: "Yes"
- not_energy_contract: "No"
+ used_before: I've used this service before
+ meeting_or_event: Meeting or event
+ dfe_publication: DfE publication (e.g. ESFA update, SBP update, Sector Bulletin)
+ non_dfe_publication: Non-DfE newsletter
+ recommendation: Recommendation
+ search_engine: Search engine, such as Google
+ social_media: Social media, such as LinkedIn, Facebook, X (formerly Twitter)
+ website: Website, such as GOV.UK
+ other: Other
+ please_specify: Please specify
+ same_supplier:
+ caption: About your procurement
+ title: Do all the schools currently use the same supplier?
+ options:
+ '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 e9a2159f9..f4bb3474b 100644
--- a/config/locales/validation/en.yml
+++ b/config/locales/validation/en.yml
@@ -66,6 +66,38 @@ en:
attributes:
school_urns_confirmed:
blank: Select whether these are the schools you're buying for
+ framework_requests/contract_length_form:
+ attributes:
+ contract_length:
+ blank: Select the amount of time you want the contract for including any extensions. Choose 'not sure' if you do not know.
+ framework_requests/contract_start_date_form:
+ attributes:
+ contract_start_date_known:
+ blank: Select if you know when the contract should start
+ contract_start_date:
+ blank: Enter the date you want the contract to start
+ framework_requests/same_supplier_form:
+ attributes:
+ same_supplier_used:
+ blank: Select if all schools are currently using the same supplier
+ framework_requests/documents_form:
+ attributes:
+ document_types:
+ blank: Select the documents that you want to upload or 'I do not have any to upload at this time' if there are none to share right now.
+ document_type_other:
+ blank: Specify the type of documents that you want to upload
+ framework_requests/procurement_amount_form:
+ attributes:
+ procurement_amount:
+ blank: Enter how much the school will be spending. The number must be greater than 0.
+ greater_than: The number must be greater than 0
+ not_a_number: Enter a valid number
+ framework_requests/origin_form:
+ attributes:
+ origin:
+ blank: Select where you heard about the service
+ origin_other:
+ blank: Specify where you heard about the service
request:
rules:
diff --git a/config/request_for_help/categories.yml b/config/request_for_help/categories.yml
index 07960e942..4513686b8 100644
--- a/config/request_for_help/categories.yml
+++ b/config/request_for_help/categories.yml
@@ -6,18 +6,23 @@ categories:
slug: accessibility-audits
description: for building or digital
support_category: Audit Accessibility (buildings and digital)
+ flow: services
- title: Decarbonisation energy audits
slug: decarbonisation-energy-audits
support_category: Decarbonisation
+ flow: services
- title: Financial audit
slug: financial-audit
support_category: Audit Financial
+ flow: services
- title: Safeguarding audit
slug: safeguarding-audit
support_category: Audit Safeguarding
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: Financial services
slug: financial-services
@@ -25,15 +30,19 @@ categories:
- title: Financial audit
slug: financial-audit
support_category: Audit Financial
+ flow: services
- title: Insurance
slug: insurance
support_category: Insurance
+ flow: services
- title: Spend analysis
slug: spend-analysis
support_category: Spend Analysis
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: Leasing
slug: leasing
@@ -41,18 +50,23 @@ categories:
- title: Leasing
slug: leasing-sub
support_category: Leasing
+ flow: services
- title: LEDs (light-emitting diode)
slug: leds
support_category: Decarbonisation
+ flow: services
- title: Property leasing agents
slug: property-leasing-agents
support_category: Property leasing agents
+ flow: services
- title: Solar
slug: solar
support_category: Solar
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: School and education supplies
slug: school-and-education-supplies
@@ -60,19 +74,24 @@ categories:
- title: Books
slug: books
support_category: Books
+ flow: goods
- title: Stationery and office supplies
slug: stationery-and-office-supplies
support_category: Stationery supply & office supplies
+ flow: goods
- title: Uniform
slug: uniform
description: for staff or pupils
support_category: Uniform
+ flow: not_fully_supported
- title: Vending machine
slug: vending-machine
support_category: Vending Machine
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Transport
slug: transport
@@ -80,12 +99,15 @@ categories:
- title: Passenger transport
slug: passenger-transport
support_category: Passenger transport
+ flow: services
- title: Vehicle hire or purchase
slug: vehicle-hire-or-purchase
support_category: Vehicle hire & purchase
+ flow: services
- title: Other
slug: other
support_category: Other (BS)
+ flow: services
- title: Food and catering
slug: food-and-catering
@@ -93,22 +115,28 @@ categories:
- title: Breakfast club
slug: breakfast-club
support_category: Breakfast Club
+ flow: services
- title: Catering equipment
slug: catering-equipment
support_category: Catering Equipment
+ flow: goods
- title: Catering services
slug: catering-services
support_category: Catering Services
+ flow: services
- title: Uniform
slug: uniform
description: for staff or pupils
support_category: Uniform
+ flow: not_fully_supported
- title: Vending machine
slug: vending-machine
support_category: Vending Machine
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Energy and utilities
slug: energy-and-utilities
@@ -116,30 +144,39 @@ categories:
- title: Decarbonisation and energy efficiency
slug: decarbonisation-and-energy-efficiency
support_category: Decarbonisation
+ flow: energy
- title: Electricity
slug: electricity
support_category: Electricity
+ flow: energy
- title: Gas
slug: gas
support_category: Gas
+ flow: energy
- title: Heat pumps
slug: heat-pumps
support_category: Decarbonisation
+ flow: energy
- title: LEDs (light-emitting diode)
slug: leds
support_category: Decarbonisation
+ flow: energy
- title: Other fuels
slug: other-fuels
support_category: Other fuels
+ flow: energy
- title: Solar
slug: solar
support_category: Solar
+ flow: services
- title: Water
slug: water
support_category: Water
+ flow: energy
- title: Other
slug: other
support_category: Other (Energy)
+ flow: energy
- title: Cleaning
slug: cleaning
@@ -147,15 +184,19 @@ categories:
- title: Cleaning products
slug: cleaning-products
support_category: Cleaning Products
+ flow: goods
- title: Cleaning services
slug: cleaning-services
support_category: Cleaning Services
+ flow: services
- title: Personal protection equipment (PPE)
slug: ppe
support_category: PPE
+ flow: goods
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Buildings and site maintenance
slug: buildings-and-site-maintenance
@@ -163,44 +204,56 @@ categories:
- title: Boilers and plumbing services
slug: boilers-and-plumbing-services
support_category: Boilers and plumbing services
+ flow: services
- title: Building maintenance and building management system
slug: building-maintenance-and-bms
support_category: Building maintenance & BMS
+ flow: services
- title: Cleaning
slug: cleaning
sub_categories: *cleaning_subcategories
- title: Grounds and winter maintenance
slug: grounds-and-winter-maintenance
support_category: Grounds & Winter Maintenance
+ flow: services
- title: Mechanical and electrical systems
slug: mechanical-and-electrical-systems
support_category: Mechanical & Electrical Systems
+ flow: not_fully_supported
- title: Multi-use games area
slug: mugas
support_category: MUGAs
+ flow: services
- title: Personal protection equipment (PPE)
slug: ppe
support_category: PPE
+ flow: goods
- title: Removal and relocation
slug: removal-and-relocation
description: such as furniture, classroom, moving sites
support_category: Removal & relocation
+ flow: services
- title: Security and CCTV
slug: security-and-cctv
support_category: Security & CCTV
+ flow: services
- title: Water, drains and sewerage
slug: water-drains-and-sewerage
support_category: Water, drains & sewerage
+ flow: energy
- title: Waste management
slug: waste-management
support_category: Waste management
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: Furniture
slug: furniture
support_category: Furniture
+ flow: goods
- title: Health and safety
slug: health-and-safety
@@ -209,19 +262,24 @@ categories:
slug: fire-safety
description: goods and systems
support_category: Fire Safety (Goods & Systems)
+ flow: goods
- title: Personal protection equipment (PPE)
slug: ppe
description: such as masks, protective clothing and helmets
support_category: PPE
+ flow: goods
- title: Security and CCTV
slug: security-and-cctv
support_category: Security & CCTV
+ flow: services
- title: Statutory testing and facilities management compliance
slug: statutory-testing-and-fm-compliance
support_category: Statutory testing & FM Compliance
+ flow: services
- title: Other
slug: other
support_category: Other (FM)
+ flow: services
- title: ICT
slug: ict
@@ -232,86 +290,111 @@ categories:
- title: Audio visual displays
slug: av-displays
support_category: AV Displays
+ flow: services
- title: Laptops
slug: laptops
support_category: Laptops
+ flow: goods
- title: Multi-functional devices (MFD)
slug: mfds
description: devices that can copy, print, scan or fax
support_category: MFD
+ flow: services
- title: Peripherals
slug: peripherals
description: such as keyboards or hard drives
support_category: Peripherals
+ flow: goods
- title: Server configuration and support
slug: server-configuration-and-support
support_category: Server Configuration & Support
+ flow: services
- title: Switches and routers
slug: switches and routers
support_category: Switches & Routers
+ flow: goods
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: ICT funding
slug: ict-funding
support_category: Funding - non procurement requests
+ is_archived: true
+ flow: services
- title: Online platforms and services
slug: online-platforms-and-services
sub_categories:
- title: Cloud SaaS (software-as-a-service)
slug: cloud-saas
support_category: Cloud SaaS
+ flow: services
- title: Cyber services
slug: cyber-services
support_category: Cyber services
+ flow: services
- title: Hosting and storage
slug: hosting-and-storage
support_category: Hosting & Storage
+ flow: services
- title: Server configuration and support
slug: server-configuration-and-support
support_category: Server Configuration & Support
+ flow: services
- title: Virtual learning environment platforms
slug: vle-platforms
support_category: Platforms (VLEs)
+ flow: services
- title: Websites
slug: websites
support_category: Websites
+ flow: services
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: Software
slug: software
sub_categories:
- title: Curriculum content
slug: curriculum-content
support_category: Curriculum Content
+ flow: services
- title: Management information system (MIS)
slug: mis
support_category: MIS
+ flow: services
- title: Operating system software
slug: os-software
support_category: OS Software
+ flow: services
- title: Server configuration and support
slug: server-configuration-and-support
support_category: Server Configuration & Support
+ flow: services
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: Telecoms and broadband
slug: telecoms-and-broadband
sub_categories:
- title: Broadband infrastructure
slug: broadband-infrastructure
support_category: Broadband Infrastructure
+ flow: services
- title: Broadband service
slug: broadband-service
support_category: Broadband service
+ flow: services
- title: Telecoms
slug: telecoms
support_category: Telecoms & Broadband
+ flow: services
- title: Other
slug: other
support_category: Other (ICT)
+ flow: services
- title: Consultancy
slug: consultancy
@@ -320,13 +403,16 @@ categories:
slug: consultancy-direct
description: direct contract with a consultant
support_category: Consultancy
+ flow: services
- title: Managed consultancy
slug: managed-consultancy
description: consultants managed through a service
support_category: Specialist professional services
+ flow: services
- title: Other
slug: other
support_category: Other (PS)
+ flow: services
- title: Human resources and payroll
slug: human-resources-and-payroll
@@ -334,22 +420,29 @@ categories:
- title: Human resources
slug: hr
support_category: HR
+ flow: services
- title: Payroll
slug: payroll
support_category: Payroll
+ flow: services
- title: Recruitment of other staff
slug: recruitment-of-other-staff
support_category: Recruitment of other staff
+ flow: services
- title: Recruitment screening
slug: recruitment-screening
support_category: Recruitment screening
+ flow: services
- title: Supply teachers and agency workers
slug: supply-teachers-and-agency-workers
support_category: Supply Teachers & Agency workers
+ flow: services
- title: Other
slug: other
support_category: Other (PS)
+ flow: services
- title: Legal Services
slug: legal-services
support_category: Legal Services
+ flow: services
diff --git a/config/routes.rb b/config/routes.rb
index 2f866aef6..748676589 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -95,17 +95,11 @@
collection do
post "/start", to: "start#create"
- get "/energy_request", to: "energy_request#index"
- post "/energy_request", to: "energy_request#create"
+ get "/energy_bill", to: "energy_bills#index"
+ post "/energy_bill", to: "energy_bills#create"
- get "/energy_request_about", to: "energy_request_about#index"
- post "/energy_request_about", to: "energy_request_about#create"
-
- get "/energy_bill", to: "energy_bill#index"
- post "/energy_bill", to: "energy_bill#create"
-
- get "/energy_alternative", to: "energy_alternative#index"
- post "/energy_alternative", to: "energy_alternative#create"
+ get "/energy_alternative", to: "energy_alternatives#index"
+ post "/energy_alternative", to: "energy_alternatives#create"
get "/sign_in", to: "sign_in#index"
post "/sign_in", to: "sign_in#create"
@@ -149,11 +143,32 @@
get "/categories/(*category_path)", to: "categories#index", as: "categories"
post "/categories/(*category_path)", to: "categories#create"
+ get "/contract_length", to: "contract_lengths#index"
+ post "/contract_length", to: "contract_lengths#create"
+
+ get "/contract_start_date", to: "contract_start_dates#index"
+ post "/contract_start_date", to: "contract_start_dates#create"
+
+ get "/same_supplier", to: "same_suppliers#index"
+ post "/same_supplier", to: "same_suppliers#create"
+
get "/procurement_amount", to: "procurement_amounts#index"
post "/procurement_amount", to: "procurement_amounts#create"
+ get "/documents", to: "documents#index"
+ post "/documents", to: "documents#create"
+
+ get "/document_uploads", to: "document_uploads#index"
+ post "/document_uploads", to: "document_uploads#create"
+ get "(:id)/document_uploads/list", to: "document_uploads#list", as: "list_document_uploads"
+ post "(:id)/document_uploads/upload", to: "document_uploads#upload", as: "upload_document_uploads"
+ delete "(:id)/document_uploads/remove", to: "document_uploads#remove", as: "remove_document_uploads"
+
get "/special_requirements", to: "special_requirements#index"
post "/special_requirements", to: "special_requirements#create"
+
+ get "/origin", to: "origins#index"
+ post "/origin", to: "origins#create"
end
member do
resource :select_organisation, only: %i[edit update], as: :framework_request_select_organisation
@@ -164,14 +179,22 @@
resource :confirm_schools, only: %i[edit update], as: :framework_request_confirm_schools
resource :name, only: %i[edit update], as: :framework_request_name
resource :email, only: %i[edit update], as: :framework_request_email
+ resource :energy_bill, only: %i[edit update], as: :framework_request_energy_bill
+ resource :energy_alternative, only: %i[edit update], as: :framework_request_energy_alternative
resource :bill_uploads, only: %i[edit update], as: :framework_request_bill_uploads
resource :message, only: %i[edit update], as: :framework_request_message
resource :category, only: [], as: :framework_request_category do
get "edit/(*category_path)", to: "categories#edit", as: "edit"
patch "(*category_path)", to: "categories#update", as: ""
end
+ resource :contract_length, only: %i[edit update], as: :framework_request_contract_length
+ resource :contract_start_date, only: %i[edit update], as: :framework_request_contract_start_date
+ resource :same_supplier, only: %i[edit update], as: :framework_request_same_supplier
resource :procurement_amount, only: %i[edit update], as: :framework_request_procurement_amount
+ resource :documents, only: %i[edit update], as: :framework_request_documents
+ resource :document_uploads, only: %i[edit update], as: :framework_request_document_uploads
resource :special_requirements, only: %i[edit update], as: :framework_request_special_requirements
+ resource :origin, only: %i[edit update], as: :framework_request_origin
end
end
end
diff --git a/config/support/categories.yml b/config/support/categories.yml
index 194c96300..d54121c28 100644
--- a/config/support/categories.yml
+++ b/config/support/categories.yml
@@ -30,6 +30,7 @@ categories:
- title: Cyber services
slug: cyber_services
- title: Funding - non procurement requests
+ is_archived: true
- title: Hosting & Storage
slug: hosting_and_storage
- title: Laptops
diff --git a/db/migrate/20230908141955_add_flow_to_request_for_help_categories.rb b/db/migrate/20230908141955_add_flow_to_request_for_help_categories.rb
new file mode 100644
index 000000000..ec8dec895
--- /dev/null
+++ b/db/migrate/20230908141955_add_flow_to_request_for_help_categories.rb
@@ -0,0 +1,5 @@
+class AddFlowToRequestForHelpCategories < ActiveRecord::Migration[7.0]
+ def change
+ add_column :request_for_help_categories, :flow, :int
+ end
+end
diff --git a/db/migrate/20230913105429_add_contract_length_to_framework_requests.rb b/db/migrate/20230913105429_add_contract_length_to_framework_requests.rb
new file mode 100644
index 000000000..71c53f366
--- /dev/null
+++ b/db/migrate/20230913105429_add_contract_length_to_framework_requests.rb
@@ -0,0 +1,5 @@
+class AddContractLengthToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ add_column :framework_requests, :contract_length, :integer
+ end
+end
diff --git a/db/migrate/20230913125303_add_contract_start_date_to_framework_requests.rb b/db/migrate/20230913125303_add_contract_start_date_to_framework_requests.rb
new file mode 100644
index 000000000..5772719ec
--- /dev/null
+++ b/db/migrate/20230913125303_add_contract_start_date_to_framework_requests.rb
@@ -0,0 +1,8 @@
+class AddContractStartDateToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ change_table :framework_requests, bulk: true do |t|
+ t.column :contract_start_date_known, :boolean
+ t.column :contract_start_date, :date
+ end
+ end
+end
diff --git a/db/migrate/20230913152536_add_same_supplier_used_to_framework_requests.rb b/db/migrate/20230913152536_add_same_supplier_used_to_framework_requests.rb
new file mode 100644
index 000000000..1859df2b0
--- /dev/null
+++ b/db/migrate/20230913152536_add_same_supplier_used_to_framework_requests.rb
@@ -0,0 +1,5 @@
+class AddSameSupplierUsedToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ add_column :framework_requests, :same_supplier_used, :integer
+ end
+end
diff --git a/db/migrate/20230915140037_add_document_types_to_framework_requests.rb b/db/migrate/20230915140037_add_document_types_to_framework_requests.rb
new file mode 100644
index 000000000..d51433b64
--- /dev/null
+++ b/db/migrate/20230915140037_add_document_types_to_framework_requests.rb
@@ -0,0 +1,8 @@
+class AddDocumentTypesToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ change_table :framework_requests, bulk: true do |t|
+ t.column :document_types, :string, array: true, default: []
+ t.column :document_type_other, :text
+ end
+ end
+end
diff --git a/db/migrate/20230915155648_create_documents.rb b/db/migrate/20230915155648_create_documents.rb
new file mode 100644
index 000000000..12ccaf310
--- /dev/null
+++ b/db/migrate/20230915155648_create_documents.rb
@@ -0,0 +1,13 @@
+class CreateDocuments < ActiveRecord::Migration[7.0]
+ def change
+ create_table :documents, id: :uuid do |t|
+ t.integer :submission_status, default: 0
+ t.string :filename
+ t.integer :filesize
+ t.references :support_case, foreign_key: { to_table: :support_cases }, type: :uuid
+ t.references :framework_request, foreign_key: { to_table: :framework_requests }, type: :uuid
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20230918155242_add_origin_to_framework_requests.rb b/db/migrate/20230918155242_add_origin_to_framework_requests.rb
new file mode 100644
index 000000000..341bb201f
--- /dev/null
+++ b/db/migrate/20230918155242_add_origin_to_framework_requests.rb
@@ -0,0 +1,8 @@
+class AddOriginToFrameworkRequests < ActiveRecord::Migration[7.0]
+ def change
+ change_table :framework_requests, bulk: true do |t|
+ t.column :origin, :integer
+ t.column :origin_other, :text
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 866247395..7a9d23ddd 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -121,6 +121,18 @@
t.index ["step_id"], name: "index_currency_answers_on_step_id"
end
+ create_table "documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+ t.integer "submission_status", default: 0
+ t.string "filename"
+ t.integer "filesize"
+ t.uuid "support_case_id"
+ t.uuid "framework_request_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["framework_request_id"], name: "index_documents_on_framework_request_id"
+ t.index ["support_case_id"], name: "index_documents_on_support_case_id"
+ end
+
create_table "energy_bills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.integer "submission_status", default: 0
t.string "filename"
@@ -204,6 +216,14 @@
t.text "category_other"
t.string "school_urns", default: [], array: true
t.uuid "support_case_id"
+ t.integer "contract_length"
+ t.boolean "contract_start_date_known"
+ t.date "contract_start_date"
+ t.integer "same_supplier_used"
+ t.string "document_types", default: [], array: true
+ t.text "document_type_other"
+ t.integer "origin"
+ t.text "origin_other"
t.index ["category_id"], name: "index_framework_requests_on_category_id"
t.index ["support_case_id"], name: "index_framework_requests_on_support_case_id"
t.index ["user_id"], name: "index_framework_requests_on_user_id"
@@ -348,6 +368,7 @@
t.datetime "archived_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "flow"
t.index ["parent_id"], name: "index_request_for_help_categories_on_parent_id"
t.index ["slug"], name: "index_request_for_help_categories_on_slug"
t.index ["support_category_id"], name: "index_request_for_help_categories_on_support_category_id"
@@ -887,6 +908,8 @@
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "all_cases_survey_responses", "support_cases", column: "case_id"
+ add_foreign_key "documents", "framework_requests"
+ add_foreign_key "documents", "support_cases"
add_foreign_key "exit_survey_responses", "support_cases", column: "case_id"
add_foreign_key "framework_requests", "request_for_help_categories", column: "category_id"
add_foreign_key "framework_requests", "support_cases"
diff --git a/spec/controllers/framework_requests/base_controller_spec.rb b/spec/controllers/framework_requests/base_controller_spec.rb
deleted file mode 100644
index 53b3560b6..000000000
--- a/spec/controllers/framework_requests/base_controller_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-describe FrameworkRequests::BaseController, type: :controller do
- describe "#last_energy_path" do
- before do
- allow(controller).to receive(:framework_request).and_return(framework_request)
- allow(controller).to receive(:form).and_return(FrameworkRequests::BaseForm.new(user: build(:user)))
- end
-
- context "when the energy alternative question has been answered" do
- let(:framework_request) { build(:framework_request, energy_alternative: "different_format") }
-
- it "returns the energy alternative path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_alternative"
- end
- end
-
- context "when the energy bill question has been answered" do
- let(:framework_request) { build(:framework_request, have_energy_bill: true) }
-
- it "returns the energy bill path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_bill"
- end
- end
-
- context "when the energy request about question has been answered" do
- let(:framework_request) { build(:framework_request, energy_request_about: "energy_contract") }
-
- it "returns the energy request about path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_request_about"
- end
- end
-
- context "when none of the other energy questions have been answered" do
- let(:framework_request) { build(:framework_request) }
-
- it "returns the energy request path" do
- expect(controller.send(:last_energy_path)).to eq "/procurement-support/energy_request"
- end
- end
- end
-end
diff --git a/spec/controllers/framework_requests/bill_uploads_controller_spec.rb b/spec/controllers/framework_requests/bill_uploads_controller_spec.rb
index 4e73a3b53..1560d80c4 100644
--- a/spec/controllers/framework_requests/bill_uploads_controller_spec.rb
+++ b/spec/controllers/framework_requests/bill_uploads_controller_spec.rb
@@ -1,32 +1,80 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::BillUploadsController, type: :controller do
- it "redirects to the message page" do
- post :create
- expect(response).to redirect_to "/procurement-support/message"
+ describe "on create" do
+ it "redirects to the accessibility needs page" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+
+ describe "back url" do
+ include_examples "back url", "/procurement-support/energy_bill"
+
+ context "when an alternative to energy bills is selected" do
+ let(:framework_request) { create(:framework_request, energy_alternative: :different_format) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/energy_alternative"
+ end
+ end
+ end
end
- describe "back url" do
- context "when the user is signed in" do
- before { user_is_signed_in(user:) }
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy"), energy_alternative:) }
+ let(:energy_alternative) { nil }
+
+ context "when coming in from the check-your-answers page" do
+ let(:framework_support_form) { { framework_support_form: { source: "change_link" } } }
+ let(:params) { { id: framework_request.id, **framework_support_form } }
+
+ before { get :edit, params: }
- context "when the user belongs to one organisation" do
- let(:user) { build(:user, :one_supported_school) }
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when coming in from elsewhere" do
+ let(:params) { { id: framework_request.id } }
- before { allow(controller).to receive(:last_energy_path).and_return("last_energy_path") }
+ context "when the user selected to upload bills straight away" do
+ let(:energy_alternative) { nil }
- include_examples "back url", "last_energy_path"
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the energy bill page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/energy_bill/edit"
+ end
end
- context "when the user belongs to multiple organisations" do
- let(:user) { build(:user, :many_supported_schools) }
+ context "when the user selected to upload bills via energy alternative" do
+ let(:energy_alternative) { :different_format }
+
+ before do
+ get :edit, params:
+ end
- include_examples "back url", "/procurement-support/select_organisation"
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/energy_alternative/edit"
+ end
end
end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+
+ before do
+ patch :update, params: { id: framework_request.id }
+ end
- context "when the user is not signed in" do
- include_examples "back url", "/procurement-support/email"
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
end
end
end
diff --git a/spec/controllers/framework_requests/categories_controller_spec.rb b/spec/controllers/framework_requests/categories_controller_spec.rb
index 670de7014..c6fe2a2d4 100644
--- a/spec/controllers/framework_requests/categories_controller_spec.rb
+++ b/spec/controllers/framework_requests/categories_controller_spec.rb
@@ -1,11 +1,10 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::CategoriesController, type: :controller do
- let(:framework_request) { create(:framework_request, category:, is_energy_request:, energy_request_about:, have_energy_bill:) }
+ let(:framework_request) { create(:framework_request, category:, group:, org_id:) }
let(:category) { nil }
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ let(:group) { nil }
+ let(:org_id) { nil }
let(:a) { create(:request_for_help_category, slug: "a") }
let(:b) { create(:request_for_help_category, slug: "b", parent: a) }
@@ -22,10 +21,53 @@
end
context "when the user is on the main categories page" do
- before { get :index, session: { framework_request_id: framework_request.id } }
+ context "and the user is signed in" do
+ before { user_is_signed_in(user:) }
- it "goes back to the message page" do
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/message"
+ context "and the user belongs to a MAT or federation with multiple schools" do
+ let(:user) { build(:user, :one_supported_group) }
+ let(:group) { true }
+ let(:org_id) { "2314" }
+
+ before do
+ establishment_group_type = create(:support_establishment_group_type, code: 6)
+ create(:support_establishment_group, name: "Testing Multi Academy Trust", uid: "2314", establishment_group_type:)
+ create_list(:support_organisation, 2, trust_code: "2314")
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the schools confirmation page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/confirm_schools"
+ end
+ end
+
+ context "and the user belongs to a single chosen organisation" do
+ let(:user) { build(:user, :many_supported_schools) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the select organisation page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/select_organisation"
+ end
+ end
+
+ context "and the user belongs to a single inferred organisation" do
+ let(:user) { build(:user, :one_supported_school) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the confirm sign-in page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/confirm_sign_in"
+ end
+ end
+ end
+
+ context "and the user is a guest" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the email page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/email"
+ end
end
end
@@ -92,22 +134,29 @@
end
context "when the user has chosen a final category" do
- before { post :create, params: { category_path: "a/b", framework_support_form: { category_slug: "c" } }, session: { framework_request_id: framework_request.id } }
+ before do
+ c.update!(flow:)
+ post :create, params: { category_path: "a/b", framework_support_form: { category_slug: "c" } }, session: { framework_request_id: framework_request.id }
+ end
+
+ context "and they are in the services flow" do
+ let(:flow) { :services }
+
+ it "redirects to the contract length page" do
+ expect(response).to redirect_to("/procurement-support/contract_length")
+ end
+ end
- context "and they have chosen to upload a bill" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { "energy_contract" }
- let(:have_energy_bill) { true }
+ context "and they are in the energy flow" do
+ let(:flow) { :energy }
- it "redirects to the accessibility page" do
- expect(response).to redirect_to("/procurement-support/special_requirements")
+ it "redirects to the contract length page" do
+ expect(response).to redirect_to("/procurement-support/contract_length")
end
end
- context "and they have chosen not to upload a bill" do
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ context "and they are not in the energy or services flow" do
+ let(:flow) { :goods }
it "redirects to the procurement amount page" do
expect(response).to redirect_to("/procurement-support/procurement_amount")
@@ -141,14 +190,29 @@
context "when the user has chosen a final category" do
let(:patch_action) { patch :update, params: { id: framework_request.id, category_path: "a/b", framework_support_form: { category_slug: "c" } } }
- it "redirects to the check-your-answers page" do
- patch_action
- expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
- end
-
it "persists the final category" do
expect { patch_action }.to change { framework_request.reload.category }.from(nil).to(c)
end
+
+ context "and the flow is finished" do
+ it "redirects to the check-your-answers page" do
+ patch_action
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+
+ context "and the flow is unfinished" do
+ let(:category) { create(:request_for_help_category, slug: "d", flow: :goods) }
+ let(:e) { create(:request_for_help_category, slug: "e", parent: b, flow: :services) }
+
+ before do
+ patch :update, params: { id: framework_request.id, category_path: "a/b", framework_support_form: { category_slug: e.slug } }
+ end
+
+ it "redirects to the contract length page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/contract_length/edit")
+ end
+ end
end
end
end
diff --git a/spec/controllers/framework_requests/confirm_schools_controller_spec.rb b/spec/controllers/framework_requests/confirm_schools_controller_spec.rb
index c25725cf4..8a9faa56d 100644
--- a/spec/controllers/framework_requests/confirm_schools_controller_spec.rb
+++ b/spec/controllers/framework_requests/confirm_schools_controller_spec.rb
@@ -1,10 +1,11 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::ConfirmSchoolsController, type: :controller do
- let(:framework_request) { create(:framework_request) }
+ let(:framework_request) { create(:framework_request, category:) }
let(:school_urns_confirmed) { false }
let(:school_urns) { %w[1 2] }
let(:framework_support_form) { { framework_support_form: { school_urns:, school_urns_confirmed: } } }
+ let(:category) { nil }
let(:params) { framework_support_form }
describe "create" do
@@ -13,21 +14,12 @@
context "when the schools are confirmed" do
let(:school_urns_confirmed) { true }
- context "and it is an energy request" do
- let(:framework_request) { create(:framework_request, :energy_request) }
-
- it "redirects to the bill upload page" do
- post(:create, params:, session:)
- expect(response).to redirect_to "/procurement-support/bill_uploads"
- end
- end
-
context "and the user is signed in" do
before { user_is_signed_in }
- it "redirects to the message page" do
+ it "redirects to the categories page" do
post(:create, params:, session:)
- expect(response).to redirect_to "/procurement-support/message"
+ expect(response).to redirect_to "/procurement-support/categories"
end
end
@@ -55,9 +47,35 @@
context "when the schools are confirmed" do
let(:school_urns_confirmed) { true }
- it "redirects to the request" do
- patch(:update, params:)
- expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ context "and a single school has been selected" do
+ let(:school_urns) { %w[1] }
+
+ it "redirects to the request" do
+ patch(:update, params:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "and multiple schools have been selected" do
+ let(:school_urns) { %w[1 2] }
+
+ context "and the user is in the services flow" do
+ let(:category) { create(:request_for_help_category, flow: :services) }
+
+ it "redirects to the same supplier page" do
+ patch(:update, params:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
+
+ context "and the user is in the energy flow" do
+ let(:category) { create(:request_for_help_category, flow: :energy) }
+
+ it "redirects to the same supplier page" do
+ patch(:update, params:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
end
end
diff --git a/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb b/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb
index a9e88ee13..11946f555 100644
--- a/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb
+++ b/spec/controllers/framework_requests/confirm_sign_in_controller_spec.rb
@@ -13,21 +13,23 @@
context "when the user belongs to one organisation" do
let(:user) { build(:user, :one_supported_school) }
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
-
- it "redirects to the message page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/message"
- end
+ it "redirects to the categories page" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/categories"
end
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ context "and the organisation is a MAT or federation with multiple schools" do
+ let(:user) { build(:user, :one_supported_group) }
+
+ before do
+ establishment_group_type = create(:support_establishment_group_type, code: 6)
+ create(:support_establishment_group, name: "Testing Multi Academy Trust", uid: "2314", establishment_group_type:)
+ create_list(:support_organisation, 2, trust_code: "2314")
+ end
- it "redirects to the bill upload page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/bill_uploads"
+ it "redirects to the school picker page" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/school_picker"
end
end
end
diff --git a/spec/controllers/framework_requests/contract_lengths_controller_spec.rb b/spec/controllers/framework_requests/contract_lengths_controller_spec.rb
new file mode 100644
index 000000000..7e63a6770
--- /dev/null
+++ b/spec/controllers/framework_requests/contract_lengths_controller_spec.rb
@@ -0,0 +1,73 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::ContractLengthsController, type: :controller do
+ include_examples "back url", "/procurement-support/categories"
+
+ describe "on create" do
+ it "redirects to the contract start date page" do
+ params = { framework_support_form: { contract_length: "not_sure" } }
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/contract_start_date"
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_length:, contract_start_date_known:) }
+
+ context "when the flow is unfinished" do
+ let(:contract_length) { nil }
+ let(:contract_start_date_known) { nil }
+
+ before do
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the categories page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/category/edit"
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:contract_length) { :one_year }
+ let(:contract_start_date_known) { false }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_start_date_known:) }
+
+ context "when the flow is unfinished" do
+ let(:contract_start_date_known) { nil }
+
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_length: "one_year" } }
+ end
+
+ it "redirects to the contract start date page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/contract_start_date/edit")
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:contract_start_date_known) { false }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_length: "one_year" } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/contract_start_dates_controller_spec.rb b/spec/controllers/framework_requests/contract_start_dates_controller_spec.rb
new file mode 100644
index 000000000..0fb1076ef
--- /dev/null
+++ b/spec/controllers/framework_requests/contract_start_dates_controller_spec.rb
@@ -0,0 +1,111 @@
+describe FrameworkRequests::ContractStartDatesController, type: :controller do
+ let(:framework_request) { create(:framework_request) }
+
+ it "goes back to the contract length page" do
+ get(:index, params: { framework_support_form: { contract_start_date_known: nil } })
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/contract_length"
+ end
+
+ describe "on create" do
+ let(:params) { { framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } } }
+ let(:session) { { framework_request_id: framework_request.id } }
+
+ context "when multiple schools are selected" do
+ before { framework_request.update!(school_urns: %w[1 2]) }
+
+ it "redirects to the all schools same supplier page" do
+ post(:create, params:, session:)
+ expect(response).to redirect_to "/procurement-support/same_supplier"
+ end
+ end
+
+ context "when a single organisation is selected" do
+ it "redirects to the procurement amount page" do
+ post(:create, params:, session:)
+ expect(response).to redirect_to "/procurement-support/procurement_amount"
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_length: :one_year, contract_start_date_known: false) }
+
+ context "when the flow is unfinished" do
+ before do
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the contract length page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_length/edit"
+ end
+ end
+
+ context "when the flow is finished" do
+ before do
+ framework_request.update!(document_types: %w[none])
+ get :edit, params: { id: framework_request.id }
+ end
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, contract_length: :one_year, category:) }
+ let(:category) { create(:request_for_help_category, flow: "services") }
+
+ context "when the flow is unfinished" do
+ context "and the organisation is a MAT with multiple selected schools" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } }
+ end
+
+ it "redirects to the same supplier page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/same_supplier/edit")
+ end
+ end
+
+ context "and the organisation is a single school" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } }
+ end
+
+ context "and the user has chosen gas or electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: "energy") }
+
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: false } }
+ end
+
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/energy_bill/edit")
+ end
+ end
+
+ context "and the user has chosen a service or a different energy category" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: false } }
+ end
+
+ it "redirects to the documents page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/documents/edit")
+ end
+ end
+ end
+ end
+
+ context "when the flow is finished" do
+ before do
+ framework_request.update!(document_types: %w[none])
+ patch :update, params: { id: framework_request.id, framework_support_form: { contract_start_date_known: "true", "contract_start_date(3i)": "27", "contract_start_date(2i)": "3", "contract_start_date(1i)": "2023" } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/document_uploads_controller_spec.rb b/spec/controllers/framework_requests/document_uploads_controller_spec.rb
new file mode 100644
index 000000000..d2992d505
--- /dev/null
+++ b/spec/controllers/framework_requests/document_uploads_controller_spec.rb
@@ -0,0 +1,49 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::DocumentUploadsController, type: :controller do
+ include_examples "back url", "/procurement-support/documents"
+
+ describe "on create" do
+ it "redirects to the accessibility needs page" do
+ post(:create)
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+
+ before do
+ patch :update, params: { id: framework_request.id }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+
+ context "when coming in from the check-your-answers page" do
+ let(:framework_support_form) { { framework_support_form: { source: "change_link" } } }
+ let(:params) { { id: framework_request.id, **framework_support_form } }
+
+ before { get :edit, params: }
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when coming in from elsewhere" do
+ let(:params) { { id: framework_request.id } }
+
+ before { get :edit, params: }
+
+ it "goes back to the documents page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/documents/edit"
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/documents_controller_spec.rb b/spec/controllers/framework_requests/documents_controller_spec.rb
new file mode 100644
index 000000000..c1ba75b8f
--- /dev/null
+++ b/spec/controllers/framework_requests/documents_controller_spec.rb
@@ -0,0 +1,75 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::DocumentsController, type: :controller do
+ include_examples "back url", "/procurement-support/message"
+
+ describe "on create" do
+ context "when the document type is none" do
+ let(:params) { { framework_support_form: { document_types: %w[none] } } }
+
+ it "redirects to the accessibility needs page" do
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ context "when the document types are anything else" do
+ let(:params) { { framework_support_form: { document_types: %w[floor_plans] } } }
+
+ it "redirects to the document upload page" do
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/document_uploads"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+
+ context "when the document type is none" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { document_types: %w[none] } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+
+ context "when the document types are anything else" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { document_types: %w[floor_plans] } }
+ end
+
+ it "redirects to the document uploads page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/document_uploads/edit")
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services")) }
+ let(:params) { { id: framework_request.id } }
+
+ context "when the request is for a MAT with multiple schools" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :edit, params:
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
+
+ context "when the request is for a single school" do
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_start_date/edit"
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/emails_controller_spec.rb b/spec/controllers/framework_requests/emails_controller_spec.rb
index f7dfc1913..868edcbc2 100644
--- a/spec/controllers/framework_requests/emails_controller_spec.rb
+++ b/spec/controllers/framework_requests/emails_controller_spec.rb
@@ -3,21 +3,8 @@
describe FrameworkRequests::EmailsController, type: :controller do
include_examples "back url", "/procurement-support/name"
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
-
- it "redirects to the bill upload page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/bill_uploads"
- end
- end
-
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
-
- it "redirects to the message page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/message"
- end
+ it "redirects to the categories page" do
+ post :create, params: { framework_support_form: { email: "test@example.com" } }
+ expect(response).to redirect_to "/procurement-support/categories"
end
end
diff --git a/spec/controllers/framework_requests/energy_alternative_controller_spec.rb b/spec/controllers/framework_requests/energy_alternative_controller_spec.rb
deleted file mode 100644
index 5f44904c7..000000000
--- a/spec/controllers/framework_requests/energy_alternative_controller_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyAlternativeController, type: :controller do
- include_examples "back url", "/procurement-support/energy_bill"
-
- context "when the user has selected different format" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "different_format" } }
- end
-
- context "when the user has selected email later" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "email_later" } }
- end
-
- context "when the user has selected no bill" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "no_bill" } }
- end
-
- context "when the user has selected no thanks" do
- include_examples "sign-in redirects", { framework_support_form: { energy_alternative: "no_thanks" } }
- end
-end
diff --git a/spec/controllers/framework_requests/energy_alternatives_controller_spec.rb b/spec/controllers/framework_requests/energy_alternatives_controller_spec.rb
new file mode 100644
index 000000000..4a79fad0c
--- /dev/null
+++ b/spec/controllers/framework_requests/energy_alternatives_controller_spec.rb
@@ -0,0 +1,88 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::EnergyAlternativesController, type: :controller do
+ include_examples "back url", "/procurement-support/energy_bill"
+
+ describe "on create" do
+ context "when the user has selected different format" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "different_format" } } }
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to "/procurement-support/bill_uploads"
+ end
+ end
+
+ context "when the user has selected to email later" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "email_later" } } }
+
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ context "when the user has selected no bill" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "no_bill" } } }
+
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+
+ context "when the user has selected no thanks" do
+ before { post :create, params: { framework_support_form: { energy_alternative: "no_thanks" } } }
+
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+
+ context "when the user has selected different format" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "different_format" } } }
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}/bill_uploads/edit"
+ end
+ end
+
+ context "when the user has selected to email later" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "email_later" } } }
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when the user has selected no bill" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "no_bill" } } }
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when the user has selected no thanks" do
+ before { patch :update, params: { id: framework_request.id, framework_support_form: { energy_alternative: "no_thanks" } } }
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+ let(:params) { { id: framework_request.id } }
+
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the energy bill page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/energy_bill/edit"
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/energy_bill_controller_spec.rb b/spec/controllers/framework_requests/energy_bill_controller_spec.rb
deleted file mode 100644
index 9c848ebb9..000000000
--- a/spec/controllers/framework_requests/energy_bill_controller_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyBillController, type: :controller do
- include_examples "back url", "/procurement-support/energy_request_about"
-
- context "when the user has no bill" do
- before { post :create, params: { framework_support_form: { have_energy_bill: "false" } } }
-
- it "redirects to the energy alternative page" do
- expect(response).to redirect_to "/procurement-support/energy_alternative"
- end
- end
-
- context "when the user has a bill" do
- include_examples "sign-in redirects", { framework_support_form: { have_energy_bill: "true" } }
- end
-end
diff --git a/spec/controllers/framework_requests/energy_bills_controller_spec.rb b/spec/controllers/framework_requests/energy_bills_controller_spec.rb
new file mode 100644
index 000000000..d16e2926f
--- /dev/null
+++ b/spec/controllers/framework_requests/energy_bills_controller_spec.rb
@@ -0,0 +1,73 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::EnergyBillsController, type: :controller do
+ include_examples "back url", "/procurement-support/message"
+
+ describe "on create" do
+ context "when the user has no bill" do
+ before { post :create, params: { framework_support_form: { have_energy_bill: "false" } } }
+
+ it "redirects to the energy alternative page" do
+ expect(response).to redirect_to "/procurement-support/energy_alternative"
+ end
+ end
+
+ context "when the user has a bill" do
+ before { post :create, params: { framework_support_form: { have_energy_bill: "true" } } }
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to "/procurement-support/bill_uploads"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+
+ context "when the user has an energy bill" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { have_energy_bill: "true" } }
+ end
+
+ it "redirects to the bill uploads page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/bill_uploads/edit")
+ end
+ end
+
+ context "when the user does not have an energy bill" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { have_energy_bill: "false" } }
+ end
+
+ it "redirects to the energy alternative page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/energy_alternative/edit")
+ end
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "energy")) }
+ let(:params) { { id: framework_request.id } }
+
+ context "when the request is for a MAT with multiple schools" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :edit, params:
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/same_supplier/edit"
+ end
+ end
+
+ context "when the request is for a single school" do
+ before do
+ get :edit, params:
+ end
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_start_date/edit"
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/energy_request_about_controller_spec.rb b/spec/controllers/framework_requests/energy_request_about_controller_spec.rb
deleted file mode 100644
index a2d4ed32c..000000000
--- a/spec/controllers/framework_requests/energy_request_about_controller_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyRequestAboutController, type: :controller do
- include_examples "back url", "/procurement-support/energy_request"
-
- context "when it is about an energy contract" do
- before { post :create, params: { framework_support_form: { energy_request_about: "energy_contract" } } }
-
- it "redirects to the energy bill page" do
- expect(response).to redirect_to "/procurement-support/energy_bill"
- end
- end
-
- context "when it is not about an energy contract" do
- include_examples "sign-in redirects", { framework_support_form: { energy_request_about: "not_energy_contract" } }
- end
-end
diff --git a/spec/controllers/framework_requests/energy_request_controller_spec.rb b/spec/controllers/framework_requests/energy_request_controller_spec.rb
deleted file mode 100644
index 062497ca8..000000000
--- a/spec/controllers/framework_requests/energy_request_controller_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "./spec/support/shared/framework_request_controllers"
-
-describe FrameworkRequests::EnergyRequestController, type: :controller do
- include_examples "back url", "/procurement-support"
-
- context "when it is an energy request" do
- before { post :create, params: { framework_support_form: { is_energy_request: "true" } } }
-
- it "redirects to the energy request about page" do
- expect(response).to redirect_to "/procurement-support/energy_request_about"
- end
- end
-
- context "when it is not an energy request" do
- include_examples "sign-in redirects", { framework_support_form: { is_energy_request: "false" } }
- end
-end
diff --git a/spec/controllers/framework_requests/messages_controller_spec.rb b/spec/controllers/framework_requests/messages_controller_spec.rb
index eef68f367..4bd2e6c02 100644
--- a/spec/controllers/framework_requests/messages_controller_spec.rb
+++ b/spec/controllers/framework_requests/messages_controller_spec.rb
@@ -1,71 +1,70 @@
require "./spec/support/shared/framework_request_controllers"
describe FrameworkRequests::MessagesController, type: :controller do
- context "when feature :energy_bill_flow is not enabled" do
- let(:framework_request) { create(:framework_request) }
+ let(:framework_request) { create(:framework_request, category:) }
+ let(:category) { nil }
- before { Flipper.disable(:energy_bill_flow) }
+ include_examples "back url", "/procurement-support/procurement_amount"
- it "redirects to the category page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/categories"
- end
- end
+ context "when the request is in the energy flow" do
+ context "and about electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: :energy) }
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
- it "redirects to the category page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/categories"
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to "/procurement-support/energy_bill"
+ end
end
- end
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
+ context "and about gas" do
+ let(:category) { create(:request_for_help_category, slug: "gas", flow: :energy) }
+
+ before { post :create, session: { framework_request_id: framework_request.id } }
- it "redirects to the category page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/categories"
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to "/procurement-support/energy_bill"
+ end
end
- end
- describe "back url" do
- context "when the user is signed in" do
- before { user_is_signed_in(user:) }
+ context "and about anything else" do
+ let(:category) { create(:request_for_help_category, slug: "water", flow: :energy) }
- context "when the user belongs to one organisation" do
- let(:user) { build(:user, :one_supported_school) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
+
+ it "redirects to the documents page" do
+ expect(response).to redirect_to "/procurement-support/documents"
+ end
+ end
+ end
- before { allow(controller).to receive(:last_energy_path).and_return("last_energy_path") }
+ context "when the request is in the services flow" do
+ let(:category) { create(:request_for_help_category, slug: "catering-services", flow: :services) }
- include_examples "back url", "last_energy_path"
+ before { post :create, session: { framework_request_id: framework_request.id } }
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
+ it "redirects to the documents page" do
+ expect(response).to redirect_to "/procurement-support/documents"
+ end
+ end
- include_examples "back url", "/procurement-support/select_organisation"
- end
- end
+ context "when the request is in the goods flow" do
+ let(:category) { create(:request_for_help_category, slug: "books", flow: :goods) }
- context "when the user belongs to multiple organisations" do
- let(:user) { build(:user, :many_supported_schools) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
- include_examples "back url", "/procurement-support/select_organisation"
- end
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
end
+ end
- context "when the user is not signed in" do
- include_examples "back url", "/procurement-support/email"
- end
+ context "when the request is in the not-fully-supported flow" do
+ let(:category) { create(:request_for_help_category, slug: "uniform", flow: :not_fully_supported) }
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ before { post :create, session: { framework_request_id: framework_request.id } }
- it "goes back to the bill upload page" do
- get :index, session: { framework_request_id: framework_request.id }
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/bill_uploads"
- end
+ it "redirects to the accessibility needs page" do
+ expect(response).to redirect_to "/procurement-support/special_requirements"
end
end
end
diff --git a/spec/controllers/framework_requests/origins_controller_spec.rb b/spec/controllers/framework_requests/origins_controller_spec.rb
new file mode 100644
index 000000000..58ea8e569
--- /dev/null
+++ b/spec/controllers/framework_requests/origins_controller_spec.rb
@@ -0,0 +1,14 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::OriginsController, type: :controller do
+ let(:framework_request) { create(:framework_request) }
+
+ include_examples "back url", "/procurement-support/special_requirements"
+
+ it "redirects to the framework request page" do
+ params = { framework_support_form: { origin: "website" } }
+ session = { framework_request_id: framework_request.id }
+ post(:create, params:, session:)
+ expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ end
+end
diff --git a/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb b/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb
index b94d64a28..368376d84 100644
--- a/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb
+++ b/spec/controllers/framework_requests/procurement_amounts_controller_spec.rb
@@ -1,10 +1,69 @@
-require "./spec/support/shared/framework_request_controllers"
-
describe FrameworkRequests::ProcurementAmountsController, type: :controller do
- include_examples "back url", "/procurement-support/categories"
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow:)) }
+ let(:flow) { nil }
+
+ it "redirects to the message page" do
+ post :create, params: { framework_support_form: { procurement_amount: "205.13" } }
+ expect(response).to redirect_to "/procurement-support/message"
+ end
+
+ describe "back url" do
+ describe "on index" do
+ context "when the user is in the services flow" do
+ let(:flow) { "services" }
+
+ context "and it is not a multi-school request" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/contract_start_date"
+ end
+ end
+
+ context "and it is a multi-school request" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/same_supplier"
+ end
+ end
+ end
+
+ context "when the user is in the energy flow" do
+ let(:flow) { "energy" }
+
+ context "and it is not a multi-school request" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/contract_start_date"
+ end
+ end
+
+ context "and it is a multi-school request" do
+ before do
+ framework_request.update!(school_urns: %w[1 2])
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the same supplier page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/same_supplier"
+ end
+ end
+ end
+
+ context "when the user is in a different flow" do
+ let(:flow) { "goods" }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
- it "redirects to the special requirements page" do
- post :create
- expect(response).to redirect_to "/procurement-support/special_requirements"
+ it "goes back to the categories page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/categories"
+ end
+ end
+ end
end
end
diff --git a/spec/controllers/framework_requests/same_suppliers_controller_spec.rb b/spec/controllers/framework_requests/same_suppliers_controller_spec.rb
new file mode 100644
index 000000000..f135576ad
--- /dev/null
+++ b/spec/controllers/framework_requests/same_suppliers_controller_spec.rb
@@ -0,0 +1,93 @@
+require "./spec/support/shared/framework_request_controllers"
+
+describe FrameworkRequests::SameSuppliersController, type: :controller do
+ include_examples "back url", "/procurement-support/contract_start_date"
+
+ describe "on create" do
+ it "redirects to the procurement amount page" do
+ params = { framework_support_form: { same_supplier_used: "yes" } }
+ post(:create, params:)
+ expect(response).to redirect_to "/procurement-support/procurement_amount"
+ end
+ end
+
+ describe "on edit" do
+ let(:framework_request) { create(:framework_request, category: create(:request_for_help_category, flow: "services"), contract_length: :one_year, contract_start_date_known: false) }
+
+ context "when coming in from the check-your-answers page" do
+ let(:framework_support_form) { { framework_support_form: { source: "change_link" } } }
+ let(:params) { { id: framework_request.id, **framework_support_form } }
+
+ before { get :edit, params: }
+
+ it "goes back to the check-your-answers page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}"
+ end
+ end
+
+ context "when the flow is unfinished" do
+ let(:params) { { id: framework_request.id } }
+
+ before { get :edit, params: }
+
+ it "goes back to the contract start date page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/contract_start_date/edit"
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:params) { { id: framework_request.id } }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ get :edit, params:
+ end
+
+ it "goes back to the confirm schools page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/#{framework_request.id}/confirm_schools/edit"
+ end
+ end
+ end
+
+ describe "on update" do
+ let(:framework_request) { create(:framework_request, contract_length: :one_year, contract_start_date_known: false, category:) }
+ let(:category) { create(:request_for_help_category, flow: "services") }
+
+ context "when the flow is unfinished" do
+ context "and the user has chosen gas or electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: "energy") }
+
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { same_supplier_used: "yes" } }
+ end
+
+ it "redirects to the energy bill page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/energy_bill/edit")
+ end
+ end
+
+ context "and the user has chosen a service or a different energy category" do
+ before do
+ patch :update, params: { id: framework_request.id, framework_support_form: { same_supplier_used: "yes" } }
+ end
+
+ it "redirects to the documents page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}/documents/edit")
+ end
+ end
+ end
+
+ context "when the flow is finished" do
+ let(:contract_start_date) { Date.parse("2023-09-21") }
+
+ before do
+ framework_request.update!(document_types: %w[none])
+ patch :update, params: { id: framework_request.id, framework_support_form: { same_supplier_used: "yes" } }
+ end
+
+ it "redirects to the check-your-answers page" do
+ expect(response).to redirect_to("/procurement-support/#{framework_request.id}")
+ end
+ end
+ end
+end
diff --git a/spec/controllers/framework_requests/select_organisations_controller_spec.rb b/spec/controllers/framework_requests/select_organisations_controller_spec.rb
index 4b7560a06..27c7cffc9 100644
--- a/spec/controllers/framework_requests/select_organisations_controller_spec.rb
+++ b/spec/controllers/framework_requests/select_organisations_controller_spec.rb
@@ -3,26 +3,34 @@
describe FrameworkRequests::SelectOrganisationsController, type: :controller do
before do
user_is_signed_in
- allow(controller).to receive(:last_energy_path).and_return "last_energy_path"
end
- include_examples "back url", "last_energy_path"
+ include_examples "back url", "/procurement-support/confirm_sign_in"
- context "when the user has chosen to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: true, energy_request_about: "energy_contract", have_energy_bill: true) }
+ context "when the user has chosen a MAT or federation" do
+ let(:framework_request) { create(:framework_request) }
- it "redirects to the bill upload page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/bill_uploads"
+ before do
+ create(:support_establishment_group, uid: "123", establishment_group_type: create(:support_establishment_group_type, code: 2))
+ create(:support_organisation, trust_code: "123")
+ end
+
+ it "redirects to the school picker" do
+ post :create, params: { framework_support_form: { group: "true", org_id: "123" } }, session: { framework_request_id: framework_request.id }
+ expect(response).to redirect_to "/procurement-support/school_picker"
end
end
- context "when the user has chosen not to upload a bill" do
- let(:framework_request) { create(:framework_request, is_energy_request: false) }
+ context "when the user has chosen a single school" do
+ let(:framework_request) { create(:framework_request) }
+
+ before do
+ create(:support_organisation, urn: "123")
+ end
- it "redirects to the message page" do
- post :create, session: { framework_request_id: framework_request.id }
- expect(response).to redirect_to "/procurement-support/message"
+ it "redirects to the categories page" do
+ post :create, params: { framework_support_form: { group: "false", org_id: "123" } }, session: { framework_request_id: framework_request.id }
+ expect(response).to redirect_to "/procurement-support/categories"
end
end
end
diff --git a/spec/controllers/framework_requests/sign_in_controller_spec.rb b/spec/controllers/framework_requests/sign_in_controller_spec.rb
index 4f48b0410..e3b6b7a25 100644
--- a/spec/controllers/framework_requests/sign_in_controller_spec.rb
+++ b/spec/controllers/framework_requests/sign_in_controller_spec.rb
@@ -18,16 +18,7 @@
end
context "when a back url is not provided" do
- include_examples "back url", "/procurement-support/energy_request"
-
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
-
- it "goes back to the start" do
- get :index
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support"
- end
- end
+ include_examples "back url", "/procurement-support"
end
end
end
diff --git a/spec/controllers/framework_requests/special_requirements_controller_spec.rb b/spec/controllers/framework_requests/special_requirements_controller_spec.rb
index 8dd8578f0..800e5e5aa 100644
--- a/spec/controllers/framework_requests/special_requirements_controller_spec.rb
+++ b/spec/controllers/framework_requests/special_requirements_controller_spec.rb
@@ -1,36 +1,117 @@
describe FrameworkRequests::SpecialRequirementsController, type: :controller do
- let(:framework_request) { create(:framework_request, is_energy_request:, energy_request_about:, have_energy_bill:) }
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ let(:framework_request) { create(:framework_request, category:) }
+ let(:category) { create(:request_for_help_category, flow:) }
+ let(:flow) { nil }
- it "redirects to the framework request page" do
+ it "redirects to the origin page" do
params = { framework_support_form: { special_requirements_choice: "no" } }
session = { framework_request_id: framework_request.id }
post(:create, params:, session:)
- expect(response).to redirect_to "/procurement-support/#{framework_request.id}"
+ expect(response).to redirect_to "/procurement-support/origin?#{params.to_query}"
end
describe "back url" do
- context "when the user has chosen to upload a bill" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { "energy_contract" }
- let(:have_energy_bill) { true }
-
- it "goes back to the categories page" do
- get :index, session: { framework_request_id: framework_request.id }
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/categories"
+ context "when the request is in the energy flow" do
+ context "and about electricity" do
+ let(:category) { create(:request_for_help_category, slug: "electricity", flow: :energy) }
+
+ context "and has bills" do
+ before do
+ framework_request.update!(energy_bills: create_list(:energy_bill, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the bill uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/bill_uploads"
+ end
+ end
+
+ context "and does not have bills" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/energy_alternative"
+ end
+ end
+ end
+
+ context "and about gas" do
+ let(:category) { create(:request_for_help_category, slug: "gas", flow: :energy) }
+
+ context "and has bills" do
+ before do
+ framework_request.update!(energy_bills: create_list(:energy_bill, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the bill uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/bill_uploads"
+ end
+ end
+
+ context "and does not have bills" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the energy alternative page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/energy_alternative"
+ end
+ end
+ end
+
+ context "and about anything else" do
+ let(:category) { create(:request_for_help_category, slug: "water", flow: :energy) }
+
+ context "and has documents" do
+ before do
+ framework_request.update!(documents: create_list(:document, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the document uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/document_uploads"
+ end
+ end
+
+ context "and does not have documents" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the documents page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/documents"
+ end
+ end
+ end
+ end
+
+ context "when the request is in the services flow" do
+ let(:category) { create(:request_for_help_category, slug: "legal_services", flow: :services) }
+
+ context "and has documents" do
+ before do
+ framework_request.update!(documents: create_list(:document, 1))
+ get :index, session: { framework_request_id: framework_request.id }
+ end
+
+ it "goes back to the document uploads page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/document_uploads"
+ end
+ end
+
+ context "and does not have documents" do
+ before { get :index, session: { framework_request_id: framework_request.id } }
+
+ it "goes back to the documents page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/documents"
+ end
end
end
- context "when the user has chosen not to upload a bill" do
- let(:is_energy_request) { false }
- let(:energy_request_about) { nil }
- let(:have_energy_bill) { false }
+ context "when the request is in any other flow" do
+ let(:category) { create(:request_for_help_category, slug: "books", flow: :goods) }
+
+ before { get :index, session: { framework_request_id: framework_request.id } }
- it "goes back to procurement amount page" do
- get :index, session: { framework_request_id: framework_request.id }
- expect(controller.view_assigns["back_url"]).to eq "/procurement-support/procurement_amount"
+ it "goes back to the message page" do
+ expect(controller.view_assigns["back_url"]).to eq "/procurement-support/message"
end
end
end
diff --git a/spec/controllers/framework_requests/start_controller_spec.rb b/spec/controllers/framework_requests/start_controller_spec.rb
index 2bec5005a..d3eecbb9c 100644
--- a/spec/controllers/framework_requests/start_controller_spec.rb
+++ b/spec/controllers/framework_requests/start_controller_spec.rb
@@ -1,26 +1,17 @@
describe FrameworkRequests::StartController, type: :controller do
- it "redirects to the energy request page" do
- post :create
- expect(response).to redirect_to "/procurement-support/energy_request"
- end
-
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
-
- context "when user is a guest" do
- it "redirects to dfe sign in" do
- post :create
- expect(response).to redirect_to "/procurement-support/sign_in"
- end
+ context "when user is a guest" do
+ it "redirects to dfe sign in" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/sign_in"
end
+ end
- context "when user is signed in" do
- before { user_is_signed_in }
+ context "when user is signed in" do
+ before { user_is_signed_in }
- it "confirms the user sign in" do
- post :create
- expect(response).to redirect_to "/procurement-support/confirm_sign_in"
- end
+ it "confirms the user sign in" do
+ post :create
+ expect(response).to redirect_to "/procurement-support/confirm_sign_in"
end
end
end
diff --git a/spec/factories/document.rb b/spec/factories/document.rb
new file mode 100644
index 000000000..9ef8992bb
--- /dev/null
+++ b/spec/factories/document.rb
@@ -0,0 +1,17 @@
+FactoryBot.define do
+ factory :document do
+ submission_status { :pending }
+ filename { "MyString" }
+ filesize { 1 }
+
+ association :framework_request, factory: :framework_request
+
+ trait :pending do
+ submission_status { :pending }
+ end
+
+ trait :submitted do
+ submission_status { :submitted }
+ end
+ end
+end
diff --git a/spec/factories/framework_requests.rb b/spec/factories/framework_requests.rb
index 9c7968ec2..0139200ac 100644
--- a/spec/factories/framework_requests.rb
+++ b/spec/factories/framework_requests.rb
@@ -16,6 +16,7 @@
energy_alternative {}
category {}
category_other {}
+ origin { :recommendation }
trait :energy_request do
is_energy_request { true }
diff --git a/spec/features/specify/auth/supported_user_spec.rb b/spec/features/specify/auth/supported_user_spec.rb
index 464603c76..78296bf70 100644
--- a/spec/features/specify/auth/supported_user_spec.rb
+++ b/spec/features/specify/auth/supported_user_spec.rb
@@ -86,8 +86,6 @@
before do
visit "/procurement-support"
click_on "Start now"
- choose "No"
- click_continue
choose "Yes, use my DfE Sign-in"
click_continue
end
diff --git a/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb b/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb
index 45910538c..cce664134 100644
--- a/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb
+++ b/spec/features/specify/framework_requests/create_framework_request_dsi_spec.rb
@@ -21,7 +21,7 @@
before do
create(:support_organisation, urn: "100253", name: "Specialist School for Testing")
- create(:request_for_help_category, title: "A category", slug: "a")
+ create(:request_for_help_category, title: "A category", slug: "a", flow: :goods)
user_is_signed_in(user:)
visit "/procurement-support/confirm_sign_in"
click_on "Yes, continue"
@@ -29,13 +29,16 @@
describe "CYA page" do
before do
- fill_in "framework_support_form[message_body]", with: "I have a problem"
- click_continue
choose "A category"
click_continue
+ fill_in "Approximately how much will the school be spending on this procurement in total?", with: "10.99"
+ click_continue
+ fill_in "framework_support_form[message_body]", with: "I have a problem"
click_continue
choose "No"
click_continue
+ choose "Recommendation"
+ click_continue
end
it "shows the inferred organisation" do
diff --git a/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb b/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb
index ab7683668..4fbda6b87 100644
--- a/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb
+++ b/spec/features/specify/framework_requests/create_framework_request_guest_spec.rb
@@ -56,7 +56,7 @@ def complete_procurement_amount_step
let(:actions) { all("dd.govuk-summary-list__actions") }
before do
- create(:request_for_help_category, title: "A category", slug: "a")
+ create(:request_for_help_category, title: "A category", slug: "a", flow: :goods)
visit "/procurement-support/sign_in"
choose "No, continue without a DfE Sign-in account"
@@ -217,13 +217,26 @@ def complete_procurement_amount_step
fill_in "framework_support_form[email]", with: "test@sky.learnmat.uk"
click_continue
- expect(page).to have_text "How can we help?"
+ expect(page).to have_text "What type of goods or service do you need?"
click_link "Back"
fill_in "framework_support_form[email]", with: "test@sch.uk"
click_continue
- expect(page).to have_text "How can we help?"
+ expect(page).to have_text "What type of goods or service do you need?"
+ end
+ end
+
+ describe "the categories page" do
+ before do
+ autocomplete_school_step
+ confirm_choice_step
+ complete_name_step
+ complete_email_step
+ end
+
+ it "has the correct attributes" do
+ expect(page).to have_title "What type of goods or service do you need?"
end
end
@@ -233,6 +246,8 @@ def complete_procurement_amount_step
confirm_choice_step
complete_name_step
complete_email_step
+ complete_category_step
+ complete_procurement_amount_step
end
it "has the correct attributes" do
@@ -251,7 +266,6 @@ def complete_procurement_amount_step
confirm_choice_step
complete_name_step
complete_email_step
- complete_help_message_step
complete_category_step
end
@@ -272,9 +286,9 @@ def complete_procurement_amount_step
confirm_choice_step
complete_name_step
complete_email_step
- complete_help_message_step
complete_category_step
complete_procurement_amount_step
+ complete_help_message_step
end
it "has the correct attributes" do
diff --git a/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb b/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb
index c53c9c0d8..47e13ffe4 100644
--- a/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb
+++ b/spec/features/specify/framework_requests/edit_framework_request_dsi_spec.rb
@@ -1,7 +1,8 @@
RSpec.feature "Editing a 'Find a Framework' request as a user" do
subject(:request) do
# Specialist School for Testing
- create(:framework_request, user:, org_id: "100253", group: false)
+ category = create(:request_for_help_category, title: "A category", slug: "a", flow: :goods)
+ create(:framework_request, user:, org_id: "100253", group: false, procurement_amount: "10.99", category:)
end
include_context "with schools and groups"
@@ -15,10 +16,9 @@
visit "/procurement-support/#{request.id}"
end
- it "goes back to the special requirements page" do
+ it "goes back to the origin page" do
click_on "Back"
- expect(page).to have_current_path "/procurement-support/#{request.id}/special_requirements/edit"
- expect(page).to have_text "Accessibility"
+ expect(page).to have_current_path "/procurement-support/#{request.id}/origin/edit"
end
it "has submission information" do
@@ -44,9 +44,25 @@
expect(values[3]).to have_text "Single"
expect(actions[3]).not_to have_link "Change"
- expect(keys[4]).to have_text "Description of request"
- expect(values[4]).to have_text "please help!"
+ expect(keys[4]).to have_text "Type of goods or service"
+ expect(values[4]).to have_text "A category"
expect(actions[4]).to have_link "Change"
+
+ expect(keys[5]).to have_text "Procurement amount"
+ expect(values[5]).to have_text "£10.99"
+ expect(actions[5]).to have_link "Change"
+
+ expect(keys[6]).to have_text "Description of request"
+ expect(values[6]).to have_text "please help!"
+ expect(actions[6]).to have_link "Change"
+
+ expect(keys[7]).to have_text "Accessibility"
+ expect(values[7]).to have_text "special_requirements"
+ expect(actions[7]).to have_link "Change"
+
+ expect(keys[8]).to have_text "Origin"
+ expect(values[8]).to have_text "Recommendation"
+ expect(actions[8]).to have_link "Change"
end
it "edit message" do
@@ -60,7 +76,7 @@
expect(page).to have_current_path "/procurement-support/#{request.id}"
- expect(values[4]).to have_text "I have a problem"
+ expect(values[6]).to have_text "I have a problem"
end
context "with many supported schools and groups", js: true do
diff --git a/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb b/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb
index 1ee1d965e..c4f7cc7e1 100644
--- a/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb
+++ b/spec/features/specify/framework_requests/edit_framework_request_guest_spec.rb
@@ -7,7 +7,7 @@
include_context "with schools and groups"
let(:fm_category) { create(:request_for_help_category, title: "FM", slug: "fm") }
- let(:catering_category) { create(:request_for_help_category, title: "Catering", slug: "catering", parent: fm_category) }
+ let(:catering_category) { create(:request_for_help_category, title: "Catering", slug: "catering", parent: fm_category, flow: :goods) }
let(:ict_category) { create(:request_for_help_category, title: "ICT", slug: "ict") }
let(:keys) { all("dt.govuk-summary-list__key") }
@@ -20,10 +20,9 @@
visit "/procurement-support/#{request.id}"
end
- it "goes back to the special requirements page" do
+ it "goes back to the origin page" do
click_on "Back"
- expect(page).to have_current_path "/procurement-support/#{request.id}/special_requirements/edit"
- expect(page).to have_text "Accessibility"
+ expect(page).to have_current_path "/procurement-support/#{request.id}/origin/edit"
end
it "has submission information" do
@@ -49,13 +48,25 @@
expect(values[3]).to have_text "Single"
expect(actions[3]).to have_link "Change"
- expect(keys[4]).to have_text "Description of request"
- expect(values[4]).to have_text "please help!"
+ expect(keys[4]).to have_text "Type of goods or service"
+ expect(values[4]).to have_text "Catering"
expect(actions[4]).to have_link "Change"
- expect(keys[5]).to have_text "Type of goods or service"
- expect(values[5]).to have_text "Catering"
+ expect(keys[5]).to have_text "Procurement amount"
+ expect(values[5]).to have_text "£10.50"
expect(actions[5]).to have_link "Change"
+
+ expect(keys[6]).to have_text "Description of request"
+ expect(values[6]).to have_text "please help!"
+ expect(actions[6]).to have_link "Change"
+
+ expect(keys[7]).to have_text "Accessibility"
+ expect(values[7]).to have_text "special_requirements"
+ expect(actions[7]).to have_link "Change"
+
+ expect(keys[8]).to have_text "Origin"
+ expect(values[8]).to have_text "Recommendation"
+ expect(actions[8]).to have_link "Change"
end
it "edit name" do
@@ -101,7 +112,7 @@
click_continue
expect(page).to have_current_path "/procurement-support/#{request.id}"
- expect(values[4]).to have_text "I have a problem"
+ expect(values[6]).to have_text "I have a problem"
end
describe "change organisation type and reselect", js: true do
diff --git a/spec/features/specify/framework_requests/start_page_spec.rb b/spec/features/specify/framework_requests/start_page_spec.rb
index a0f8e612b..becd9612a 100644
--- a/spec/features/specify/framework_requests/start_page_spec.rb
+++ b/spec/features/specify/framework_requests/start_page_spec.rb
@@ -17,8 +17,6 @@
visit "/procurement-support"
click_on "Start now"
- choose "No"
- click_continue
choose "Yes, use my DfE Sign-in"
click_continue
end
diff --git a/spec/forms/framework_requests/base_form_spec.rb b/spec/forms/framework_requests/base_form_spec.rb
index b70a97635..c2ed9321d 100644
--- a/spec/forms/framework_requests/base_form_spec.rb
+++ b/spec/forms/framework_requests/base_form_spec.rb
@@ -3,8 +3,6 @@
let(:data) { {} }
- it { is_expected.to delegate_method(:allow_bill_upload?).to(:framework_request) }
-
describe "#dsi?" do
let(:data) { { dsi: "true" } }
diff --git a/spec/forms/framework_requests/procurement_amount_form_spec.rb b/spec/forms/framework_requests/procurement_amount_form_spec.rb
index 5c541d291..765838241 100644
--- a/spec/forms/framework_requests/procurement_amount_form_spec.rb
+++ b/spec/forms/framework_requests/procurement_amount_form_spec.rb
@@ -22,14 +22,14 @@
subject(:form) { described_class.new(procurement_amount: "abc") }
before do
- allow(validator).to receive(:invalid_number?).and_return(true)
+ # allow(validator).to receive(:invalid_number?).and_return(true)
allow(validator).to receive(:too_large?).and_return(false)
end
it "returns the right error message" do
expect(form).not_to be_valid
expect(form.errors.messages[:procurement_amount]).to eq ["Enter a valid number"]
- expect(validator).to have_received(:invalid_number?).once
+ # expect(validator).to have_received(:invalid_number?).once
end
end
@@ -37,7 +37,7 @@
subject(:form) { described_class.new(procurement_amount: "10000000") }
before do
- allow(validator).to receive(:invalid_number?).and_return(false)
+ # allow(validator).to receive(:invalid_number?).and_return(false)
allow(validator).to receive(:too_large?).and_return(true)
end
diff --git a/spec/models/specify/framework_request_spec.rb b/spec/models/specify/framework_request_spec.rb
index b784dfd19..e1205ce7f 100644
--- a/spec/models/specify/framework_request_spec.rb
+++ b/spec/models/specify/framework_request_spec.rb
@@ -1,5 +1,5 @@
RSpec.describe FrameworkRequest, type: :model do
- subject(:framework_request) { build(:framework_request, group:, org_id:, is_energy_request:, energy_request_about:, have_energy_bill:, energy_alternative:, school_urns:) }
+ subject(:framework_request) { create(:framework_request, group:, org_id:, is_energy_request:, energy_request_about:, have_energy_bill:, energy_alternative:, school_urns:, category:, contract_length:, contract_start_date_known:, contract_start_date:, same_supplier_used:, document_type_other:) }
let(:is_energy_request) { false }
let(:energy_request_about) { nil }
@@ -8,70 +8,16 @@
let(:school_urns) { [] }
let(:group) { false }
let(:org_id) { nil }
+ let(:category) { nil }
+ let(:contract_length) { nil }
+ let(:contract_start_date_known) { nil }
+ let(:contract_start_date) { nil }
+ let(:same_supplier_used) { nil }
+ let(:document_type_other) { nil }
it { is_expected.to belong_to(:user).optional }
it { is_expected.to belong_to(:category).class_name("RequestForHelpCategory").optional }
- describe "#allow_bill_upload?" do
- context "when feature :energy_bill_flow is not enabled" do
- before { Flipper.disable(:energy_bill_flow) }
-
- it "returns false" do
- framework_request = described_class.new
- expect(framework_request.allow_bill_upload?).to be(false)
- end
- end
-
- context "when it's an energy request about a contract and they have a bill to upload" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :energy_contract }
- let(:have_energy_bill) { true }
-
- it "returns true" do
- expect(framework_request.allow_bill_upload?).to eq true
- end
- end
-
- context "when it's an energy request about a contract and they have a bill in a different format" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :energy_contract }
- let(:have_energy_bill) { false }
- let(:energy_alternative) { :different_format }
-
- it "returns true" do
- expect(framework_request.allow_bill_upload?).to eq true
- end
- end
-
- context "when it's not an energy request" do
- let(:is_energy_request) { false }
-
- it "returns false" do
- expect(framework_request.allow_bill_upload?).to eq false
- end
- end
-
- context "when it's an energy request not about a contract" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :not_energy_contract }
-
- it "returns false" do
- expect(framework_request.allow_bill_upload?).to eq false
- end
- end
-
- context "when it's an energy request about a contract but they don't have a bill in a different format" do
- let(:is_energy_request) { true }
- let(:energy_request_about) { :energy_contract }
- let(:have_energy_bill) { false }
- let(:energy_alternative) { :no_bill }
-
- it "returns false" do
- expect(framework_request.allow_bill_upload?).to eq false
- end
- end
- end
-
describe "#has_bills?" do
context "when there are associated energy bills" do
before { create(:energy_bill, framework_request:) }
@@ -118,4 +64,149 @@
expect(framework_request.school_urns).to match_array(%w[456])
end
end
+
+ describe "changes to the request category" do
+ context "when changed to the 'Goods' flow" do
+ let(:category) { create(:request_for_help_category, flow: :services) }
+ let(:contract_length) { :three_years }
+ let(:contract_start_date_known) { true }
+ let(:contract_start_date) { Date.parse("2023-09-20") }
+ let(:same_supplier_used) { :yes }
+ let(:document_types) { %w[other quotes] }
+ let(:document_type_other) { "other" }
+ let(:update) { { category: create(:request_for_help_category, flow: :goods) } }
+
+ before do
+ framework_request.update!(document_types:)
+ create(:energy_bill, framework_request:)
+ create(:document, framework_request:)
+ end
+
+ it "clears the contract length" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_length).from(contract_length.to_s).to(nil)
+ end
+
+ it "clears the contract start date known" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date_known).from(contract_start_date_known).to(nil)
+ end
+
+ it "clears the contract start date" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date).from(contract_start_date).to(nil)
+ end
+
+ it "clears the 'same supplier used' value" do
+ expect { framework_request.update!(update) }.to change(framework_request, :same_supplier_used).from(same_supplier_used.to_s).to(nil)
+ end
+
+ it "clears the document types" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_types).from(document_types).to([])
+ end
+
+ it "clears the document type other" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_type_other).from(document_type_other).to(nil)
+ end
+
+ it "removes all bills" do
+ expect { framework_request.update!(update) }.to change { framework_request.reload.energy_bills.count }.from(1).to(0)
+ end
+
+ it "removes all documents" do
+ expect { framework_request.update!(update) }.to change { framework_request.reload.documents.count }.from(1).to(0)
+ end
+ end
+
+ context "when changed to the 'Not fully supported' flow" do
+ let(:category) { create(:request_for_help_category, flow: nil) }
+ let(:contract_length) { :two_years }
+ let(:contract_start_date_known) { true }
+ let(:contract_start_date) { Date.parse("2025-02-10") }
+ let(:same_supplier_used) { :not_sure }
+ let(:document_types) { %w[other quotes] }
+ let(:document_type_other) { "other" }
+ let(:update) { { category: create(:request_for_help_category, flow: :not_fully_supported) } }
+
+ before do
+ framework_request.update!(document_types:)
+ create_list(:energy_bill, 2, framework_request:)
+ create(:document, framework_request:)
+ end
+
+ it "clears the contract length" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_length).from(contract_length.to_s).to(nil)
+ end
+
+ it "clears the contract start date known" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date_known).from(contract_start_date_known).to(nil)
+ end
+
+ it "clears the contract start date" do
+ expect { framework_request.update!(update) }.to change(framework_request, :contract_start_date).from(contract_start_date).to(nil)
+ end
+
+ it "clears the 'same supplier used' value" do
+ expect { framework_request.update!(update) }.to change(framework_request, :same_supplier_used).from(same_supplier_used.to_s).to(nil)
+ end
+
+ it "clears the document types" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_types).from(document_types).to([])
+ end
+
+ it "clears the document type other" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_type_other).from(document_type_other).to(nil)
+ end
+
+ it "removes all bills" do
+ expect { framework_request.update!(update) }.to change { framework_request.energy_bills.count }.from(2).to(0)
+ end
+
+ it "removes all documents" do
+ expect { framework_request.update!(update) }.to change { framework_request.reload.documents.count }.from(1).to(0)
+ end
+ end
+
+ context "when changed to the 'Services' flow" do
+ let(:category) { create(:request_for_help_category, flow: :energy) }
+ let(:have_energy_bill) { true }
+ let(:energy_alternative) { :different_format }
+ let(:update) { { category: create(:request_for_help_category, flow: :services) } }
+
+ before { create_list(:energy_bill, 2, framework_request:) }
+
+ it "clears the have energy bill value" do
+ expect { framework_request.update!(update) }.to change(framework_request, :have_energy_bill).from(have_energy_bill).to(nil)
+ end
+
+ it "clears the energy alternative" do
+ expect { framework_request.update!(update) }.to change(framework_request, :energy_alternative).from(energy_alternative.to_s).to(nil)
+ end
+
+ it "removes all bills" do
+ expect { framework_request.update!(update) }.to change { framework_request.energy_bills.count }.from(2).to(0)
+ end
+ end
+
+ context "when changed to the 'Energy' flow" do
+ let(:category) { create(:request_for_help_category, flow: :services) }
+ let(:document_types) { %w[other quotes] }
+ let(:document_type_other) { "other" }
+ let(:update) { { category: create(:request_for_help_category, flow: :energy) } }
+
+ before do
+ framework_request.update!(document_types:)
+ create_list(:document, 2, framework_request:)
+ end
+
+ it "clears the document types" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_types).from(document_types).to([])
+ end
+
+ it "clears the document type other" do
+ expect { framework_request.update!(update) }.to change(framework_request, :document_type_other).from(document_type_other).to(nil)
+ end
+
+ it "removes all documents" do
+ expect { framework_request.update!(update) }.to change { framework_request.documents.count }.from(2).to(0)
+ end
+ end
+ end
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index a4dc10dd4..26f9cc6ca 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -84,7 +84,6 @@
config.before do
# Configure feature flags for test here
- Flipper.enable(:energy_bill_flow)
Flipper.enable(:email_templates)
Flipper.enable(:cms_triage_view)
Flipper.enable(:cms_panel_view)
diff --git a/spec/services/request_for_help/seed_categories_spec.rb b/spec/services/request_for_help/seed_categories_spec.rb
index 9cac9237f..503dd1f3a 100644
--- a/spec/services/request_for_help/seed_categories_spec.rb
+++ b/spec/services/request_for_help/seed_categories_spec.rb
@@ -36,4 +36,15 @@
expect(passenger_transport.support_category).to eq(support_category)
end
end
+
+ context "when a category is archived" do
+ before { service.call }
+
+ it "persists it as archived with an archive date" do
+ ict_funding = RequestForHelpCategory.find_by(title: "ICT funding")
+
+ expect(ict_funding.archived).to eq(true)
+ expect(ict_funding.archived_at).to be_within(1.second).of(Time.zone.now)
+ end
+ end
end
diff --git a/spec/services/specify/submit_framework_request_spec.rb b/spec/services/specify/submit_framework_request_spec.rb
index ba04733a9..0f7706638 100644
--- a/spec/services/specify/submit_framework_request_spec.rb
+++ b/spec/services/specify/submit_framework_request_spec.rb
@@ -8,7 +8,8 @@
let(:email_confirmation_parameters) { anything }
let(:support_category) { create(:support_category, title: "Other (Energy)", slug: "other-energy") }
let(:parent_rfh_category) { create(:request_for_help_category, title: "Energy and utilities", slug: "energy-and-utilities") }
- let(:rfh_category) { create(:request_for_help_category, title: "Other", slug: "other", support_category:, parent: parent_rfh_category) }
+ let(:rfh_category) { create(:request_for_help_category, title: "Other", slug: "other", support_category:, parent: parent_rfh_category, flow:) }
+ let(:flow) { :services }
let(:category_other) { "other energy requirements" }
before do
@@ -56,7 +57,7 @@
end
context "when it's an energy request" do
- let(:energy_alternative) { :email_later }
+ let(:flow) { :energy }
it "sends out the confirmation email for energy requests" do
allow(Emails::ConfirmationEnergy).to receive(:new).with(email_confirmation_parameters).and_return(email_confirmation)
@@ -92,5 +93,31 @@
expect(Support::CaseAttachment.find_by(attachable: bill_2).case).to eq(Support::Case.last)
end
end
+
+ context "when documents have been uploaded" do
+ let!(:doc_1) { create(:document, :pending, framework_request: request) }
+ let!(:doc_2) { create(:document, :pending, framework_request: request) }
+
+ it "sets their status to submitted" do
+ described_class.new(request:, referrer:).call
+
+ expect(doc_1.reload).to be_submitted
+ expect(doc_2.reload).to be_submitted
+ end
+
+ it "connects them with the newly created case" do
+ described_class.new(request:, referrer:).call
+
+ expect(doc_1.reload.support_case).to eq(Support::Case.last)
+ expect(doc_2.reload.support_case).to eq(Support::Case.last)
+ end
+
+ it "creates CaseAttachment records for each bill" do
+ described_class.new(request:, referrer:).call
+
+ expect(Support::CaseAttachment.find_by(attachable: doc_1).case).to eq(Support::Case.last)
+ expect(Support::CaseAttachment.find_by(attachable: doc_2).case).to eq(Support::Case.last)
+ end
+ end
end
end