From d2518d7c383eb564be806172add7edd04839f168 Mon Sep 17 00:00:00 2001 From: Robert Sullivan Date: Thu, 11 Apr 2024 13:43:54 +0100 Subject: [PATCH 01/12] CLDC-2481: Add ability to disable organisations (#2293) * CLDC-2481: Add ability to disable organisations. * CLDC-2481: Add ability to disable organisations * Tidy up tests * CLDC-2481: Review markups * CLDC-2481: Fix location and scheme filters * Add banners for stock owners and managing agents * Update view test --------- Co-authored-by: Kat --- .../organisation_relationships_controller.rb | 10 +- app/controllers/organisations_controller.rb | 33 ++++- app/controllers/users_controller.rb | 3 +- .../toggle_active_organisation_helper.rb | 13 ++ .../questions/managing_organisation.rb | 6 +- .../form/lettings/questions/stock_owner.rb | 4 +- .../sales/questions/managing_organisation.rb | 6 +- .../sales/questions/owning_organisation_id.rb | 4 +- app/models/location.rb | 22 +++- app/models/organisation.rb | 3 + app/models/scheme.rb | 25 +++- app/models/user.rb | 17 +++ app/policies/organisation_policy.rb | 16 +++ app/views/locations/show.html.erb | 2 +- .../managing_agents.html.erb | 18 ++- .../stock_owners.html.erb | 18 ++- app/views/organisations/show.html.erb | 9 ++ .../organisations/toggle_active.html.erb | 29 +++++ app/views/schemes/show.html.erb | 2 +- app/views/users/new.html.erb | 2 +- app/views/users/show.html.erb | 4 +- config/locales/en.yml | 5 + config/routes.rb | 2 + ...d_reactivate_with_organisation_to_users.rb | 5 + ...ault_value_to_organisation_active_field.rb | 12 ++ db/schema.rb | 3 +- .../questions/managing_organisation_spec.rb | 15 ++- .../lettings/questions/stock_owner_spec.rb | 21 +-- .../questions/managing_organisation_spec.rb | 7 +- .../questions/owning_organisation_id_spec.rb | 20 +-- spec/models/location_spec.rb | 13 +- spec/models/organisation_spec.rb | 41 +++++- spec/models/scheme_spec.rb | 10 +- spec/policies/organisation_policy_spec.rb | 66 ++++++++++ ...anisation_relationships_controller_spec.rb | 60 +++++++++ .../requests/organisations_controller_spec.rb | 120 ++++++++++++++++++ spec/views/locations/show.html.erb_spec.rb | 113 +++++++++++------ .../views/organisations/show.html.erb_spec.rb | 14 ++ spec/views/schemes/show.html.erb_spec.rb | 34 ++++- 39 files changed, 699 insertions(+), 108 deletions(-) create mode 100644 app/helpers/toggle_active_organisation_helper.rb create mode 100644 app/policies/organisation_policy.rb create mode 100644 app/views/organisations/toggle_active.html.erb create mode 100644 db/migrate/20240304112411_add_reactivate_with_organisation_to_users.rb create mode 100644 db/migrate/20240305112507_add_default_value_to_organisation_active_field.rb create mode 100644 spec/policies/organisation_policy_spec.rb diff --git a/app/controllers/organisation_relationships_controller.rb b/app/controllers/organisation_relationships_controller.rb index 0ac66bd31..0e3d230ef 100644 --- a/app/controllers/organisation_relationships_controller.rb +++ b/app/controllers/organisation_relationships_controller.rb @@ -14,7 +14,7 @@ class OrganisationRelationshipsController < ApplicationController ] def stock_owners - stock_owners = organisation.stock_owners + stock_owners = organisation.stock_owners.filter_by_active unpaginated_filtered_stock_owners = filtered_collection(stock_owners, search_term) @pagy, @stock_owners = pagy(unpaginated_filtered_stock_owners) @@ -23,7 +23,7 @@ class OrganisationRelationshipsController < ApplicationController end def managing_agents - managing_agents = organisation.managing_agents + managing_agents = organisation.managing_agents.filter_by_active unpaginated_filtered_managing_agents = filtered_collection(managing_agents, search_term) @pagy, @managing_agents = pagy(unpaginated_filtered_managing_agents) @@ -48,7 +48,7 @@ class OrganisationRelationshipsController < ApplicationController flash[:notice] = "#{@organisation_relationship.parent_organisation.name} is now one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} stock owners" redirect_to stock_owners_organisation_path else - @organisations = Organisation.where.not(id: organisation.id).pluck(:id, :name) + @organisations = Organisation.filter_by_active.where.not(id: organisation.id).pluck(:id, :name) render "organisation_relationships/add_stock_owner", status: :unprocessable_entity end end @@ -60,7 +60,7 @@ class OrganisationRelationshipsController < ApplicationController flash[:notice] = "#{@organisation_relationship.child_organisation.name} is now one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} managing agents" redirect_to managing_agents_organisation_path else - @organisations = Organisation.where.not(id: organisation.id).pluck(:id, :name) + @organisations = Organisation.filter_by_active.where.not(id: organisation.id).pluck(:id, :name) render "organisation_relationships/add_managing_agent", status: :unprocessable_entity end end @@ -110,7 +110,7 @@ private end def organisations - @organisations ||= Organisation.where.not(id: organisation.id).pluck(:id, :name) + @organisations ||= Organisation.filter_by_active.where.not(id: organisation.id).pluck(:id, :name) end def parent_organisation diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 4982c4287..e7f5c4bef 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -94,10 +94,37 @@ class OrganisationsController < ApplicationController end end + def deactivate + authorize @organisation + + render "toggle_active", locals: { action: "deactivate" } + end + + def reactivate + authorize @organisation + + render "toggle_active", locals: { action: "reactivate" } + end + def update - if current_user.data_coordinator? || current_user.support? + if (current_user.data_coordinator? && org_params[:active].nil?) || current_user.support? if @organisation.update(org_params) - flash[:notice] = I18n.t("organisation.updated") + case org_params[:active] + when "false" + @organisation.users.filter_by_active.each do |user| + user.deactivate!(reactivate_with_organisation: true) + end + flash[:notice] = I18n.t("organisation.deactivated", organisation: @organisation.name) + when "true" + users_to_reactivate = @organisation.users.where(reactivate_with_organisation: true) + users_to_reactivate.each do |user| + user.reactivate! + user.send_confirmation_instructions + end + flash[:notice] = I18n.t("organisation.reactivated", organisation: @organisation.name) + else + flash[:notice] = I18n.t("organisation.updated") + end redirect_to details_organisation_path(@organisation) end else @@ -239,7 +266,7 @@ private end def org_params - params.require(:organisation).permit(:name, :address_line1, :address_line2, :postcode, :phone, :holds_own_stock, :provider_type, :housing_registration_no) + params.require(:organisation).permit(:name, :address_line1, :address_line2, :postcode, :phone, :holds_own_stock, :provider_type, :housing_registration_no, :active) end def codes_only_export? diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6a76cb047..3fe3b1813 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -62,9 +62,10 @@ class UsersController < ApplicationController else user_name = @user.name&.possessive || @user.email.possessive if user_params[:active] == "false" - @user.update!(confirmed_at: nil, sign_in_count: 0, initial_confirmation_sent: false) + @user.deactivate! flash[:notice] = I18n.t("devise.activation.deactivated", user_name:) elsif user_params[:active] == "true" + @user.reactivate! @user.send_confirmation_instructions flash[:notice] = I18n.t("devise.activation.reactivated", user_name:) elsif user_params.key?("email") diff --git a/app/helpers/toggle_active_organisation_helper.rb b/app/helpers/toggle_active_organisation_helper.rb new file mode 100644 index 000000000..10b9b0983 --- /dev/null +++ b/app/helpers/toggle_active_organisation_helper.rb @@ -0,0 +1,13 @@ +module ToggleActiveOrganisationHelper + def toggle_organisation_form_path(action, organisation) + if action == "deactivate" + organisation_new_deactivation_path(organisation) + else + organisation_reactivate_path(organisation) + end + end + + def date_type_question(action) + action == "deactivate" ? :deactivation_date_type : :reactivation_date_type + end +end diff --git a/app/models/form/lettings/questions/managing_organisation.rb b/app/models/form/lettings/questions/managing_organisation.rb index 51eccdaac..ea85ff207 100644 --- a/app/models/form/lettings/questions/managing_organisation.rb +++ b/app/models/form/lettings/questions/managing_organisation.rb @@ -31,11 +31,11 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question end orgs = if user.support? - log.owning_organisation.managing_agents + log.owning_organisation.managing_agents.filter_by_active elsif user.organisation.absorbed_organisations.include?(log.owning_organisation) - user.organisation.managing_agents + log.owning_organisation.managing_agents + user.organisation.managing_agents.filter_by_active + log.owning_organisation.managing_agents.filter_by_active else - user.organisation.managing_agents + user.organisation.managing_agents.filter_by_active end user.organisation.absorbed_organisations.each do |absorbed_org| diff --git a/app/models/form/lettings/questions/stock_owner.rb b/app/models/form/lettings/questions/stock_owner.rb index 682c64247..6ce0e5496 100644 --- a/app/models/form/lettings/questions/stock_owner.rb +++ b/app/models/form/lettings/questions/stock_owner.rb @@ -30,7 +30,7 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question end if user.support? - Organisation.where(holds_own_stock: true).find_each do |org| + Organisation.filter_by_active.where(holds_own_stock: true).find_each do |org| if org.merge_date.present? answer_opts[org.id] = "#{org.name} (inactive as of #{org.merge_date.to_fs(:govuk_date)})" if org.merge_date >= FormHandler.instance.start_date_of_earliest_open_for_editing_collection_period elsif org.absorbed_organisations.merged_during_open_collection_period.exists? && org.available_from.present? @@ -40,7 +40,7 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question end end else - user.organisation.stock_owners.each do |stock_owner| + user.organisation.stock_owners.filter_by_active.each do |stock_owner| answer_opts[stock_owner.id] = stock_owner.name end recently_absorbed_organisations.each do |absorbed_org| diff --git a/app/models/form/sales/questions/managing_organisation.rb b/app/models/form/sales/questions/managing_organisation.rb index f98dd0100..54d7ab6e0 100644 --- a/app/models/form/sales/questions/managing_organisation.rb +++ b/app/models/form/sales/questions/managing_organisation.rb @@ -31,11 +31,11 @@ class Form::Sales::Questions::ManagingOrganisation < ::Form::Question end orgs = if user.support? - log.owning_organisation.managing_agents + log.owning_organisation.managing_agents.filter_by_active elsif user.organisation.absorbed_organisations.include?(log.owning_organisation) - user.organisation.managing_agents + log.owning_organisation.managing_agents + user.organisation.managing_agents.filter_by_active + log.owning_organisation.managing_agents.filter_by_active else - user.organisation.managing_agents + user.organisation.managing_agents.filter_by_active end.pluck(:id, :name).to_h user.organisation.absorbed_organisations.each do |absorbed_org| diff --git a/app/models/form/sales/questions/owning_organisation_id.rb b/app/models/form/sales/questions/owning_organisation_id.rb index 062fbcaaf..dc3913882 100644 --- a/app/models/form/sales/questions/owning_organisation_id.rb +++ b/app/models/form/sales/questions/owning_organisation_id.rb @@ -25,7 +25,7 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question answer_opts[user.organisation.id] = "#{user.organisation.name} (Your organisation)" end - user.organisation.stock_owners.where(holds_own_stock: true).find_each do |org| + user.organisation.stock_owners.filter_by_active.where(holds_own_stock: true).find_each do |org| answer_opts[org.id] = org.name end end @@ -44,7 +44,7 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question end if user.support? - Organisation.where(holds_own_stock: true).find_each do |org| + Organisation.filter_by_active.where(holds_own_stock: true).find_each do |org| if org.merge_date.present? answer_opts[org.id] = "#{org.name} (inactive as of #{org.merge_date.to_fs(:govuk_date)})" if org.merge_date >= FormHandler.instance.start_date_of_earliest_open_for_editing_collection_period elsif org.absorbed_organisations.merged_during_open_collection_period.exists? && org.available_from.present? diff --git a/app/models/location.rb b/app/models/location.rb index 43285bfbb..dfcbef41b 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -40,6 +40,7 @@ class Location < ApplicationRecord if scopes.any? filtered_records = filtered_records .left_outer_joins(:location_deactivation_periods) + .joins(scheme: [:owning_organisation]) .order("location_deactivation_periods.created_at DESC") .merge(scopes.reduce(&:or)) end @@ -53,27 +54,39 @@ class Location < ApplicationRecord } scope :deactivated, lambda { + deactivated_by_organisation + .or(deactivated_directly) + } + + scope :deactivated_by_organisation, lambda { + merge(Organisation.filter_by_inactive) + } + + scope :deactivated_directly, lambda { merge(LocationDeactivationPeriod.deactivations_without_reactivation) - .where("location_deactivation_periods.deactivation_date <= ?", Time.zone.now) + .where("location_deactivation_periods.deactivation_date <= ?", Time.zone.now) } scope :deactivating_soon, lambda { merge(LocationDeactivationPeriod.deactivations_without_reactivation) .where("location_deactivation_periods.deactivation_date > ?", Time.zone.now) + .where.not(id: joins(scheme: [:owning_organisation]).deactivated_by_organisation.pluck(:id)) } scope :reactivating_soon, lambda { where.not("location_deactivation_periods.reactivation_date IS NULL") .where("location_deactivation_periods.reactivation_date > ?", Time.zone.now) + .where.not(id: joins(scheme: [:owning_organisation]).deactivated_by_organisation.pluck(:id)) } scope :activating_soon, lambda { - where("startdate > ?", Time.zone.now) + where("locations.startdate > ?", Time.zone.now) } scope :active_status, lambda { where.not(id: joins(:location_deactivation_periods).reactivating_soon.pluck(:id)) - .where.not(id: joins(:location_deactivation_periods).deactivated.pluck(:id)) + .where.not(id: joins(scheme: [:owning_organisation]).deactivated_by_organisation.pluck(:id)) + .where.not(id: joins(:location_deactivation_periods).deactivated_directly.pluck(:id)) .where.not(id: incomplete.pluck(:id)) .where.not(id: joins(:location_deactivation_periods).deactivating_soon.pluck(:id)) .where.not(id: activating_soon.pluck(:id)) @@ -142,7 +155,8 @@ class Location < ApplicationRecord def status_at(date) return :deleted if discarded_at.present? return :incomplete unless confirmed - return :deactivated if open_deactivation&.deactivation_date.present? && date >= open_deactivation.deactivation_date + return :deactivated if scheme.owning_organisation.status_at(date) == :deactivated || + open_deactivation&.deactivation_date.present? && date >= open_deactivation.deactivation_date return :deactivating_soon if open_deactivation&.deactivation_date.present? && date < open_deactivation.deactivation_date return :reactivating_soon if last_deactivation_before(date)&.reactivation_date.present? && date < last_deactivation_before(date).reactivation_date return :activating_soon if startdate.present? && date < startdate diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 0a852d2fd..b5c6f36aa 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -37,6 +37,8 @@ class Organisation < ApplicationRecord scope :search_by_name, ->(name) { where("name ILIKE ?", "%#{name}%") } scope :search_by, ->(param) { search_by_name(param) } + scope :filter_by_active, -> { where(active: true) } + scope :filter_by_inactive, -> { where(active: false) } scope :merged_during_open_collection_period, -> { where("merge_date >= ?", FormHandler.instance.start_date_of_earliest_open_for_editing_collection_period) } has_paper_trail @@ -138,6 +140,7 @@ class Organisation < ApplicationRecord def status_at(date) return :merged if merge_date.present? && merge_date < date + return :deactivated unless active :active end diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 2518293a0..5b95ed98a 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -35,6 +35,7 @@ class Scheme < ApplicationRecord if scopes.any? filtered_records = filtered_records .left_outer_joins(:scheme_deactivation_periods) + .joins(:owning_organisation) .merge(scopes.reduce(&:or)) end @@ -45,35 +46,48 @@ class Scheme < ApplicationRecord where.not(confirmed: true) .or(where(confirmed: nil)) .or(where.not(id: Location.select(:scheme_id).where(confirmed: true).distinct)) + .where.not(id: joins(:owning_organisation).deactivated_by_organisation.pluck(:id)) + .where.not(id: joins(:scheme_deactivation_periods).deactivated_directly.pluck(:id)) .where.not(id: joins(:scheme_deactivation_periods).reactivating_soon.pluck(:id)) - .where.not(id: joins(:scheme_deactivation_periods).deactivated.pluck(:id)) .where.not(id: joins(:scheme_deactivation_periods).deactivating_soon.pluck(:id)) } scope :deactivated, lambda { + deactivated_by_organisation + .or(deactivated_directly) + } + + scope :deactivated_by_organisation, lambda { + merge(Organisation.filter_by_inactive) + } + + scope :deactivated_directly, lambda { merge(SchemeDeactivationPeriod.deactivations_without_reactivation) - .where("scheme_deactivation_periods.deactivation_date <= ?", Time.zone.now) + .where("scheme_deactivation_periods.deactivation_date <= ?", Time.zone.now) } scope :deactivating_soon, lambda { merge(SchemeDeactivationPeriod.deactivations_without_reactivation) .where("scheme_deactivation_periods.deactivation_date > ? AND scheme_deactivation_periods.deactivation_date < ? ", Time.zone.now, 6.months.from_now) + .where.not(id: joins(:owning_organisation).deactivated_by_organisation.pluck(:id)) } scope :reactivating_soon, lambda { where.not("scheme_deactivation_periods.reactivation_date IS NULL") .where("scheme_deactivation_periods.reactivation_date > ?", Time.zone.now) + .where.not(id: joins(:owning_organisation).deactivated_by_organisation.pluck(:id)) } scope :activating_soon, lambda { - where("startdate > ?", Time.zone.now) + where("schemes.startdate > ?", Time.zone.now) } scope :active_status, lambda { where.not(id: joins(:scheme_deactivation_periods).reactivating_soon.pluck(:id)) - .where.not(id: joins(:scheme_deactivation_periods).deactivated.pluck(:id)) .where.not(id: incomplete.pluck(:id)) .where.not(id: joins(:scheme_deactivation_periods).deactivating_soon.pluck(:id)) + .where.not(id: joins(:owning_organisation).deactivated_by_organisation.pluck(:id)) + .where.not(id: joins(:owning_organisation).joins(:scheme_deactivation_periods).deactivated_directly.pluck(:id)) .where.not(id: activating_soon.pluck(:id)) } @@ -268,7 +282,8 @@ class Scheme < ApplicationRecord def status_at(date) return :deleted if discarded_at.present? return :incomplete unless confirmed && locations.confirmed.any? - return :deactivated if open_deactivation&.deactivation_date.present? && date >= open_deactivation.deactivation_date + return :deactivated if owning_organisation.status_at(date) == :deactivated || + (open_deactivation&.deactivation_date.present? && date >= open_deactivation.deactivation_date) return :deactivating_soon if open_deactivation&.deactivation_date.present? && date < open_deactivation.deactivation_date return :reactivating_soon if last_deactivation_before(date)&.reactivation_date.present? && date < last_deactivation_before(date).reactivation_date return :activating_soon if startdate.present? && date < startdate diff --git a/app/models/user.rb b/app/models/user.rb index 6d13e8cd1..27187529a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -134,6 +134,23 @@ class User < ApplicationRecord update!(is_dpo: true) end + def deactivate!(reactivate_with_organisation: false) + update!( + active: false, + confirmed_at: nil, + sign_in_count: 0, + initial_confirmation_sent: false, + reactivate_with_organisation:, + ) + end + + def reactivate! + update!( + active: true, + reactivate_with_organisation: false, + ) + end + MFA_TEMPLATE_ID = "6bdf5ee1-8e01-4be1-b1f9-747061d8a24c".freeze RESET_PASSWORD_TEMPLATE_ID = "2c410c19-80a7-481c-a531-2bcb3264f8e6".freeze CONFIRMABLE_TEMPLATE_ID = "3fc2e3a7-0835-4b84-ab7a-ce51629eb614".freeze diff --git a/app/policies/organisation_policy.rb b/app/policies/organisation_policy.rb new file mode 100644 index 000000000..3e0c9a946 --- /dev/null +++ b/app/policies/organisation_policy.rb @@ -0,0 +1,16 @@ +class OrganisationPolicy + attr_reader :user, :organisation + + def initialize(user, organisation) + @user = user + @organisation = organisation + end + + def deactivate? + user.support? && organisation.status == :active + end + + def reactivate? + user.support? && organisation.status == :deactivated + end +end diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index 86de3a362..8ac8f6b23 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -47,7 +47,7 @@ -<% if LocationPolicy.new(current_user, @location).deactivate? %> +<% if @location.scheme.owning_organisation.active? && LocationPolicy.new(current_user, @location).deactivate? %> <%= toggle_location_link(@location) %> <% end %> diff --git a/app/views/organisation_relationships/managing_agents.html.erb b/app/views/organisation_relationships/managing_agents.html.erb index a01a354d2..726533e53 100644 --- a/app/views/organisation_relationships/managing_agents.html.erb +++ b/app/views/organisation_relationships/managing_agents.html.erb @@ -5,19 +5,35 @@ <%= render SubNavigationComponent.new( items: secondary_items(request.path, @organisation.id), ) %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new managing agents. + <% end %> + <% end %>

Managing Agents

A managing agent can submit logs for this organisation.

<% if @total_count == 0 %>

This organisation does not currently have any managing agents.

<% end %> <% else %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new managing agents. + <% end %> + <% end %> <%= render partial: "organisations/headings", locals: { main: "Your managing agents", sub: current_user.organisation.name } %>

A managing agent can submit logs for this organisation.

<% if @total_count == 0 %>

This organisation does not currently have any managing agents.

<% end %> <% end %> -<% if current_user.support? || current_user.data_coordinator? %> +<% if (current_user.support? || current_user.data_coordinator?) && @organisation.active? %> <%= govuk_button_link_to "Add a managing agent", managing_agents_add_organisation_path, html: { method: :get } %> <% end %> <% if @total_count != 0 %> diff --git a/app/views/organisation_relationships/stock_owners.html.erb b/app/views/organisation_relationships/stock_owners.html.erb index 4be22f7b9..41b7af06d 100644 --- a/app/views/organisation_relationships/stock_owners.html.erb +++ b/app/views/organisation_relationships/stock_owners.html.erb @@ -2,19 +2,35 @@ <% if current_user.support? %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new stock owners. + <% end %> + <% end %>

Stock Owners

This organisation can submit logs for its stock owners.

<% if @total_count == 0 %>

This organisation does not currently have any stock owners.

<% end %> <% else %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new stock owners. + <% end %> + <% end %> <%= render partial: "organisations/headings", locals: { main: "Your stock owners", sub: current_user.organisation.name } %>

Your organisation can submit logs for its stock owners.

<% if @total_count == 0 %>

You do not currently have any stock owners.

<% end %> <% end %> -<% if current_user.support? || current_user.data_coordinator? %> +<% if (current_user.support? || current_user.data_coordinator?) && @organisation.active? %> <%= govuk_button_link_to "Add a stock owner", stock_owners_add_organisation_path, html: { method: :get } %> <% end %> <% if @total_count != 0 %> diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb index e2e07e28c..2dced52bd 100644 --- a/app/views/organisations/show.html.erb +++ b/app/views/organisations/show.html.erb @@ -40,3 +40,12 @@ <%= render partial: "organisations/merged_organisation_details" %> + +<% if OrganisationPolicy.new(current_user, @organisation).deactivate? %> + <%= govuk_button_link_to "Deactivate this organisation", deactivate_organisation_path(@organisation), warning: true %> +<% end %> +<% if OrganisationPolicy.new(current_user, @organisation).reactivate? %> + + <%= govuk_button_link_to "Reactivate this organisation", reactivate_organisation_path(@organisation) %> + +<% end %> diff --git a/app/views/organisations/toggle_active.html.erb b/app/views/organisations/toggle_active.html.erb new file mode 100644 index 000000000..42f1e8403 --- /dev/null +++ b/app/views/organisations/toggle_active.html.erb @@ -0,0 +1,29 @@ +<% title = "#{action.humanize} #{@organisation.name}" %> +<% content_for :title, title %> + +<% content_for :before_content do %> + <%= govuk_back_link( + href: organisation_path(@organisation), + ) %> +<% end %> + +<%= form_for(@organisation, as: :organisation, html: { method: :patch }) do |f| %> +
+
+

+ <%= @organisation.name %> + Are you sure you want to <%= action %> this organisation? +

+ <%= govuk_warning_text text: I18n.t("warnings.organisation.#{action}") %> + + <% active_value = action != "deactivate" %> + <%= f.hidden_field :active, value: active_value %> + + <%= f.govuk_submit "#{action.capitalize} this organisation" %> + +

+ <%= govuk_link_to("Cancel", organisation_path(@organisation)) %> +

+
+
+<% end %> diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index 31ca1cba9..1aefadef5 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -49,7 +49,7 @@ -<% if SchemePolicy.new(current_user, @scheme).deactivate? %> +<% if @scheme.owning_organisation.active? && SchemePolicy.new(current_user, @scheme).deactivate? %> <%= toggle_scheme_link(@scheme) %> <% end %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 0465f67bb..925f1ada7 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -31,7 +31,7 @@ <% if current_user.support? %> <% null_option = [OpenStruct.new(id: "", name: "Select an option")] %> - <% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %> + <% organisations = Organisation.filter_by_active.map { |org| OpenStruct.new(id: org.id, name: org.name) } %> <% answer_options = null_option + organisations %> <% if @organisation_id %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index a93532e7b..c62fccf2c 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -127,8 +127,8 @@ end %> <% end %> -
- <% if current_user.can_toggle_active?(@user) %> + <% if @user.organisation.active? && current_user.can_toggle_active?(@user) %> +
<% if @user.active? %> <%= govuk_button_link_to "Deactivate user", deactivate_user_path(@user), warning: true %> <% if current_user.support? && @user.last_sign_in_at.nil? %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 079967095..68bea0c8f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -34,6 +34,8 @@ en: feedback_form: "https://forms.office.com/Pages/ResponsePage.aspx?id=EGg0v32c3kOociSi7zmVqC4YDsCJ3llAvEZelBFBLUBURFVUTzFDTUJPQlM4M0laTE5DTlNFSjJBQi4u" organisation: updated: "Organisation details updated" + reactivated: "%{organisation} has been reactivated." + deactivated: "%{organisation} has been deactivated." user: create_password: "Create a password to finish setting up your account" reset_password: "Reset your password" @@ -860,6 +862,9 @@ Make sure these answers are correct." offered: "Times previously offered since becoming available" warnings: + organisation: + deactivate: "All schemes and users at this organisation will be deactivated. All the organisation's relationships will be removed. It will no longer be possible to create logs for this organisation." + reactivate: "All schemes, users, and relationships that were active when this organisation was deactivated will be reactivated." location: deactivate: existing_logs: "It will not be possible to add logs with this location if their tenancy start date is on or after the date you enter. Any existing logs may be affected." diff --git a/config/routes.rb b/config/routes.rb index 79dcf0a04..b6b362569 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -179,6 +179,8 @@ Rails.application.routes.draw do post "managing-agents", to: "organisation_relationships#create_managing_agent" delete "managing-agents", to: "organisation_relationships#delete_managing_agent" get "merge-request", to: "organisations#merge_request" + get "deactivate", to: "organisations#deactivate" + get "reactivate", to: "organisations#reactivate" end end diff --git a/db/migrate/20240304112411_add_reactivate_with_organisation_to_users.rb b/db/migrate/20240304112411_add_reactivate_with_organisation_to_users.rb new file mode 100644 index 000000000..e66b3108a --- /dev/null +++ b/db/migrate/20240304112411_add_reactivate_with_organisation_to_users.rb @@ -0,0 +1,5 @@ +class AddReactivateWithOrganisationToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :reactivate_with_organisation, :boolean + end +end diff --git a/db/migrate/20240305112507_add_default_value_to_organisation_active_field.rb b/db/migrate/20240305112507_add_default_value_to_organisation_active_field.rb new file mode 100644 index 000000000..8984b80b5 --- /dev/null +++ b/db/migrate/20240305112507_add_default_value_to_organisation_active_field.rb @@ -0,0 +1,12 @@ +class AddDefaultValueToOrganisationActiveField < ActiveRecord::Migration[7.0] + def up + change_column :organisations, :active, :boolean, default: true + + execute "UPDATE organisations + SET active = true;" + end + + def down + change_column :organisations, :active, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index cca8b7f5c..bb13372cd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -453,7 +453,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_19_122706) do t.string "managing_agents_label" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "active" + t.boolean "active", default: true t.integer "old_association_type" t.string "software_supplier_id" t.string "housing_management_system" @@ -764,6 +764,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_19_122706) do t.string "unconfirmed_email" t.boolean "initial_confirmation_sent" t.datetime "discarded_at" + t.boolean "reactivate_with_organisation" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["encrypted_otp_secret_key"], name: "index_users_on_encrypted_otp_secret_key", unique: true diff --git a/spec/models/form/lettings/questions/managing_organisation_spec.rb b/spec/models/form/lettings/questions/managing_organisation_spec.rb index 86d58d4d3..45c089698 100644 --- a/spec/models/form/lettings/questions/managing_organisation_spec.rb +++ b/spec/models/form/lettings/questions/managing_organisation_spec.rb @@ -57,6 +57,7 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do let(:managing_org1) { create(:organisation, name: "Managing org 1") } let(:managing_org2) { create(:organisation, name: "Managing org 2") } let(:managing_org3) { create(:organisation, name: "Managing org 3") } + let(:inactive_managing_org) { create(:organisation, name: "Inactive managing org", active: false) } let(:log) { create(:lettings_log, managing_organisation: managing_org1) } let!(:org_rel1) do @@ -76,7 +77,9 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do } end - it "shows current managing agent at top, followed by user's org (with hint), followed by the managing agents of the user's org" do + it "shows current managing agent at top, followed by user's org (with hint), followed by the active managing agents of the user's org" do + create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: inactive_managing_org) + expect(question.displayed_answer_options(log, user)).to eq(options) end end @@ -100,6 +103,10 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do create(:organisation_relationship, parent_organisation: log_owning_org, child_organisation: managing_org3) end + before do + create(:organisation, name: "Inactive managing org", active: false) + end + context "when org owns stock" do let(:options) do { @@ -111,7 +118,7 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do } end - it "shows current managing agent at top, followed by the current owning organisation (with hint), followed by the managing agents of the current owning organisation" do + it "shows current managing agent at top, followed by the current owning organisation (with hint), followed by the active managing agents of the current owning organisation" do log_owning_org.update!(holds_own_stock: true) expect(question.displayed_answer_options(log, user)).to eq(options) end @@ -133,7 +140,7 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do org_rel2.child_organisation.update!(merge_date: Time.zone.local(2023, 8, 2), absorbing_organisation_id: log_owning_org.id) end - it "shows current managing agent at top, followed by the current owning organisation (with hint), followed by the managing agents of the current owning organisation" do + it "shows current managing agent at top, followed by the current owning organisation (with hint), followed by the active managing agents of the current owning organisation" do log_owning_org.update!(holds_own_stock: true) expect(question.displayed_answer_options(log, user)).to eq(options) end @@ -149,7 +156,7 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do } end - it "shows current managing agent at top, followed by the managing agents of the current owning organisation" do + it "shows current managing agent at top, followed by the active managing agents of the current owning organisation" do log_owning_org.update!(holds_own_stock: false) expect(question.displayed_answer_options(log, user)).to eq(options) end diff --git a/spec/models/form/lettings/questions/stock_owner_spec.rb b/spec/models/form/lettings/questions/stock_owner_spec.rb index af899e4ab..cb600b986 100644 --- a/spec/models/form/lettings/questions/stock_owner_spec.rb +++ b/spec/models/form/lettings/questions/stock_owner_spec.rb @@ -46,6 +46,7 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do let(:owning_org_1) { create(:organisation, name: "Owning org 1") } let(:owning_org_2) { create(:organisation, name: "Owning org 2") } + let(:inactive_owning_org) { create(:organisation, name: "Inactive owning org", active: false) } let!(:org_rel) do create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: owning_org_2) end @@ -61,7 +62,8 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do } end - it "shows current stock owner at top, followed by user's org (with hint), followed by the stock owners of the user's org" do + it "shows current stock owner at top, followed by user's org (with hint), followed by the active stock owners of the user's org" do + create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: inactive_owning_org) user.organisation.update!(holds_own_stock: true) expect(question.displayed_answer_options(log, user)).to eq(options) end @@ -93,7 +95,8 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do } end - it "shows current stock owner at top, followed by the stock owners of the user's org" do + it "shows current stock owner at top, followed by the active stock active owners of the user's org" do + create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: inactive_owning_org) user.organisation.update!(holds_own_stock: false) expect(question.displayed_answer_options(log, user)).to eq(options) end @@ -203,21 +206,21 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do end context "when user is support" do - let(:user) { create(:user, :support) } + let!(:user) { create(:user, :support) } + let!(:log) { create(:lettings_log) } - let(:log) { create(:lettings_log) } + it "shows active orgs where organisation holds own stock" do + non_stock_organisation = create(:organisation, name: "Non-stockholding org", holds_own_stock: false) + inactive_organisation = create(:organisation, name: "Inactive org", active: false) - let(:non_stock_organisation) { create(:organisation, holds_own_stock: false) } - let(:expected_opts) do - Organisation.where(holds_own_stock: true).each_with_object(options) do |organisation, hsh| + expected_opts = Organisation.filter_by_active.where(holds_own_stock: true).each_with_object(options) do |organisation, hsh| hsh[organisation.id] = organisation.name hsh end - end - it "shows orgs where organisation holds own stock" do expect(question.displayed_answer_options(log, user)).to eq(expected_opts) expect(question.displayed_answer_options(log, user)).not_to include(non_stock_organisation.id) + expect(question.displayed_answer_options(log, user)).not_to include(inactive_organisation.id) end context "and org has recently absorbed other orgs and does not have available from date" do diff --git a/spec/models/form/sales/questions/managing_organisation_spec.rb b/spec/models/form/sales/questions/managing_organisation_spec.rb index 716b1b917..30574e049 100644 --- a/spec/models/form/sales/questions/managing_organisation_spec.rb +++ b/spec/models/form/sales/questions/managing_organisation_spec.rb @@ -57,6 +57,7 @@ RSpec.describe Form::Sales::Questions::ManagingOrganisation, type: :model do let(:managing_org1) { create(:organisation, name: "Managing org 1") } let(:managing_org2) { create(:organisation, name: "Managing org 2") } let(:managing_org3) { create(:organisation, name: "Managing org 3") } + let(:inactive_org) { create(:organisation, name: "Inactive org", active: false) } let(:log) do create(:lettings_log, owning_organisation: log_owning_org, managing_organisation: managing_org1, @@ -80,7 +81,8 @@ RSpec.describe Form::Sales::Questions::ManagingOrganisation, type: :model do } end - it "shows current managing agent at top, followed by the current owning organisation (with hint), followed by the managing agents of the current owning organisation" do + it "shows current managing agent at top, followed by the current owning organisation (with hint), followed by the active managing agents of the current owning organisation" do + create(:organisation_relationship, parent_organisation: log_owning_org, child_organisation: inactive_org) log_owning_org.update!(holds_own_stock: true) expect(question.displayed_answer_options(log, user)).to eq(options) end @@ -96,7 +98,8 @@ RSpec.describe Form::Sales::Questions::ManagingOrganisation, type: :model do } end - it "shows current managing agent at top, followed by the managing agents of the current owning organisation" do + it "shows current managing agent at top, followed by the active managing agents of the current owning organisation" do + create(:organisation_relationship, parent_organisation: log_owning_org, child_organisation: inactive_org) log_owning_org.update!(holds_own_stock: false) expect(question.displayed_answer_options(log, user)).to eq(options) end diff --git a/spec/models/form/sales/questions/owning_organisation_id_spec.rb b/spec/models/form/sales/questions/owning_organisation_id_spec.rb index 7f14824db..54a08299b 100644 --- a/spec/models/form/sales/questions/owning_organisation_id_spec.rb +++ b/spec/models/form/sales/questions/owning_organisation_id_spec.rb @@ -57,6 +57,7 @@ RSpec.describe Form::Sales::Questions::OwningOrganisationId, type: :model do let(:owning_org_1) { create(:organisation, name: "Owning org 1") } let(:owning_org_2) { create(:organisation, name: "Owning org 2") } + let(:inactive_owning_org) { create(:organisation, name: "Inactive owning org", active: false) } let(:non_stock_owner) { create(:organisation, name: "Non stock owner", holds_own_stock: false) } let(:log) { create(:lettings_log, owning_organisation: owning_org_1) } @@ -75,7 +76,8 @@ RSpec.describe Form::Sales::Questions::OwningOrganisationId, type: :model do } end - it "shows user organisation, current owning organisation and the stock owners that hold their stock" do + it "shows user organisation, current owning organisation and the activestock owners that hold their stock" do + create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: inactive_owning_org) user.organisation.update!(holds_own_stock: true) expect(question.displayed_answer_options(log, user)).to eq(options) end @@ -95,7 +97,8 @@ RSpec.describe Form::Sales::Questions::OwningOrganisationId, type: :model do create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: non_stock_owner) end - it "shows current owning organisation and the stock owners that hold their stock" do + it "shows current owning organisation and the active stock owners that hold their stock" do + create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: inactive_owning_org) user.organisation.update!(holds_own_stock: false) expect(question.displayed_answer_options(log, user)).to eq(options) end @@ -204,20 +207,21 @@ RSpec.describe Form::Sales::Questions::OwningOrganisationId, type: :model do context "when user is support" do let(:user) { create(:user, :support, organisation: organisation_1) } - let(:log) { create(:lettings_log, created_by: user) } - let(:non_stock_organisation) { create(:organisation, holds_own_stock: false) } - let(:expected_opts) do - Organisation.where(holds_own_stock: true).each_with_object(options) do |organisation, hsh| + it "shows active orgs where organisation holds own stock" do + non_stock_organisation = create(:organisation, holds_own_stock: false) + inactive_org = create(:organisation, active: false) + + expected_opts = Organisation.filter_by_active.where(holds_own_stock: true).each_with_object(options) do |organisation, hsh| hsh[organisation.id] = organisation.name hsh end - end - it "shows orgs where organisation holds own stock" do expect(question.displayed_answer_options(log, user)).to eq(expected_opts) expect(question.displayed_answer_options(log, user)).not_to include(non_stock_organisation.id) + expect(question.displayed_answer_options(log, user)).not_to include(inactive_org.id) + expect(question.displayed_answer_options(log, user)).to include(organisation_1.id) end context "when an org has recently absorbed other orgs" do diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index 58a101496..3bdc55b44 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -870,6 +870,11 @@ RSpec.describe Location, type: :model do expect(location.status).to eq(:deactivating_soon) end + it "returns deactivated if the owning organisation is deactivated" do + location.scheme.owning_organisation.active = false + expect(location.status).to eq(:deactivated) + end + it "returns deactivated if deactivation_date is in the past" do FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 6), location:) location.save! @@ -969,6 +974,9 @@ RSpec.describe Location, type: :model do end describe "filter by status" do + let!(:deactivated_organisation) { FactoryBot.create(:organisation, active: false) } + let!(:deactivated_by_organisation_scheme) { FactoryBot.create(:scheme, owning_organisation: deactivated_organisation) } + let!(:deactivated_by_organisation_location) { FactoryBot.create(:location, scheme: deactivated_by_organisation_scheme) } let!(:incomplete_location) { FactoryBot.create(:location, :incomplete, startdate: Time.zone.local(2022, 4, 1)) } let!(:incomplete_location_with_nil_confirmed) { FactoryBot.create(:location, :incomplete, startdate: Time.zone.local(2022, 4, 1), confirmed: nil) } let!(:active_location) { FactoryBot.create(:location, startdate: Time.zone.local(2022, 4, 1)) } @@ -1015,8 +1023,9 @@ RSpec.describe Location, type: :model do context "when filtering by deactivated status" do it "returns only deactivated locations" do - expect(described_class.filter_by_status(%w[deactivated]).count).to eq(1) - expect(described_class.filter_by_status(%w[deactivated]).first).to eq(deactivated_location) + expect(described_class.filter_by_status(%w[deactivated]).count).to eq(2) + expect(described_class.filter_by_status(%w[deactivated])).to include(deactivated_location) + expect(described_class.filter_by_status(%w[deactivated])).to include(deactivated_by_organisation_location) end end diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index ad9034d35..98b082c56 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -212,8 +212,8 @@ RSpec.describe Organisation, type: :model do describe "scopes" do before do - create(:organisation, name: "Joe Bloggs") - create(:organisation, name: "Tom Smith") + create(:organisation, name: "Joe Bloggs", active: false) + create(:organisation, name: "Tom Smith", active: true) end context "when searching by name" do @@ -229,5 +229,42 @@ RSpec.describe Organisation, type: :model do expect(described_class.search_by("joe").count).to eq(1) end end + + context "when searching by active" do + it "returns only active records" do + results = described_class.filter_by_active + expect(results.count).to eq(1) + expect(results[0].name).to eq("Tom Smith") + end + end + end + + describe "status" do + let!(:organisation) { create(:organisation) } + + it "returns inactive when organisation inactive" do + organisation.active = false + + expect(organisation.status).to be(:deactivated) + end + + it "returns active when organisation active" do + organisation.active = true + + expect(organisation.status).to be(:active) + end + + it "returns merged when organisation merged in the past" do + organisation.merge_date = 1.month.ago + + expect(organisation.status).to be(:merged) + end + + it "does not return merged when organisation merges in the future" do + organisation.active = true + organisation.merge_date = Time.zone.now + 1.month + + expect(organisation.status).to be(:active) + end end end diff --git a/spec/models/scheme_spec.rb b/spec/models/scheme_spec.rb index 9b663595c..c84be444f 100644 --- a/spec/models/scheme_spec.rb +++ b/spec/models/scheme_spec.rb @@ -112,11 +112,13 @@ RSpec.describe Scheme, type: :model do end context "when filtering by status" do + let!(:deactivated_organisation) { FactoryBot.create(:organisation, active: false) } let!(:incomplete_scheme) { FactoryBot.create(:scheme, :incomplete, service_name: "name") } let!(:incomplete_scheme_2) { FactoryBot.create(:scheme, :incomplete, service_name: "name") } let!(:incomplete_scheme_with_nil_confirmed) { FactoryBot.create(:scheme, :incomplete, service_name: "name", confirmed: nil) } let(:active_scheme) { FactoryBot.create(:scheme) } let(:active_scheme_2) { FactoryBot.create(:scheme) } + let!(:deactivated_by_organisation_scheme) { FactoryBot.create(:scheme, owning_organisation: deactivated_organisation) } let(:deactivating_soon_scheme) { FactoryBot.create(:scheme) } let(:deactivating_soon_scheme_2) { FactoryBot.create(:scheme) } let(:deactivated_scheme) { FactoryBot.create(:scheme) } @@ -181,9 +183,10 @@ RSpec.describe Scheme, type: :model do context "when filtering by deactivated status" do it "returns only deactivated schemes" do - expect(described_class.filter_by_status(%w[deactivated]).count).to eq(2) + expect(described_class.filter_by_status(%w[deactivated]).count).to eq(3) expect(described_class.filter_by_status(%w[deactivated])).to include(deactivated_scheme) expect(described_class.filter_by_status(%w[deactivated])).to include(deactivated_scheme_2) + expect(described_class.filter_by_status(%w[deactivated])).to include(deactivated_by_organisation_scheme) end end @@ -231,6 +234,11 @@ RSpec.describe Scheme, type: :model do expect(scheme.status).to eq(:deactivating_soon) end + it "returns deactivated if the owning organisation is deactivated" do + scheme.owning_organisation.active = false + expect(scheme.status).to eq(:deactivated) + end + it "returns deactivated if deactivation_date is in the past" do FactoryBot.create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 6), scheme:) scheme.reload diff --git a/spec/policies/organisation_policy_spec.rb b/spec/policies/organisation_policy_spec.rb new file mode 100644 index 000000000..4fb4c6761 --- /dev/null +++ b/spec/policies/organisation_policy_spec.rb @@ -0,0 +1,66 @@ +require "rails_helper" + +RSpec.describe OrganisationPolicy do + subject(:policy) { described_class } + + let(:organisation) { FactoryBot.create(:organisation) } + let(:data_provider) { FactoryBot.create(:user, :data_provider) } + let(:data_coordinator) { FactoryBot.create(:user, :data_coordinator) } + let(:support) { FactoryBot.create(:user, :support) } + + permissions :deactivate? do + it "does not permit data providers to deactivate an organisation" do + organisation.active = true + expect(policy).not_to permit(data_provider, organisation) + end + + it "does not permit data coordinators to deactivate an organisation" do + organisation.active = true + expect(policy).not_to permit(data_coordinator, organisation) + end + + it "permits support users to deactivate an active organisation" do + organisation.active = true + expect(policy).to permit(support, organisation) + end + + it "does not permit support users to deactivate an inactive organisation" do + organisation.active = false + expect(policy).not_to permit(support, organisation) + end + + it "does not permit support users to deactivate a merged organisation" do + organisation.active = true + organisation.merge_date = Time.zone.local(2023, 8, 2) + expect(policy).not_to permit(support, organisation) + end + end + + permissions :reactivate? do + it "does not permit data providers to reactivate an organisation" do + organisation.active = false + expect(policy).not_to permit(data_provider, organisation) + end + + it "does not permit data coordinators to reactivate an organisation" do + organisation.active = false + expect(policy).not_to permit(data_coordinator, organisation) + end + + it "permits support users to reactivate an inactive organisation" do + organisation.active = false + expect(policy).to permit(support, organisation) + end + + it "does not permit support users to reactivate an active organisation" do + organisation.active = true + expect(policy).not_to permit(support, organisation) + end + + it "does not permit support users to reactivate a merged organisation" do + organisation.active = false + organisation.merge_date = Time.zone.local(2023, 8, 2) + expect(policy).not_to permit(support, organisation) + end + end +end diff --git a/spec/requests/organisation_relationships_controller_spec.rb b/spec/requests/organisation_relationships_controller_spec.rb index 4c22a2aa2..feb687e0c 100644 --- a/spec/requests/organisation_relationships_controller_spec.rb +++ b/spec/requests/organisation_relationships_controller_spec.rb @@ -18,11 +18,13 @@ RSpec.describe OrganisationRelationshipsController, type: :request do context "with an organisation that the user belongs to" do let!(:stock_owner) { FactoryBot.create(:organisation) } let!(:other_org_stock_owner) { FactoryBot.create(:organisation, name: "Foobar LTD") } + let!(:inactive_stock_owner) { FactoryBot.create(:organisation, name: "Inactive LTD", active: false) } let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD 2") } before do FactoryBot.create(:organisation_relationship, child_organisation: organisation, parent_organisation: stock_owner) FactoryBot.create(:organisation_relationship, child_organisation: other_organisation, parent_organisation: other_org_stock_owner) + FactoryBot.create(:organisation_relationship, child_organisation: organisation, parent_organisation: inactive_stock_owner) get "/organisations/#{organisation.id}/stock-owners", headers:, params: {} end @@ -46,11 +48,18 @@ RSpec.describe OrganisationRelationshipsController, type: :request do expect(page).not_to have_content(other_org_stock_owner.name) end + it "does not show inactive stock owners" do + expect(page).not_to have_content(inactive_stock_owner.name) + end + it "shows the pagination count" do expect(page).to have_content("1 total stock owners") end context "when adding a stock owner" do + let!(:active_organisation) { FactoryBot.create(:organisation, name: "Active Org", active: true) } + let!(:inactive_organisation) { FactoryBot.create(:organisation, name: "Inactive LTD", active: false) } + before do get "/organisations/#{organisation.id}/stock-owners/add", headers:, params: {} end @@ -66,6 +75,27 @@ RSpec.describe OrganisationRelationshipsController, type: :request do it "shows a cancel button" do expect(page).to have_link("Cancel", href: "/organisations/#{organisation.id}/stock-owners") end + + it "includes only active organisations as options" do + expect(response.body).to include(active_organisation.name) + expect(response.body).not_to include(inactive_organisation.name) + end + end + + context "and current organisation is deactivated" do + before do + organisation.update!(active: false) + get "/organisations/#{organisation.id}/stock-owners", headers:, params: {} + end + + it "does not show the add stock owner button" do + expect(page).not_to have_link("Add a stock owner") + end + + it "shows a banner" do + expect(page).to have_content("This organisation is deactivated.") + expect(page).to have_content("You cannot add any new stock owners.") + end end end @@ -84,11 +114,13 @@ RSpec.describe OrganisationRelationshipsController, type: :request do context "with an organisation that the user belongs to" do let!(:managing_agent) { FactoryBot.create(:organisation) } let!(:other_org_managing_agent) { FactoryBot.create(:organisation, name: "Foobar LTD") } + let!(:inactive_managing_agent) { FactoryBot.create(:organisation, name: "Inactive LTD", active: false) } let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD") } before do FactoryBot.create(:organisation_relationship, parent_organisation: organisation, child_organisation: managing_agent) FactoryBot.create(:organisation_relationship, parent_organisation: other_organisation, child_organisation: other_org_managing_agent) + FactoryBot.create(:organisation_relationship, parent_organisation: organisation, child_organisation: inactive_managing_agent) get "/organisations/#{organisation.id}/managing-agents", headers:, params: {} end @@ -112,12 +144,35 @@ RSpec.describe OrganisationRelationshipsController, type: :request do expect(page).not_to have_content(other_org_managing_agent.name) end + it "does not show inactive managing-agents" do + expect(page).not_to have_content(inactive_managing_agent.name) + end + it "shows the pagination count" do expect(page).to have_content("1 total managing agents") end + + context "and current organisation is deactivated" do + before do + organisation.update!(active: false) + get "/organisations/#{organisation.id}/managing-agents", headers:, params: {} + end + + it "does not show the add managing agent button" do + expect(page).not_to have_link("Add a managing agent") + end + + it "shows a banner" do + expect(page).to have_content("This organisation is deactivated.") + expect(page).to have_content("You cannot add any new managing agents.") + end + end end context "when adding a managing agent" do + let!(:active_organisation) { FactoryBot.create(:organisation, name: "Active Org", active: true) } + let!(:inactive_organisation) { FactoryBot.create(:organisation, name: "Inactive LTD", active: false) } + before do get "/organisations/#{organisation.id}/managing-agents/add", headers:, params: {} end @@ -125,6 +180,11 @@ RSpec.describe OrganisationRelationshipsController, type: :request do it "has the correct header" do expect(response.body).to include("What is the name of your managing agent?") end + + it "includes only active organisations as options" do + expect(response.body).to include(active_organisation.name) + expect(response.body).not_to include(inactive_organisation.name) + end end context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 53e830592..fa5163003 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -579,6 +579,32 @@ RSpec.describe OrganisationsController, type: :request do expect(whodunnit_actor).to be_a(User) expect(whodunnit_actor.id).to eq(user.id) end + + context "with active parameter true" do + let(:params) do + { + id: organisation.id, + organisation: { active: "true" }, + } + end + + it "redirects" do + expect(response).to have_http_status(:unauthorized) + end + end + + context "with active parameter false" do + let(:params) do + { + id: organisation.id, + organisation: { active: "false" }, + } + end + + it "redirects" do + expect(response).to have_http_status(:unauthorized) + end + end end context "with an organisation that the user does not belong to" do @@ -1407,6 +1433,100 @@ RSpec.describe OrganisationsController, type: :request do end end + describe "#update" do + context "with active parameter false" do + let(:params) { { id: organisation.id, organisation: { active: "false" } } } + + user_to_update = nil + + before do + user_to_update = create(:user, :data_coordinator, organisation:) + patch "/organisations/#{organisation.id}", headers:, params: + end + + it "deactivates associated users" do + user_to_update.reload + expect(user_to_update.active).to eq(false) + expect(user_to_update.reactivate_with_organisation).to eq(true) + end + end + + context "with active parameter true" do + user_to_reactivate = nil + user_not_to_reactivate = nil + + let(:params) do + { + id: organisation.id, + organisation: { active: "true" }, + } + end + let(:notify_client) { instance_double(Notifications::Client) } + let(:devise_notify_mailer) { DeviseNotifyMailer.new } + + let(:expected_personalisation) do + { + name: user_to_reactivate.name, + email: user_to_reactivate.email, + organisation: organisation.name, + link: include("/account/confirmation?confirmation_token="), + } + end + + before do + allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) + allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client) + allow(notify_client).to receive(:send_email).and_return(true) + + user_to_reactivate = create(:user, :data_coordinator, organisation:, active: false, reactivate_with_organisation: true) + user_not_to_reactivate = create(:user, :data_coordinator, organisation:, active: false, reactivate_with_organisation: false) + patch "/organisations/#{organisation.id}", headers:, params: + end + + it "reactivates users deactivated with organisation" do + user_to_reactivate.reload + user_not_to_reactivate.reload + expect(user_to_reactivate.active).to eq(true) + expect(user_to_reactivate.reactivate_with_organisation).to eq(false) + expect(user_not_to_reactivate.active).to eq(false) + end + + it "sends invitation emails" do + expect(notify_client).to have_received(:send_email).with(email_address: user_to_reactivate.email, template_id: User::BETA_ONBOARDING_TEMPLATE_ID, personalisation: expected_personalisation).once + end + end + end + + describe "#deactivate" do + before do + get "/organisations/#{organisation.id}/deactivate", headers:, params: {} + end + + it "shows deactivation page with deactivate and cancel buttons for the organisation" do + expect(path).to include("/organisations/#{organisation.id}/deactivate") + expect(page).to have_content(organisation.name) + expect(page).to have_content("Are you sure you want to deactivate this organisation?") + expect(page).to have_button("Deactivate this organisation") + expect(page).to have_link("Cancel", href: "/organisations/#{organisation.id}") + end + end + + describe "#reactivate" do + let(:inactive_organisation) { create(:organisation, name: "Inactive org", active: false) } + + before do + get "/organisations/#{inactive_organisation.id}/reactivate", headers:, params: {} + end + + it "shows reactivation page with reactivate and cancel buttons for the organisation" do + expect(path).to include("/organisations/#{inactive_organisation.id}/reactivate") + expect(page).to have_content(inactive_organisation.name) + expect(page).to have_content("Are you sure you want to reactivate this organisation?") + expect(page).to have_button("Reactivate this organisation") + expect(page).to have_link("Cancel", href: "/organisations/#{inactive_organisation.id}") + end + end + describe "#create" do let(:name) { " Unique new org name" } let(:address_line1) { "12 Random Street" } diff --git a/spec/views/locations/show.html.erb_spec.rb b/spec/views/locations/show.html.erb_spec.rb index c2510c79b..9caa079e0 100644 --- a/spec/views/locations/show.html.erb_spec.rb +++ b/spec/views/locations/show.html.erb_spec.rb @@ -1,50 +1,51 @@ require "rails_helper" RSpec.describe "locations/show.html.erb" do - context "when a data provider" do - let(:user) { create(:user) } + let(:scheme) do + instance_double( + Scheme, + owning_organisation: user.organisation, + id: 1, + service_name: "some name", + id_to_display: "S1", + sensitive: false, + scheme_type: "some type", + registered_under_care_act: false, + arrangement_type: "some other type", + primary_client_group: false, + has_other_client_group: false, + secondary_client_group: false, + support_type: "some support type", + intended_stay: "some intended stay", + available_from: 1.week.ago, + scheme_deactivation_periods: [], + status: :active, + ) + end - let(:scheme) do - instance_double( - Scheme, - owning_organisation: user.organisation, - id: 1, - service_name: "some name", - id_to_display: "S1", - sensitive: false, - scheme_type: "some type", - registered_under_care_act: false, - arrangement_type: "some other type", - primary_client_group: false, - has_other_client_group: false, - secondary_client_group: false, - support_type: "some support type", - intended_stay: "some intended stay", - available_from: 1.week.ago, - scheme_deactivation_periods: [], - status: :active, - ) - end + let(:location) do + instance_double( + Location, + id: 5, + name: "some location", + postcode: "EC1N 2TD", + linked_local_authorities: [], + units: "", + type_of_unit: "", + mobility_type: "", + available_from: 1.week.ago, + location_deactivation_periods: [], + status: :active, + active?: true, + scheme:, + deactivates_in_a_long_time?: false, + is_la_inferred: nil, + deactivated?: false, + ) + end - let(:location) do - instance_double( - Location, - id: 5, - name: "some location", - postcode: "EC1N 2TD", - linked_local_authorities: [], - units: "", - type_of_unit: "", - mobility_type: "", - available_from: 1.week.ago, - location_deactivation_periods: [], - status: :active, - active?: true, - scheme:, - deactivates_in_a_long_time?: false, - is_la_inferred: nil, - ) - end + context "when a data provider" do + let(:user) { create(:user) } it "does not see add a location button" do assign(:scheme, scheme) @@ -70,4 +71,32 @@ RSpec.describe "locations/show.html.erb" do expect(rendered).not_to have_content("Change") end end + + context "when a support user" do + let(:user) { create(:user, role: "support") } + + it "sees deactivate scheme location button" do + assign(:scheme, scheme) + assign(:location, location) + + allow(view).to receive(:current_user).and_return(user) + + render + + expect(rendered).to have_content("Deactivate this location") + end + + it "does not see deactivate scheme location button when organisation is deactivated" do + user.organisation.active = false + + assign(:scheme, scheme) + assign(:location, location) + + allow(view).to receive(:current_user).and_return(user) + + render + + expect(rendered).not_to have_content("Deactivate this location") + end + end end diff --git a/spec/views/organisations/show.html.erb_spec.rb b/spec/views/organisations/show.html.erb_spec.rb index 119462349..de4996c36 100644 --- a/spec/views/organisations/show.html.erb_spec.rb +++ b/spec/views/organisations/show.html.erb_spec.rb @@ -113,6 +113,20 @@ RSpec.describe "organisations/show.html.erb" do expect(fragment).to have_link(text: "View agreement", href: "/organisations/#{organisation_with_dsa.id}/data-sharing-agreement") end end + + it "shows deactivate button when organisation is active" do + user.organisation.active = true + render + expect(fragment).to have_content("Deactivate this organisation") + expect(fragment).not_to have_content("Reactivate this organisation") + end + + it "shows reactivate button when organisation is inactive" do + user.organisation.active = false + render + expect(fragment).not_to have_content("Deactivate this organisation") + expect(fragment).to have_content("Reactivate this organisation") + end end context "when not dpo" do diff --git a/spec/views/schemes/show.html.erb_spec.rb b/spec/views/schemes/show.html.erb_spec.rb index 4a0447c11..797a95d60 100644 --- a/spec/views/schemes/show.html.erb_spec.rb +++ b/spec/views/schemes/show.html.erb_spec.rb @@ -1,10 +1,15 @@ require "rails_helper" RSpec.describe "schemes/show.html.erb" do + let(:organisation) { create(:organisation, holds_own_stock: true) } + let(:scheme) { create(:scheme, owning_organisation: organisation, confirmed: true) } + + before do + create(:location, scheme:, confirmed: true) + end + context "when data provider" do - let(:organisation) { create(:organisation, holds_own_stock: true) } let(:user) { build(:user, organisation:) } - let(:scheme) { create(:scheme, owning_organisation: user.organisation) } it "does not render button to deactivate schemes" do assign(:scheme, scheme) @@ -26,4 +31,29 @@ RSpec.describe "schemes/show.html.erb" do expect(rendered).not_to have_content("Change") end end + + context "when support" do + let(:user) { build(:user, organisation:, role: "support") } + + it "renders button to deactivate scheme" do + assign(:scheme, scheme) + + allow(view).to receive(:current_user).and_return(user) + + render + + expect(rendered).to have_content("Deactivate this scheme") + end + + it "does not render button to deactivate scheme if organisation is deactivated" do + organisation.active = false + assign(:scheme, scheme) + + allow(view).to receive(:current_user).and_return(user) + + render + + expect(rendered).not_to have_content("Deactivate this scheme") + end + end end From f03c9573bd8a43bade0b9e38c59db0c0978b1c42 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:03:09 +0100 Subject: [PATCH 02/12] Enable resource deletion on prod (#2380) --- app/services/feature_toggle.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/feature_toggle.rb b/app/services/feature_toggle.rb index 987a087ac..810bfb845 100644 --- a/app/services/feature_toggle.rb +++ b/app/services/feature_toggle.rb @@ -28,14 +28,14 @@ class FeatureToggle end def self.delete_scheme_enabled? - !Rails.env.production? + true end def self.delete_location_enabled? - !Rails.env.production? + true end def self.delete_user_enabled? - !Rails.env.production? + true end end From 14fd937e490f0192d293a8640520e54c106e33d2 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:24:09 +0100 Subject: [PATCH 03/12] feat: remove dependency on current date in test (#2382) --- spec/models/validations/household_validations_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 32fb536e8..1c0be2133 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -429,10 +429,11 @@ RSpec.describe Validations::HouseholdValidations do end context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } + before do - Timecop.freeze(Time.zone.local(2024, 4, 1)) + Timecop.freeze(log_date) Singleton.__init__(FormHandler) - record.update!(startdate: Time.zone.local(2024, 4, 1)) end after do From c4741ee2ac792268204cc8dbd171a1a1611289b0 Mon Sep 17 00:00:00 2001 From: Robert Sullivan Date: Tue, 16 Apr 2024 09:06:52 +0100 Subject: [PATCH 04/12] CLDC-2670: Improve navigation flow when revisiting questions from CYA page (#2362) * CLDC-2670: Improve navigation flow when revisiting questions from CYA page * CLDC-2670: Fix failing test * CLDC-2670: fix issue with wrong referrer behaviour on interrupt screens * CLDC-2670: Fix build errors * Update validation feature * CLDC-2670: Do not show already-answered questions when answering new questions from CYA page * CLDC-2670: Fix linter error and tests * Fix incorrect URLs in feature test * feat: fix typo * feat: make skip links for new answers route to check_answers * feat: make skip links for new answers route to check_answers * feat: update tests * feat: bug fix * feat: test fix * feat: skip unanswered questions for interruption screens --------- Co-authored-by: natdeanlewissoftwire --- ...swers_summary_list_card_component.html.erb | 2 +- ...eck_answers_summary_list_card_component.rb | 5 +- app/controllers/form_controller.rb | 40 +++++++++++-- app/helpers/form_page_helper.rb | 2 +- app/models/form.rb | 11 ++-- app/models/form/page.rb | 4 ++ app/models/form/question.rb | 10 +++- .../form/_check_answers_summary_list.html.erb | 6 +- .../_interruption_screen_question.html.erb | 2 +- app/views/form/check_answers.html.erb | 1 + app/views/form/review.html.erb | 7 ++- .../check_answers_page_lettings_logs_spec.rb | 4 +- spec/features/form/form_navigation_spec.rb | 6 +- spec/features/form/validations_spec.rb | 10 ++-- spec/requests/form_controller_spec.rb | 60 ++++++++++++++++++- 15 files changed, 140 insertions(+), 30 deletions(-) diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb index 946092a46..4a26b8c8d 100644 --- a/app/components/check_answers_summary_list_card_component.html.erb +++ b/app/components/check_answers_summary_list_card_component.html.erb @@ -36,7 +36,7 @@ <% if @log.collection_period_open_for_editing? %> <% row.with_action( text: question.action_text(log), - href: action_href(log, question.page.id), + href: action_href(question, log), visually_hidden_text: question.check_answer_label.to_s.downcase, ) %> <% end %> diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb index 8f18b1ffc..205a8516e 100644 --- a/app/components/check_answers_summary_list_card_component.rb +++ b/app/components/check_answers_summary_list_card_component.rb @@ -28,8 +28,9 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base "Person #{question.check_answers_card_number}" end - def action_href(log, page_id, referrer = "check_answers") - send("#{log.model_name.param_key}_#{page_id}_path", log, referrer:) + def action_href(question, log) + referrer = question.displayed_as_answered?(log) ? "check_answers" : "check_answers_new_answer" + send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer:) end private diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 635dc12e4..e558b5fb5 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -9,6 +9,11 @@ class FormController < ApplicationController def submit_form if @log @page = form.get_page(params[@log.model_name.param_key][:page]) + shown_page_ids_with_unanswered_questions_before_update = @page.subsection.pages + .select { |page| page.routed_to?(@log, current_user) } + .select { |page| page.has_unanswered_questions?(@log) } + .map(&:id) + responses_for_page = responses_for_page(@page) mandatory_questions_with_no_response = mandatory_questions_with_no_response(responses_for_page) @@ -18,7 +23,9 @@ class FormController < ApplicationController updated_question_string = [updated_question&.question_number_string, updated_question&.check_answer_label.to_s.downcase].compact.join(": ") flash[:notice] = "You have successfully updated #{updated_question_string}" end - redirect_to(successful_redirect_path) + + pages_requiring_update = pages_requiring_update(shown_page_ids_with_unanswered_questions_before_update) + redirect_to(successful_redirect_path(pages_requiring_update)) else mandatory_questions_with_no_response.map do |question| @log.errors.add question.id.to_sym, question.unanswered_error_message, category: :not_answered @@ -171,7 +178,7 @@ private params[@log.model_name.param_key]["interruption_page_referrer_type"].presence end - def successful_redirect_path + def successful_redirect_path(pages_to_check) if FeatureToggle.deduplication_flow_enabled? if is_referrer_type?("duplicate_logs") || is_referrer_type?("duplicate_logs_banner") return correcting_duplicate_logs_redirect_path @@ -195,7 +202,9 @@ private previous_page = form.previous_page_id(@page, @log, current_user) if next_page&.interruption_screen? || next_page_id == previous_page || CONFIRMATION_PAGE_IDS.include?(next_page_id) - return send("#{@log.class.name.underscore}_#{next_page_id}_path", @log, { referrer: "check_answers" }) + return redirect_path_to_question(next_page, pages_to_check) + elsif pages_to_check.any? + return redirect_path_to_question(pages_to_check[0], pages_to_check) else return send("#{@log.model_name.param_key}_#{form.subsection_for_page(@page).id}_check_answers_path", @log) end @@ -204,8 +213,29 @@ private return send("#{@log.class.name.underscore}_#{previous_interruption_screen_page_id}_path", @log, { referrer: previous_interruption_screen_referrer, original_log_id: original_duplicate_log_id_from_query }.compact) end - redirect_path = form.next_page_redirect_path(@page, @log, current_user) - send(redirect_path, @log) + is_new_answer_from_check_answers = is_referrer_type?("check_answers_new_answer") + redirect_path = form.next_page_redirect_path(@page, @log, current_user, ignore_answered: is_new_answer_from_check_answers) + referrer = is_new_answer_from_check_answers ? "check_answers_new_answer" : nil + + send(redirect_path, @log, { referrer: }) + end + + def redirect_path_to_question(page_to_show, unanswered_pages) + remaining_pages = unanswered_pages.excluding(page_to_show) + remaining_page_ids = remaining_pages.any? ? remaining_pages.map(&:id).join(",") : nil + send("#{@log.class.name.underscore}_#{page_to_show.id}_path", @log, { referrer: "check_answers", unanswered_pages: remaining_page_ids }) + end + + def pages_requiring_update(previously_visible_empty_page_ids) + return [] unless is_referrer_type?("check_answers") + + currently_shown_pages = @page.subsection.pages + .select { |page| page.routed_to?(@log, current_user) } + + existing_unanswered_pages = request.params["unanswered_pages"].nil? ? [] : request.params["unanswered_pages"].split(",") + currently_shown_pages + .reject { |page| previously_visible_empty_page_ids.include?(page.id) && !existing_unanswered_pages.include?(page.id) } + .select { |page| page.has_unanswered_questions?(@log) } end def form diff --git a/app/helpers/form_page_helper.rb b/app/helpers/form_page_helper.rb index dc471da1c..eeb682131 100644 --- a/app/helpers/form_page_helper.rb +++ b/app/helpers/form_page_helper.rb @@ -43,7 +43,7 @@ module FormPageHelper elsif returning_to_question_page?(page, referrer) send(log.form.cancel_path(page, log), log) else - page.skip_href(log) || send(log.form.next_page_redirect_path(page, log, current_user), log) + page.skip_href(log) || send(log.form.next_page_redirect_path(page, log, current_user, ignore_answered: true), log) end end end diff --git a/app/models/form.rb b/app/models/form.rb index 1d58e2f9f..755121473 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -80,7 +80,7 @@ class Form subsections.find { |s| s.pages.find { |p| p.id == page.id } } end - def next_page_id(page, log, current_user) + def next_page_id(page, log, current_user, ignore_answered: false) return page.next_unresolved_page_id || :check_answers if log.unresolved page_ids = subsection_for_page(page).pages.map(&:id) @@ -93,13 +93,14 @@ class Form next_page = get_page(page_id) return :check_answers if next_page.nil? - return next_page.id if next_page.routed_to?(log, current_user) + return next_page.id if next_page.routed_to?(log, current_user) && + (!ignore_answered || next_page.has_unanswered_questions?(log)) - next_page_id(next_page, log, current_user) + next_page_id(next_page, log, current_user, ignore_answered:) end - def next_page_redirect_path(page, log, current_user) - next_page_id = next_page_id(page, log, current_user) + def next_page_redirect_path(page, log, current_user, ignore_answered: false) + next_page_id = next_page_id(page, log, current_user, ignore_answered:) if next_page_id == :check_answers "#{type}_log_#{subsection_for_page(page).id}_check_answers_path" else diff --git a/app/models/form/page.rb b/app/models/form/page.rb index 6485ceb07..f1d6497a0 100644 --- a/app/models/form/page.rb +++ b/app/models/form/page.rb @@ -36,6 +36,10 @@ class Form::Page end end + def has_unanswered_questions?(log) + questions.any? { |question| question.displayed_to_user?(log) && question.unanswered?(log) } + end + def interruption_screen? questions.all? { |question| question.type == "interruption_screen" } end diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 0c1611e60..20b73f5d8 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -110,12 +110,16 @@ class Form::Question end def action_text(log) + displayed_as_answered?(log) ? "Change" : "Answer" + end + + def displayed_as_answered?(log) if is_derived_or_has_inferred_check_answers_value?(log) - "Change" + true elsif type == "checkbox" - answer_options.keys.any? { |key| value_is_yes?(log[key]) } ? "Change" : "Answer" + answer_options.keys.any? { |key| value_is_yes?(log[key]) } else - log[id].blank? ? "Answer" : "Change" + log[id].present? end end diff --git a/app/views/form/_check_answers_summary_list.html.erb b/app/views/form/_check_answers_summary_list.html.erb index 59d6c9bd1..f849847a2 100644 --- a/app/views/form/_check_answers_summary_list.html.erb +++ b/app/views/form/_check_answers_summary_list.html.erb @@ -28,7 +28,11 @@ <% if @log.collection_period_open_for_editing? %> <% row.with_action( text: question.action_text(@log), - href: action_href(@log, question.page.id, referrer), + href: action_href( + @log, + question.page.id, + question.displayed_as_answered?(@log) || !defined?(referrer_unanswered) ? referrer : referrer_unanswered, + ), visually_hidden_text: question.check_answer_label.to_s.downcase, ) %> <% end %> diff --git a/app/views/form/_interruption_screen_question.html.erb b/app/views/form/_interruption_screen_question.html.erb index 73c355588..c0063e477 100644 --- a/app/views/form/_interruption_screen_question.html.erb +++ b/app/views/form/_interruption_screen_question.html.erb @@ -19,6 +19,6 @@ <%= f.govuk_submit "Confirm and continue" %> <%= govuk_link_to( (@page.skip_text || "Skip for now"), - (@page.skip_href(@log) || send(@log.form.next_page_redirect_path(@page, @log, current_user), @log)), + (@page.skip_href(@log) || send(@log.form.next_page_redirect_path(@page, @log, current_user, ignore_answered: true), @log)), ) %>
diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb index 7c26dd123..a0ce5c9dc 100644 --- a/app/views/form/check_answers.html.erb +++ b/app/views/form/check_answers.html.erb @@ -27,6 +27,7 @@ lettings_log: @log, questions: total_applicable_questions(subsection, @log, current_user), referrer: "check_answers", + referrer_unanswered: "check_answers_new_answer", } %> <% end %> diff --git a/app/views/form/review.html.erb b/app/views/form/review.html.erb index 39682362d..357f83fd0 100644 --- a/app/views/form/review.html.erb +++ b/app/views/form/review.html.erb @@ -19,7 +19,12 @@

<%= subsection.label %>

- <%= render partial: "form/check_answers_summary_list", locals: { subsection:, questions: total_applicable_questions(subsection, @log, current_user), referrer: "check_answers" } %> + <%= render partial: "form/check_answers_summary_list", locals: { + subsection:, + questions: total_applicable_questions(subsection, @log, current_user), + referrer: "check_answers", + referrer_unanswered: "check_answers_new_answer", + } %>
<% end %> diff --git a/spec/features/form/check_answers_page_lettings_logs_spec.rb b/spec/features/form/check_answers_page_lettings_logs_spec.rb index f45854b4f..3df66a341 100644 --- a/spec/features/form/check_answers_page_lettings_logs_spec.rb +++ b/spec/features/form/check_answers_page_lettings_logs_spec.rb @@ -89,11 +89,11 @@ RSpec.describe "Lettings Log Check Answers Page" do # Regex explanation: match the string "Answer" but not if it's follow by "the missing questions" # This way only the links in the table will get picked up - it "has an answer link for questions missing an answer" do + it "has an answer link with the check_answers_new_answer referrer for questions missing an answer" do visit("/lettings-logs/#{empty_lettings_log.id}/#{subsection}/check-answers?referrer=check_answers") assert_selector "a", text: /Answer (?!the missing questions)/, count: 4 assert_selector "a", text: "Change", count: 0 - expect(page).to have_link("Answer", href: "/lettings-logs/#{empty_lettings_log.id}/person-1-age?referrer=check_answers") + expect(page).to have_link("Answer", href: "/lettings-logs/#{empty_lettings_log.id}/person-1-age?referrer=check_answers_new_answer") end it "has a change link for answered questions" do diff --git a/spec/features/form/form_navigation_spec.rb b/spec/features/form/form_navigation_spec.rb index 9e43dd682..5b21a9cbd 100644 --- a/spec/features/form/form_navigation_spec.rb +++ b/spec/features/form/form_navigation_spec.rb @@ -66,12 +66,12 @@ RSpec.describe "Form Navigation" do expect(page).to have_field("lettings-log-age1-field") end - it "a question page leads to the next question defined in the form definition" do + it "a question page leads to the next unanswered question defined in the form definition" do pages = question_answers.map { |_key, val| val[:path] } pages[0..-2].each_with_index do |val, index| - visit("/lettings-logs/#{id}/#{val}") + visit("/lettings-logs/#{empty_lettings_log.id}/#{val}") click_link("Skip for now") - expect(page).to have_current_path("/lettings-logs/#{id}/#{pages[index + 1]}") + expect(page).to have_current_path("/lettings-logs/#{empty_lettings_log.id}/#{pages[index + 1]}") end end diff --git a/spec/features/form/validations_spec.rb b/spec/features/form/validations_spec.rb index aba4f40f6..cf7cff0ea 100644 --- a/spec/features/form/validations_spec.rb +++ b/spec/features/form/validations_spec.rb @@ -171,15 +171,17 @@ RSpec.describe "validations" do expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") end - it "returns the user back to the check_your_answers after fixing a validation from check_your_anwers" do - lettings_log.update!(earnings: income_over_soft_limit, incfreq: 1) + it "returns the user back to the check_your_answers after fixing a validation from check_your_answers" do + lettings_log.update!(earnings: income_under_soft_limit, incfreq: 1, net_income_value_check: 1) visit("/lettings-logs/#{lettings_log.id}/income-and-benefits/check-answers") - click_link("Answer", href: "/lettings-logs/#{lettings_log.id}/net-income-value-check?referrer=check_answers") + click_link("Change", href: "/lettings-logs/#{lettings_log.id}/net-income?referrer=check_answers", match: :first) + expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income?referrer=check_answers") + fill_in("lettings-log-earnings-field", with: income_over_soft_limit) + click_button("Save changes") expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income-value-check?referrer=check_answers") click_link("Change", href: "/lettings-logs/#{lettings_log.id}/net-income?referrer=interruption_screen", match: :first) expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income?referrer=interruption_screen") fill_in("lettings-log-earnings-field", with: income_under_soft_limit) - choose("lettings-log-incfreq-1-field", allow_label_click: true) click_button("Save and continue") expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income-value-check?referrer=check_answers") click_button("Confirm and continue") diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb index 76f8e52a5..beafa258f 100644 --- a/spec/requests/form_controller_spec.rb +++ b/spec/requests/form_controller_spec.rb @@ -1036,6 +1036,13 @@ RSpec.describe FormController, type: :request do sales_log.saledate = Time.zone.local(2024, 12, 1) sales_log.save!(validate: false) sales_log.reload + Timecop.freeze(Time.zone.local(2024, 12, 1)) + Singleton.__init__(FormHandler) + end + + after do + Timecop.unfreeze + Singleton.__init__(FormHandler) end it "sets managing organisation to created by organisation" do @@ -1261,7 +1268,7 @@ RSpec.describe FormController, type: :request do "housingneeds_g" => "No disability requirements", "divider_a" => true, "housingneeds_h" => "Don’t know" }, - }, nil + }, page ), Form::Question.new("tenancycode", { "type" => "text" }, nil), ] @@ -1326,6 +1333,57 @@ RSpec.describe FormController, type: :request do end context "when coming from check answers page" do + let(:sales_log) { create(:sales_log, ownershipsch: 3, created_by: user) } + let(:lettings_log_referrer) { "/lettings-logs/#{lettings_log.id}/needs-type?referrer=check_answers" } + let(:sales_log_referrer) { "/sales-logs/#{sales_log.id}/ownership-scheme?referrer=check_answers" } + + let(:sales_log_form_ownership_params) do + { + id: sales_log.id, + sales_log: { + page: "ownership_scheme", + ownershipsch: 1, + }, + } + end + let(:sales_log_form_shared_ownership_type_params) do + { + id: sales_log.id, + unanswered_pages: "joint_purchase", + sales_log: { + page: "shared_ownership_type", + type: 2, + }, + } + end + let(:lettings_log_form_needs_type_params) do + { + id: lettings_log.id, + lettings_log: { + page: "needs_type", + needstype: 2, + }, + } + end + + context "and changing an answer" do + it "navigates to follow-up questions when required" do + post "/lettings-logs/#{lettings_log.id}/needs-type", params: lettings_log_form_needs_type_params, headers: headers.merge({ "HTTP_REFERER" => lettings_log_referrer }) + expect(response).to redirect_to("/lettings-logs/#{lettings_log.id}/scheme?referrer=check_answers") + end + + it "queues up additional follow-up questions if needed" do + post "/sales-logs/#{sales_log.id}/shared-ownership-type", params: sales_log_form_ownership_params, headers: headers.merge({ "HTTP_REFERER" => sales_log_referrer }) + expect(response).to redirect_to("/sales-logs/#{sales_log.id}/shared-ownership-type?referrer=check_answers&unanswered_pages=joint_purchase") + end + + it "moves to a queued up follow-up questions if one was provided" do + post "/sales-logs/#{sales_log.id}/shared-ownership-type", params: sales_log_form_ownership_params, headers: headers.merge({ "HTTP_REFERER" => sales_log_referrer }) + post "/sales-logs/#{sales_log.id}/ownership-scheme", params: sales_log_form_shared_ownership_type_params, headers: headers.merge({ "HTTP_REFERER" => sales_log_referrer }) + expect(response).to redirect_to("/sales-logs/#{sales_log.id}/joint-purchase?referrer=check_answers") + end + end + context "and navigating to an interruption screen" do let(:interrupt_params) do { From a0215d45efe4012429a1b436ac85df6cf43bd7c9 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Tue, 16 Apr 2024 09:20:19 +0100 Subject: [PATCH 05/12] CLDC-3089 Make absolute skip/back links relative (#2348) * Empty-Commit * feat: make skip links relative * feat: make scheme back links relative * feat: update tests --- app/models/form/lettings/pages/uprn.rb | 4 ++-- app/models/form/lettings/pages/uprn_selection.rb | 2 +- app/models/form/sales/pages/uprn.rb | 4 ++-- app/models/form/sales/pages/uprn_selection.rb | 2 +- app/views/schemes/confirm_secondary.html.erb | 2 +- app/views/schemes/secondary_client_group.html.erb | 2 +- app/views/schemes/support.html.erb | 2 +- spec/models/form/lettings/pages/uprn_selection_spec.rb | 2 +- spec/models/form/lettings/pages/uprn_spec.rb | 4 ++-- spec/models/form/sales/pages/uprn_selection_spec.rb | 2 +- spec/models/form/sales/pages/uprn_spec.rb | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/form/lettings/pages/uprn.rb b/app/models/form/lettings/pages/uprn.rb index 83ea11507..d3c744b8f 100644 --- a/app/models/form/lettings/pages/uprn.rb +++ b/app/models/form/lettings/pages/uprn.rb @@ -24,9 +24,9 @@ class Form::Lettings::Pages::Uprn < ::Form::Page return unless log if form.start_year_after_2024? - "/#{log.model_name.param_key.dasherize}s/#{log.id}/address-matcher" + "address-matcher" else - "/#{log.model_name.param_key.dasherize}s/#{log.id}/address" + "address" end end end diff --git a/app/models/form/lettings/pages/uprn_selection.rb b/app/models/form/lettings/pages/uprn_selection.rb index 8d3640740..162c608f3 100644 --- a/app/models/form/lettings/pages/uprn_selection.rb +++ b/app/models/form/lettings/pages/uprn_selection.rb @@ -27,6 +27,6 @@ class Form::Lettings::Pages::UprnSelection < ::Form::Page def skip_href(log = nil) return unless log - "/#{log.model_name.param_key.dasherize}s/#{log.id}/address-matcher" + "address-matcher" end end diff --git a/app/models/form/sales/pages/uprn.rb b/app/models/form/sales/pages/uprn.rb index 05727878e..d4c7e4d77 100644 --- a/app/models/form/sales/pages/uprn.rb +++ b/app/models/form/sales/pages/uprn.rb @@ -23,9 +23,9 @@ class Form::Sales::Pages::Uprn < ::Form::Page return unless log if form.start_year_after_2024? - "/#{log.model_name.param_key.dasherize}s/#{log.id}/address-matcher" + "address-matcher" else - "/#{log.model_name.param_key.dasherize}s/#{log.id}/address" + "address" end end end diff --git a/app/models/form/sales/pages/uprn_selection.rb b/app/models/form/sales/pages/uprn_selection.rb index 1c7f251ac..94f35540f 100644 --- a/app/models/form/sales/pages/uprn_selection.rb +++ b/app/models/form/sales/pages/uprn_selection.rb @@ -27,6 +27,6 @@ class Form::Sales::Pages::UprnSelection < ::Form::Page def skip_href(log = nil) return unless log - "/#{log.model_name.param_key.dasherize}s/#{log.id}/address-matcher" + "address-matcher" end end diff --git a/app/views/schemes/confirm_secondary.html.erb b/app/views/schemes/confirm_secondary.html.erb index de5d9c82e..7e7cfeebf 100644 --- a/app/views/schemes/confirm_secondary.html.erb +++ b/app/views/schemes/confirm_secondary.html.erb @@ -2,7 +2,7 @@ <% content_for :before_content do %> <%= govuk_back_link( - href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/primary-client-group", + href: request.query_parameters["check_answers"] ? "check-answers" : "primary-client-group", ) %> <% end %> diff --git a/app/views/schemes/secondary_client_group.html.erb b/app/views/schemes/secondary_client_group.html.erb index 45c68547a..1e70fd92b 100644 --- a/app/views/schemes/secondary_client_group.html.erb +++ b/app/views/schemes/secondary_client_group.html.erb @@ -2,7 +2,7 @@ <% content_for :before_content do %> <%= govuk_back_link( - href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/confirm-secondary-client-group", + href: request.query_parameters["check_answers"] ? "check-answers" : "confirm-secondary-client-group", ) %> <% end %> diff --git a/app/views/schemes/support.html.erb b/app/views/schemes/support.html.erb index b953ce548..a004a3da9 100644 --- a/app/views/schemes/support.html.erb +++ b/app/views/schemes/support.html.erb @@ -2,7 +2,7 @@ <% content_for :before_content do %> <%= govuk_back_link( - href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/secondary-client-group", + href: request.query_parameters["check_answers"] ? "check-answers" : "secondary-client-group", ) %> <% end %> diff --git a/spec/models/form/lettings/pages/uprn_selection_spec.rb b/spec/models/form/lettings/pages/uprn_selection_spec.rb index 89e2424d2..5cbb08e93 100644 --- a/spec/models/form/lettings/pages/uprn_selection_spec.rb +++ b/spec/models/form/lettings/pages/uprn_selection_spec.rb @@ -34,7 +34,7 @@ RSpec.describe Form::Lettings::Pages::UprnSelection, type: :model do it "has the correct skip_href" do expect(page.skip_href(log)).to eq( - "/lettings-logs/#{log.id}/address-matcher", + "address-matcher", ) end diff --git a/spec/models/form/lettings/pages/uprn_spec.rb b/spec/models/form/lettings/pages/uprn_spec.rb index 7d5921444..089daf4bc 100644 --- a/spec/models/form/lettings/pages/uprn_spec.rb +++ b/spec/models/form/lettings/pages/uprn_spec.rb @@ -50,7 +50,7 @@ RSpec.describe Form::Lettings::Pages::Uprn, type: :model do context "with 2023/24 form" do it "points to address page" do expect(page.skip_href(log)).to eq( - "/lettings-logs/#{log.id}/address", + "address", ) end @@ -66,7 +66,7 @@ RSpec.describe Form::Lettings::Pages::Uprn, type: :model do it "points to address search page" do expect(page.skip_href(log)).to eq( - "/lettings-logs/#{log.id}/address-matcher", + "address-matcher", ) end diff --git a/spec/models/form/sales/pages/uprn_selection_spec.rb b/spec/models/form/sales/pages/uprn_selection_spec.rb index 75fc6ae24..6013774d3 100644 --- a/spec/models/form/sales/pages/uprn_selection_spec.rb +++ b/spec/models/form/sales/pages/uprn_selection_spec.rb @@ -34,7 +34,7 @@ RSpec.describe Form::Sales::Pages::UprnSelection, type: :model do it "has the correct skip_href" do expect(page.skip_href(log)).to eq( - "/sales-logs/#{log.id}/address-matcher", + "address-matcher", ) end diff --git a/spec/models/form/sales/pages/uprn_spec.rb b/spec/models/form/sales/pages/uprn_spec.rb index 092f2dfef..ef1c9848f 100644 --- a/spec/models/form/sales/pages/uprn_spec.rb +++ b/spec/models/form/sales/pages/uprn_spec.rb @@ -50,7 +50,7 @@ RSpec.describe Form::Sales::Pages::Uprn, type: :model do context "with 2023/24 form" do it "points to address page" do expect(page.skip_href(log)).to eq( - "/sales-logs/#{log.id}/address", + "address", ) end @@ -66,7 +66,7 @@ RSpec.describe Form::Sales::Pages::Uprn, type: :model do it "points to address search page" do expect(page.skip_href(log)).to eq( - "/sales-logs/#{log.id}/address-matcher", + "address-matcher", ) end From 64001541a67620562946d4b6c28bffb675a8c098 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Tue, 16 Apr 2024 10:29:41 +0100 Subject: [PATCH 06/12] CLDC-3123 Speed up deployment pipeline (#2355) * feat: remove unnecessary steps from prod pipeline, check they passed on staging in the prod aws deploy step instead * feat: test condition * Revert "feat: test condition" This reverts commit 4146b2664be18ca0c5935262a72c9e6e0700b919. --- .github/workflows/aws_deploy.yml | 6 +- .github/workflows/production_pipeline.yml | 200 ---------------------- 2 files changed, 5 insertions(+), 201 deletions(-) diff --git a/.github/workflows/aws_deploy.yml b/.github/workflows/aws_deploy.yml index 7fea220d3..20c043f3d 100644 --- a/.github/workflows/aws_deploy.yml +++ b/.github/workflows/aws_deploy.yml @@ -59,13 +59,17 @@ jobs: run: | echo "image-exists=$(if aws ecr list-images --repository-name=$repository --query "imageIds[*].imageTag" | grep -q ${{ github.sha }}; then echo true; else echo false; fi)" >> $GITHUB_ENV - - name: Build, tag, and push docker image to ECR + - name: Build, tag, and push docker image to ECR if there is no image, failing for releases id: build-image if: ${{ env.image-exists == 'false' }} env: registry: ${{ steps.ecr-login.outputs.registry }} commit_tag: ${{ github.sha }} run: | + if [[ ${{ inputs.environment }} == 'production' ]]; then + echo "Error: Deployment to production environment is not allowed as there is no docker image (i.e. the AWS deploy on staging was unsuccessful for this commit)." + exit 1 + fi docker build -t $registry/$repository:$commit_tag . --target=production docker push $registry/$repository:$commit_tag diff --git a/.github/workflows/production_pipeline.yml b/.github/workflows/production_pipeline.yml index cb79038ef..b4a188415 100644 --- a/.github/workflows/production_pipeline.yml +++ b/.github/workflows/production_pipeline.yml @@ -5,213 +5,13 @@ on: types: [released] workflow_dispatch: -env: - REPO_URL: communitiesuk/submit-social-housing-lettings-and-sales-data - defaults: run: shell: bash jobs: - test: - name: Test - runs-on: ubuntu-latest - outputs: - releasetag: ${{ steps.latestrelease.outputs.releasetag }} - - services: - postgres: - image: postgres:13.5 - env: - POSTGRES_PASSWORD: password - POSTGRES_USER: postgres - POSTGRES_DB: data_collector - ports: - - 5432:5432 - # Needed because the Postgres container does not provide a health check - # tmpfs makes database faster by using RAM - options: >- - --mount type=tmpfs,destination=/var/lib/postgresql/data - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - env: - RAILS_ENV: test - GEMFILE_RUBY_VERSION: 3.1.1 - DB_HOST: localhost - DB_DATABASE: data_collector - DB_USERNAME: postgres - DB_PASSWORD: password - RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} - PARALLEL_TEST_PROCESSORS: 4 - - steps: - - name: Get latest release with tag - id: latestrelease - run: | - echo "releasetag=$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" >> $GITHUB_OUTPUT - - - name: Confirm release tag - run: | - echo ${{ steps.latestrelease.outputs.releasetag }} - - - name: Checkout tag - uses: actions/checkout@v3 - with: - ref: ${{ steps.latestrelease.outputs.releasetag }} - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Set up node - uses: actions/setup-node@v3 - with: - cache: yarn - node-version: 20 - - - name: Create database - run: | - bundle exec rake parallel:setup - - - name: Compile Assets - run: | - bundle exec rake assets:precompile - - - name: Run tests - run: | - bundle exec rake parallel:spec['spec\/(?!features)'] - - feature_test: - name: Feature Tests - if: '!github.event.pull_request.draft' - runs-on: ubuntu-latest - - services: - postgres: - image: postgres:13.5 - env: - POSTGRES_PASSWORD: password - POSTGRES_USER: postgres - POSTGRES_DB: data_collector - ports: - - 5432:5432 - # Needed because the Postgres container does not provide a health check - # tmpfs makes database faster by using RAM - options: >- - --mount type=tmpfs,destination=/var/lib/postgresql/data - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - env: - RAILS_ENV: test - GEMFILE_RUBY_VERSION: 3.1.1 - DB_HOST: localhost - DB_DATABASE: data_collector - DB_USERNAME: postgres - DB_PASSWORD: password - RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - cache: yarn - node-version: 20 - - - name: Create database - run: | - bundle exec rake db:prepare - - - name: Compile assets - run: | - bundle exec rake assets:precompile - - - name: Run tests - run: | - bundle exec rspec spec/features --fail-fast - - lint: - name: Lint - runs-on: ubuntu-latest - - steps: - - name: Get latest release with tag - id: latestrelease - run: | - echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" - - - name: Confirm release tag - run: | - echo ${{ steps.latestrelease.outputs.releasetag }} - - - name: Checkout tag - uses: actions/checkout@v3 - with: - ref: ${{ steps.latestrelease.outputs.releasetag }} - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - cache: yarn - node-version: 20 - - - name: Install packages and symlink local dependencies - run: | - yarn install --immutable --immutable-cache --check-cache - - - name: Lint - run: | - bundle exec rake lint - - audit: - name: Audit dependencies - runs-on: ubuntu-latest - - steps: - - name: Get latest release with tag - id: latestrelease - run: | - echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" - - - name: Confirm release tag - run: | - echo ${{ steps.latestrelease.outputs.releasetag }} - - - name: Checkout tag - uses: actions/checkout@v3 - with: - ref: ${{ steps.latestrelease.outputs.releasetag }} - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Audit - run: | - bundle exec bundler-audit - aws_deploy: name: AWS Deploy - needs: [lint, test, feature_test, audit] uses: ./.github/workflows/aws_deploy.yml with: aws_account_id: 977287343304 From c309a4760bf45a1625a573ef22edb5404e96ff34 Mon Sep 17 00:00:00 2001 From: Robert Sullivan Date: Tue, 16 Apr 2024 11:31:17 +0100 Subject: [PATCH 07/12] CLDC-3384 referral tests and inconsistencies (#2370) * CLDC-3156: Update 2024 referral options * CLDC-3156: Add tests for referral question * CLDC-3156: Update other referral questions * CLDC-3384: Referral question inconsistencies and tests * feat: remove option 4 from 24/25 referral * feat: update tests --------- Co-authored-by: natdeanlewissoftwire --- .../form/lettings/questions/referral_prp.rb | 7 +- .../questions/referral_supported_housing.rb | 10 +- .../validations/household_validations.rb | 4 - config/locales/en.yml | 2 - .../lettings/questions/referral_prp_spec.rb | 104 +++++++++++++++++ .../referral_supported_housing_prp_spec.rb | 105 ++++++++++++++++++ .../referral_supported_housing_spec.rb | 101 +++++++++++++++++ .../validations/household_validations_spec.rb | 18 --- 8 files changed, 314 insertions(+), 37 deletions(-) create mode 100644 spec/models/form/lettings/questions/referral_prp_spec.rb create mode 100644 spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb create mode 100644 spec/models/form/lettings/questions/referral_supported_housing_spec.rb diff --git a/app/models/form/lettings/questions/referral_prp.rb b/app/models/form/lettings/questions/referral_prp.rb index c5549ce49..6a8fa63de 100644 --- a/app/models/form/lettings/questions/referral_prp.rb +++ b/app/models/form/lettings/questions/referral_prp.rb @@ -18,14 +18,11 @@ class Form::Lettings::Questions::ReferralPrp < ::Form::Question "hint" => "Where the tenant has moved to another social property owned by the same landlord.", }, "2" => { - "value" => "Tenant applied directly (no nomination)", + "value" => "Tenant applied directly (no referral or nomination)", }, "3" => { "value" => "Nominated by a local housing authority", }, - "4" => { - "value" => "Referred by local authority housing department", - }, "8" => { "value" => "Re-located through official housing mobility scheme", }, @@ -64,7 +61,7 @@ class Form::Lettings::Questions::ReferralPrp < ::Form::Question "hint" => "Where the tenant has moved to another social property owned by the same landlord.", }, "2" => { - "value" => "Tenant applied directly (no nomination)", + "value" => "Tenant applied directly (no referral or nomination)", }, "3" => { "value" => "Nominated by a local housing authority", diff --git a/app/models/form/lettings/questions/referral_supported_housing.rb b/app/models/form/lettings/questions/referral_supported_housing.rb index 642d2eb16..d9ede5a83 100644 --- a/app/models/form/lettings/questions/referral_supported_housing.rb +++ b/app/models/form/lettings/questions/referral_supported_housing.rb @@ -18,10 +18,7 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question "hint" => "Where the tenant has moved to another social property owned by the same landlord.", }, "2" => { - "value" => "Tenant applied directly (no referral)", - }, - "3" => { - "value" => "Nominated by a local housing authority", + "value" => "Tenant applied directly (no referral or nomination)", }, "8" => { "value" => "Re-located through official housing mobility scheme", @@ -61,10 +58,7 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question "hint" => "Where the tenant has moved to another social property owned by the same landlord.", }, "2" => { - "value" => "Tenant applied directly (no referral)", - }, - "3" => { - "value" => "Nominated by a local housing authority", + "value" => "Tenant applied directly (no referral or nomination)", }, "8" => { "value" => "Re-located through official housing mobility scheme", diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 52c1de668..2fc3cf6c9 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -178,10 +178,6 @@ module Validations::HouseholdValidations record.errors.add :prevten, :internal_transfer_fixed_or_lifetime, message: I18n.t("validations.household.prevten.la_general_needs.internal_transfer") record.errors.add :referral, :internal_transfer_fixed_or_lifetime, message: I18n.t("validations.household.referral.la_general_needs.internal_transfer") end - - if record.owning_organisation.provider_type == "LA" && record.local_housing_referral? - record.errors.add :referral, I18n.t("validations.household.referral.prp.local_housing_referral") - end end def validate_prevloc(record) diff --git a/config/locales/en.yml b/config/locales/en.yml index 68bea0c8f..ef8674c44 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -533,8 +533,6 @@ en: la_general_needs: internal_transfer: "Answer cannot be internal transfer as it’s the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting" prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log" - prp: - local_housing_referral: "Answer cannot be ‘nominated by a local housing authority’ as a local authority is on the tenancy agreement" homeless: assessed: internal_transfer: "Answer cannot be 'assessed as homeless' as this tenancy is an internal transfer" diff --git a/spec/models/form/lettings/questions/referral_prp_spec.rb b/spec/models/form/lettings/questions/referral_prp_spec.rb new file mode 100644 index 000000000..f0fdb47e7 --- /dev/null +++ b/spec/models/form/lettings/questions/referral_prp_spec.rb @@ -0,0 +1,104 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::ReferralPrp, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + allow(page).to receive(:subsection).and_return(subsection) + allow(subsection).to receive(:form).and_return(form) + end + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("referral") + end + + it "has the correct header" do + expect(question.header).to eq("What was the source of referral for this letting?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Source of referral for letting") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(0) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("You told us that the needs type is general needs. We have removed some options because of this.") + end + + it "is not marked as derived" do + expect(question).not_to be_derived(nil) + end + + context "with 2023/24 form" do + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "3" => { "value" => "Nominated by a local housing authority" }, + "4" => { "value" => "Referred by local authority housing department" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "12" => { "value" => "Police, probation or prison" }, + "7" => { "value" => "Voluntary agency" }, + "13" => { "value" => "Youth offending team" }, + "17" => { "value" => "Children’s Social Care" }, + "16" => { "value" => "Other" }, + }) + end + + it "has the correct question number" do + expect(question.question_number).to eq(85) + end + end + + context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "3" => { "value" => "Nominated by a local housing authority" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" }, + "19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" }, + "7" => { "value" => "Voluntary agency" }, + "17" => { "value" => "Children’s Social Care" }, + "16" => { "value" => "Other" }, + }) + end + + it "has the correct question number" do + expect(question.question_number).to eq(84) + end + end +end diff --git a/spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb b/spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb new file mode 100644 index 000000000..de209092c --- /dev/null +++ b/spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb @@ -0,0 +1,105 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::ReferralSupportedHousingPrp, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + allow(page).to receive(:subsection).and_return(subsection) + allow(subsection).to receive(:form).and_return(form) + end + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("referral") + end + + it "has the correct header" do + expect(question.header).to eq("What was the source of referral for this letting?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Source of referral for letting") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(0) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "is not marked as derived" do + expect(question).not_to be_derived(nil) + end + + context "with 2023/24 form" do + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "3" => { "value" => "Nominated by a local housing authority" }, + "4" => { "value" => "Referred by local authority housing department" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "12" => { "value" => "Police, probation or prison" }, + "7" => { "value" => "Voluntary agency" }, + "13" => { "value" => "Youth offending team" }, + "17" => { "value" => "Children’s Social Care" }, + "16" => { "value" => "Other" }, + }) + end + + it "has the correct question number" do + expect(question.question_number).to eq(85) + end + end + + context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "3" => { "value" => "Nominated by a local housing authority" }, + "4" => { "value" => "Referred by local authority housing department" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" }, + "19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" }, + "7" => { "value" => "Voluntary agency" }, + "17" => { "value" => "Children’s Social Care" }, + "16" => { "value" => "Other" }, + }) + end + + it "has the correct question number" do + expect(question.question_number).to eq(84) + end + end +end diff --git a/spec/models/form/lettings/questions/referral_supported_housing_spec.rb b/spec/models/form/lettings/questions/referral_supported_housing_spec.rb new file mode 100644 index 000000000..0a09415a6 --- /dev/null +++ b/spec/models/form/lettings/questions/referral_supported_housing_spec.rb @@ -0,0 +1,101 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::ReferralSupportedHousing, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + allow(page).to receive(:subsection).and_return(subsection) + allow(subsection).to receive(:form).and_return(form) + end + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("referral") + end + + it "has the correct header" do + expect(question.header).to eq("What was the source of referral for this letting?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Source of referral for letting") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(0) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("You told us that you are a local authority. We have removed some options because of this.") + end + + it "is not marked as derived" do + expect(question).not_to be_derived(nil) + end + + context "with 2023/24 form" do + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "12" => { "value" => "Police, probation or prison" }, + "7" => { "value" => "Voluntary agency" }, + "13" => { "value" => "Youth offending team" }, + "17" => { "value" => "Children’s Social Care" }, + "16" => { "value" => "Other" }, + }) + end + + it "has the correct question number" do + expect(question.question_number).to eq(85) + end + end + + context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" }, + "19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" }, + "7" => { "value" => "Voluntary agency" }, + "17" => { "value" => "Children’s Social Care" }, + "16" => { "value" => "Other" }, + }) + end + + it "has the correct question number" do + expect(question.question_number).to eq(84) + end + end +end diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 1c0be2133..c5f59da93 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -177,24 +177,6 @@ RSpec.describe Validations::HouseholdValidations do .to include(match(I18n.t("validations.household.prevten.la_general_needs.internal_transfer"))) end end - - context "when referral is nominated by a local housing authority" do - it "cannot have a local authority" do - record.owning_organisation.provider_type = "LA" - record.referral = 3 - household_validator.validate_referral(record) - expect(record.errors["referral"]) - .to include(match(I18n.t("validations.household.referral.prp.local_housing_referral"))) - end - - it "can have a private registered provider" do - record.owning_organisation.provider_type = "PRP" - record.referral = 3 - household_validator.validate_referral(record) - expect(record.errors["referral"]) - .to be_empty - end - end end describe "armed forces validations" do From a0842064fbfa618f8ea026da21d871d32b916042 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:58:34 +0100 Subject: [PATCH 08/12] Update privacy notice BU validation (#2377) --- app/services/bulk_upload/lettings/year2023/row_parser.rb | 2 +- .../bulk_upload/lettings/year2023/row_parser_spec.rb | 8 ++++++++ .../bulk_upload/lettings/year2024/row_parser_spec.rb | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 85d660bd5..7ce80b279 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -517,7 +517,7 @@ private def validate_declaration_acceptance unless field_45 == 1 - errors.add(:field_45, I18n.t("validations.declaration.missing"), category: :setup) + errors.add(:field_45, I18n.t("validations.declaration.missing.pre_2024"), category: :setup) end end diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb index 6203b9c59..6b3652b6f 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -692,6 +692,14 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do expect(parser).not_to be_valid end end + + context "when the privacy notice is not accepted" do + let(:attributes) { valid_attributes.merge({ field_45: nil }) } + + it "cannot be nulled" do + expect(parser.errors[:field_45]).to eq(["You must show the DLUHC privacy notice to the tenant before you can submit this log."]) + end + end end describe "#validate_nulls" do diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index d1c2fc761..7895b8eb5 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -787,6 +787,14 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end end end + + context "when the privacy notice is not accepted" do + let(:attributes) { valid_attributes.merge({ field_15: nil }) } + + it "cannot be nulled" do + expect(parser.errors[:field_15]).to eq(["You must answer tenant has seen the privacy notice"]) + end + end end describe "#validate_nulls" do From b83be837ee10307b398b04612c8540e3f0b63d22 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:25:43 +0100 Subject: [PATCH 09/12] CLDC-3377 Remove hint text from buyer 1 questions (#2376) * Remove hint text from buyer 1 questions * Update working situation answer options * Update missed hint text * Update csv tests --- .../sales/questions/buyer1_ethnic_background_arab.rb | 2 +- .../sales/questions/buyer1_ethnic_background_asian.rb | 2 +- .../sales/questions/buyer1_ethnic_background_black.rb | 2 +- .../sales/questions/buyer1_ethnic_background_mixed.rb | 2 +- app/models/form/sales/questions/buyer1_ethnic_group.rb | 2 +- .../form/sales/questions/buyer1_live_in_property.rb | 2 +- .../form/sales/questions/buyer1_working_situation.rb | 4 ++-- .../form/sales/questions/buyer2_working_situation.rb | 2 +- .../form/sales/questions/nationality_all_group.rb | 10 +--------- .../form/sales/questions/person_working_situation.rb | 2 +- .../fixtures/files/sales_logs_csv_export_labels_23.csv | 2 +- ...ales_logs_csv_export_labels_23_during_24_period.csv | 2 +- .../fixtures/files/sales_logs_csv_export_labels_24.csv | 2 +- .../sales/pages/buyer1_ethnic_background_arab_spec.rb | 2 +- .../sales/pages/buyer1_ethnic_background_asian_spec.rb | 2 +- .../sales/pages/buyer1_ethnic_background_black_spec.rb | 2 +- .../sales/pages/buyer1_ethnic_background_mixed_spec.rb | 2 +- .../form/sales/pages/buyer1_ethnic_group_spec.rb | 2 +- .../form/sales/pages/buyer1_live_in_property_spec.rb | 2 +- .../form/sales/pages/buyer1_working_situation_spec.rb | 2 +- .../questions/buyer1_ethnic_background_arab_spec.rb | 2 +- .../questions/buyer1_ethnic_background_asian_spec.rb | 2 +- .../questions/buyer1_ethnic_background_black_spec.rb | 2 +- .../questions/buyer1_ethnic_background_mixed_spec.rb | 2 +- .../form/sales/questions/buyer1_ethnic_group_spec.rb | 2 +- .../sales/questions/buyer1_live_in_property_spec.rb | 2 +- .../sales/questions/buyer1_working_situation_spec.rb | 4 ++-- .../sales/questions/buyer2_working_situation_spec.rb | 2 +- .../form/sales/questions/nationality_all_group_spec.rb | 4 ++-- .../sales/questions/person_working_situation_spec.rb | 2 +- 30 files changed, 33 insertions(+), 41 deletions(-) diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb index e082bd4b4..fbaca62ca 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundArab < ::Form::Question @header = "Which of the following best describes buyer 1’s Arab background?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb index 57bd72584..64cffb507 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundAsian < ::Form::Question @header = "Which of the following best describes buyer 1’s Asian or Asian British background?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb index 258f82675..41d951d71 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundBlack < ::Form::Question @header = "Which of the following best describes buyer 1’s Black, African, Caribbean or Black British background?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb index 9b1b1adf3..42506b70e 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundMixed < ::Form::Question @header = "Which of the following best describes buyer 1’s Mixed or Multiple ethnic groups background?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_group.rb b/app/models/form/sales/questions/buyer1_ethnic_group.rb index 2ce8b95ff..a3eec2474 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_group.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_group.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Buyer1EthnicGroup < ::Form::Question @header = "What is buyer 1’s ethnic group?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_live_in_property.rb b/app/models/form/sales/questions/buyer1_live_in_property.rb index 24fe3a43a..83dff6437 100644 --- a/app/models/form/sales/questions/buyer1_live_in_property.rb +++ b/app/models/form/sales/questions/buyer1_live_in_property.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Buyer1LiveInProperty < ::Form::Question @header = "Will buyer 1 live in the property?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_working_situation.rb b/app/models/form/sales/questions/buyer1_working_situation.rb index 8056f849d..376367624 100644 --- a/app/models/form/sales/questions/buyer1_working_situation.rb +++ b/app/models/form/sales/questions/buyer1_working_situation.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question @header = "Which of these best describes buyer 1's working situation?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it's a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @inferred_check_answers_value = [{ "condition" => { @@ -20,7 +20,7 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question ANSWER_OPTIONS = { "1" => { "value" => "Full-time - 30 hours or more" }, "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work due to long term sick or disability" }, diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb index e5eed38de..54fcb5931 100644 --- a/app/models/form/sales/questions/buyer2_working_situation.rb +++ b/app/models/form/sales/questions/buyer2_working_situation.rb @@ -19,7 +19,7 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question ANSWER_OPTIONS = { "1" => { "value" => "Full-time - 30 hours or more" }, "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work due to long term sick or disability" }, diff --git a/app/models/form/sales/questions/nationality_all_group.rb b/app/models/form/sales/questions/nationality_all_group.rb index f0ab1bc6e..86dcabc88 100644 --- a/app/models/form/sales/questions/nationality_all_group.rb +++ b/app/models/form/sales/questions/nationality_all_group.rb @@ -4,7 +4,7 @@ class Form::Sales::Questions::NationalityAllGroup < ::Form::Question @check_answer_label = "Buyer #{buyer_index}’s nationality" @header = "What is buyer #{buyer_index}’s nationality?" @type = "radio" - @hint_text = buyer_index == 1 ? "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." : "" + @hint_text = "If buyer #{buyer_index} is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." @answer_options = ANSWER_OPTIONS @check_answers_card_number = buyer_index @conditional_for = buyer_index == 1 ? { "nationality_all" => [12] } : { "nationality_all_buyer2" => [12] } @@ -19,14 +19,6 @@ class Form::Sales::Questions::NationalityAllGroup < ::Form::Question "0" => { "value" => "Buyer prefers not to say" }, }.freeze - def hint_text - if @buyer_index == 1 - "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest. If buyer 1 is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." - else - "If buyer 2 is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." - end - end - def question_number if form.start_date.year == 2023 @buyer_index == 1 ? 24 : 32 diff --git a/app/models/form/sales/questions/person_working_situation.rb b/app/models/form/sales/questions/person_working_situation.rb index 2e9ae1edb..fd5506170 100644 --- a/app/models/form/sales/questions/person_working_situation.rb +++ b/app/models/form/sales/questions/person_working_situation.rb @@ -20,7 +20,7 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question { "1" => { "value" => "Full-time - 30 hours or more" }, "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work due to long term sick or disability" }, diff --git a/spec/fixtures/files/sales_logs_csv_export_labels_23.csv b/spec/fixtures/files/sales_logs_csv_export_labels_23.csv index 88a4e6edc..0d8f76aa2 100644 --- a/spec/fixtures/files/sales_logs_csv_export_labels_23.csv +++ b/spec/fixtures/files/sales_logs_csv_export_labels_23.csv @@ -1,2 +1,2 @@ id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,assigned_to,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,beds,proptype,builtype,pcodenk,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,wchair,noint,privacynotice,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,nationalbuy2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 +,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_labels_23_during_24_period.csv b/spec/fixtures/files/sales_logs_csv_export_labels_23_during_24_period.csv index 360e2a49d..8cde997ee 100644 --- a/spec/fixtures/files/sales_logs_csv_export_labels_23_during_24_period.csv +++ b/spec/fixtures/files/sales_logs_csv_export_labels_23_during_24_period.csv @@ -1,2 +1,2 @@ id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,assigned_to,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2024-05-01T00:00:00+01:00,,2023,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 +,completed,,2023-12-08T00:00:00+00:00,2024-05-01T00:00:00+01:00,,2023,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_labels_24.csv b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv index 5e9659290..98889d0e2 100644 --- a/spec/fixtures/files/sales_logs_csv_export_labels_24.csv +++ b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv @@ -1,2 +1,2 @@ id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,assigned_to,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,,2024,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,,DLUHC,DLUHC,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,13,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000003,Barnet,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 +,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,,2024,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,,DLUHC,DLUHC,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,13,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000003,Barnet,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb index b0f024c7a..58f8672be 100644 --- a/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundArab, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb index c097edde7..ad004b5b1 100644 --- a/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundAsian, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb index f3137340d..0192daf72 100644 --- a/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundBlack, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb index 962cc5006..84f3bf761 100644 --- a/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundMixed, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb index 1155c1d30..9560aa272 100644 --- a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb +++ b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb index 646c73ea0..7414d93e1 100644 --- a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb +++ b/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer1LiveInProperty, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/buyer1_working_situation_spec.rb b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb index f98009ab9..f9d833abf 100644 --- a/spec/models/form/sales/pages/buyer1_working_situation_spec.rb +++ b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer1WorkingSituation, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb index c49cbb91a..8cf7d0e81 100644 --- a/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundArab, type: :model let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb index 4eae7d8ac..8603badf7 100644 --- a/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundAsian, type: :model let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb index c0cf78aa8..403d68b78 100644 --- a/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundBlack, type: :model let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb index 4c3f4c0c6..9a0357d60 100644 --- a/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundMixed, type: :model let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb index 02adb5f65..552f45244 100644 --- a/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb +++ b/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer1EthnicGroup, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/sales/questions/buyer1_live_in_property_spec.rb b/spec/models/form/sales/questions/buyer1_live_in_property_spec.rb index 077ac196e..151e4c42d 100644 --- a/spec/models/form/sales/questions/buyer1_live_in_property_spec.rb +++ b/spec/models/form/sales/questions/buyer1_live_in_property_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer1LiveInProperty, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/sales/questions/buyer1_working_situation_spec.rb b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb index 4e8c4431f..908d12a51 100644 --- a/spec/models/form/sales/questions/buyer1_working_situation_spec.rb +++ b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) @@ -35,7 +35,7 @@ RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, type: :model do expect(question.answer_options).to eq({ "1" => { "value" => "Full-time - 30 hours or more" }, "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work due to long term sick or disability" }, diff --git a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb index c0c429b2d..5a27e1b5e 100644 --- a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb +++ b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do expect(question.answer_options).to eq({ "1" => { "value" => "Full-time - 30 hours or more" }, "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work due to long term sick or disability" }, diff --git a/spec/models/form/sales/questions/nationality_all_group_spec.rb b/spec/models/form/sales/questions/nationality_all_group_spec.rb index 6625f9353..719a5f13e 100644 --- a/spec/models/form/sales/questions/nationality_all_group_spec.rb +++ b/spec/models/form/sales/questions/nationality_all_group_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::NationalityAllGroup, type: :model do let(:buyer_index) { 1 } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to be page @@ -47,7 +47,7 @@ RSpec.describe Form::Sales::Questions::NationalityAllGroup, type: :model do end it "has the correct hint" do - expect(question.hint_text).to eq "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest. If buyer 1 is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." + expect(question.hint_text).to eq "If buyer 1 is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." end it "has the correct header" do diff --git a/spec/models/form/sales/questions/person_working_situation_spec.rb b/spec/models/form/sales/questions/person_working_situation_spec.rb index 30974fba4..29641dd05 100644 --- a/spec/models/form/sales/questions/person_working_situation_spec.rb +++ b/spec/models/form/sales/questions/person_working_situation_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model do expect(question.answer_options).to eq({ "1" => { "value" => "Full-time - 30 hours or more" }, "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work due to long term sick or disability" }, From eea2aead2c9d0b549f75c39224409518c0bf47df Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:26:07 +0100 Subject: [PATCH 10/12] CLDC-3397 Remove hint text from lead tenant questions (#2378) * Remove hint text from lead tenant questions * Update working situation answer options --- app/models/form/lettings/questions/ethnic_arab.rb | 2 +- app/models/form/lettings/questions/ethnic_asian.rb | 2 +- app/models/form/lettings/questions/ethnic_black.rb | 2 +- app/models/form/lettings/questions/ethnic_group.rb | 2 +- app/models/form/lettings/questions/ethnic_mixed.rb | 2 +- app/models/form/lettings/questions/nationality_all_group.rb | 2 +- .../form/lettings/questions/person_working_situation.rb | 2 +- app/models/form/lettings/questions/working_situation1.rb | 4 ++-- spec/models/form/lettings/questions/gender_identity1_spec.rb | 2 +- .../form/lettings/questions/nationality_all_group_spec.rb | 2 +- .../form/lettings/questions/person_working_situation_spec.rb | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models/form/lettings/questions/ethnic_arab.rb b/app/models/form/lettings/questions/ethnic_arab.rb index 929b680b0..380de645f 100644 --- a/app/models/form/lettings/questions/ethnic_arab.rb +++ b/app/models/form/lettings/questions/ethnic_arab.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::EthnicArab < ::Form::Question @header = "Which of the following best describes the lead tenant’s Arab background?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_asian.rb b/app/models/form/lettings/questions/ethnic_asian.rb index 4e0ec376e..33002533b 100644 --- a/app/models/form/lettings/questions/ethnic_asian.rb +++ b/app/models/form/lettings/questions/ethnic_asian.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::EthnicAsian < ::Form::Question @header = "Which of the following best describes the lead tenant’s Asian or Asian British background?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_black.rb b/app/models/form/lettings/questions/ethnic_black.rb index 4b336b819..16a886eb3 100644 --- a/app/models/form/lettings/questions/ethnic_black.rb +++ b/app/models/form/lettings/questions/ethnic_black.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::EthnicBlack < ::Form::Question @header = "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_group.rb b/app/models/form/lettings/questions/ethnic_group.rb index fdf80e03d..c3093d48e 100644 --- a/app/models/form/lettings/questions/ethnic_group.rb +++ b/app/models/form/lettings/questions/ethnic_group.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::EthnicGroup < ::Form::Question @header = "What is the lead tenant’s ethnic group?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_mixed.rb b/app/models/form/lettings/questions/ethnic_mixed.rb index 3016abee1..cd7d7a4bb 100644 --- a/app/models/form/lettings/questions/ethnic_mixed.rb +++ b/app/models/form/lettings/questions/ethnic_mixed.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::EthnicMixed < ::Form::Question @header = "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/nationality_all_group.rb b/app/models/form/lettings/questions/nationality_all_group.rb index a1d6cd843..53534851b 100644 --- a/app/models/form/lettings/questions/nationality_all_group.rb +++ b/app/models/form/lettings/questions/nationality_all_group.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::NationalityAllGroup < ::Form::Question @header = "What is the nationality of the lead tenant?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest. If the lead tenant is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the tenant should decide which country to enter." + @hint_text = "If the lead tenant is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the tenant should decide which country to enter." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @conditional_for = { "nationality_all" => [12] } diff --git a/app/models/form/lettings/questions/person_working_situation.rb b/app/models/form/lettings/questions/person_working_situation.rb index 974bb01b8..3d223a943 100644 --- a/app/models/form/lettings/questions/person_working_situation.rb +++ b/app/models/form/lettings/questions/person_working_situation.rb @@ -16,7 +16,7 @@ class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question { "1" => { "value" => "Full-time – 30 hours or more" }, "2" => { "value" => "Part-time – Less than 30 hours" }, "7" => { "value" => "Full-time student" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work because of long term sick or disability" }, diff --git a/app/models/form/lettings/questions/working_situation1.rb b/app/models/form/lettings/questions/working_situation1.rb index cbd1b9a24..b2facdf01 100644 --- a/app/models/form/lettings/questions/working_situation1.rb +++ b/app/models/form/lettings/questions/working_situation1.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question @header = "Which of these best describes the lead tenant’s working situation?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end @@ -15,7 +15,7 @@ class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question "1" => { "value" => "Full-time – 30 hours or more" }, "2" => { "value" => "Part-time – Less than 30 hours" }, "7" => { "value" => "Full-time student" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, "8" => { "value" => "Unable to work because of long term sick or disability" }, diff --git a/spec/models/form/lettings/questions/gender_identity1_spec.rb b/spec/models/form/lettings/questions/gender_identity1_spec.rb index 8072149e0..67c7d54c8 100644 --- a/spec/models/form/lettings/questions/gender_identity1_spec.rb +++ b/spec/models/form/lettings/questions/gender_identity1_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Form::Lettings::Questions::GenderIdentity1, type: :model do let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) } before do allow(page).to receive(:subsection).and_return(subsection) diff --git a/spec/models/form/lettings/questions/nationality_all_group_spec.rb b/spec/models/form/lettings/questions/nationality_all_group_spec.rb index 56fc50257..5be7f13a5 100644 --- a/spec/models/form/lettings/questions/nationality_all_group_spec.rb +++ b/spec/models/form/lettings/questions/nationality_all_group_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Form::Lettings::Questions::NationalityAllGroup, type: :model do end it "has the correct hint_text" do - expect(question.hint_text).to eq("The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest. If the lead tenant is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the tenant should decide which country to enter.") + expect(question.hint_text).to eq("If the lead tenant is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the tenant should decide which country to enter.") end it "has the correct answer_options" do diff --git a/spec/models/form/lettings/questions/person_working_situation_spec.rb b/spec/models/form/lettings/questions/person_working_situation_spec.rb index 3e564823e..03cd60019 100644 --- a/spec/models/form/lettings/questions/person_working_situation_spec.rb +++ b/spec/models/form/lettings/questions/person_working_situation_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Form::Lettings::Questions::PersonWorkingSituation, type: :model d "1" => { "value" => "Full-time – 30 hours or more" }, "10" => { "value" => "Person prefers not to say" }, "2" => { "value" => "Part-time – Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, + "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "5" => { "value" => "Retired" }, "6" => { "value" => "Not seeking work" }, From 1f1df3e77fc443fa545b1fa310210c3a1f63db74 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:34:25 +0100 Subject: [PATCH 11/12] feat: add new period option (#2375) --- app/models/form/lettings/questions/period.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/form/lettings/questions/period.rb b/app/models/form/lettings/questions/period.rb index 3155207b8..35b8a85dc 100644 --- a/app/models/form/lettings/questions/period.rb +++ b/app/models/form/lettings/questions/period.rb @@ -20,6 +20,7 @@ class Form::Lettings::Questions::Period < ::Form::Question "7" => { "value" => "Weekly for 48 weeks" }, "6" => { "value" => "Weekly for 49 weeks" }, "5" => { "value" => "Weekly for 50 weeks" }, + "11" => { "value" => "Weekly for 51 weeks" }, "1" => { "value" => "Weekly for 52 weeks" }, "10" => { "value" => "Weekly for 53 weeks" }, }.freeze From 452066a37cfce13de348581868626c90ca432353 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Wed, 17 Apr 2024 11:06:16 +0100 Subject: [PATCH 12/12] CLDC-2652 Use new env vars (#2379) * feat: use new env var names * feat: update names * feat: update test * feat: update test --- app/jobs/create_addresses_csv_job.rb | 2 +- app/jobs/data_export_xml_job.rb | 2 +- app/jobs/email_csv_job.rb | 2 +- app/jobs/email_missing_addresses_csv_job.rb | 2 +- app/jobs/scheme_email_csv_job.rb | 2 +- app/models/forms/bulk_upload_lettings/upload_your_file.rb | 2 +- app/models/forms/bulk_upload_sales/upload_your_file.rb | 2 +- .../bulk_update_from_csv/update_locations_from_csv_service.rb | 2 +- .../bulk_update_from_csv/update_schemes_from_csv_service.rb | 2 +- app/services/bulk_upload/downloader.rb | 2 +- lib/tasks/data_export.rake | 2 +- lib/tasks/import_address_from_csv.rake | 4 ++-- spec/lib/tasks/correct_address_from_csv_spec.rb | 2 +- spec/lib/tasks/data_export_spec.rb | 4 ++-- spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/jobs/create_addresses_csv_job.rb b/app/jobs/create_addresses_csv_job.rb index ef83ee746..3a6352f29 100644 --- a/app/jobs/create_addresses_csv_job.rb +++ b/app/jobs/create_addresses_csv_job.rb @@ -14,7 +14,7 @@ class CreateAddressesCsvJob < ApplicationJob filename = "#{['sales-logs-addresses', organisation.name, Time.zone.now].compact.join('-')}.csv" end - storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) Rails.logger.info("Created addresses file: #{filename}") diff --git a/app/jobs/data_export_xml_job.rb b/app/jobs/data_export_xml_job.rb index 60633d21a..8b825f6df 100644 --- a/app/jobs/data_export_xml_job.rb +++ b/app/jobs/data_export_xml_job.rb @@ -2,7 +2,7 @@ class DataExportXmlJob < ApplicationJob queue_as :default def perform(full_update: false) - storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_PAAS_INSTANCE"]) + storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_BUCKET"]) export_service = Exports::LettingsLogExportService.new(storage_service) export_service.export_xml_lettings_logs(full_update:) diff --git a/app/jobs/email_csv_job.rb b/app/jobs/email_csv_job.rb index 7658cf755..3166bb729 100644 --- a/app/jobs/email_csv_job.rb +++ b/app/jobs/email_csv_job.rb @@ -20,7 +20,7 @@ class EmailCsvJob < ApplicationJob filename = "#{[log_type, 'logs', organisation&.name, Time.zone.now].compact.join('-')}.csv" - storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) diff --git a/app/jobs/email_missing_addresses_csv_job.rb b/app/jobs/email_missing_addresses_csv_job.rb index d8b756b20..4f2d1a3fb 100644 --- a/app/jobs/email_missing_addresses_csv_job.rb +++ b/app/jobs/email_missing_addresses_csv_job.rb @@ -18,7 +18,7 @@ class EmailMissingAddressesCsvJob < ApplicationJob email_method = :send_missing_sales_addresses_csv_download_mail end - storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) diff --git a/app/jobs/scheme_email_csv_job.rb b/app/jobs/scheme_email_csv_job.rb index 9c3060cb9..44d016a90 100644 --- a/app/jobs/scheme_email_csv_job.rb +++ b/app/jobs/scheme_email_csv_job.rb @@ -23,7 +23,7 @@ class SchemeEmailCsvJob < ApplicationJob filename = "#{['schemes-and-locations', organisation&.name, Time.zone.now].compact.join('-')}.csv" end - storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) diff --git a/app/models/forms/bulk_upload_lettings/upload_your_file.rb b/app/models/forms/bulk_upload_lettings/upload_your_file.rb index 319bfc636..9ccec7622 100644 --- a/app/models/forms/bulk_upload_lettings/upload_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/upload_your_file.rb @@ -56,7 +56,7 @@ module Forms def storage_service @storage_service ||= if upload_enabled? - Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) else Storage::LocalDiskService.new end diff --git a/app/models/forms/bulk_upload_sales/upload_your_file.rb b/app/models/forms/bulk_upload_sales/upload_your_file.rb index 37199ab92..de650c831 100644 --- a/app/models/forms/bulk_upload_sales/upload_your_file.rb +++ b/app/models/forms/bulk_upload_sales/upload_your_file.rb @@ -49,7 +49,7 @@ module Forms def storage_service @storage_service ||= if FeatureToggle.upload_enabled? - Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) else Storage::LocalDiskService.new end diff --git a/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb b/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb index 4a2577fc3..56a8da6d1 100644 --- a/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb +++ b/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb @@ -5,7 +5,7 @@ class BulkUpdateFromCsv::UpdateLocationsFromCsvService end def call - s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) original_locations_csv = csv_from_path(@original_file_name, s3_service) updated_locations_csv = csv_from_path(@updated_file_name, s3_service) diff --git a/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb b/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb index bb4a0c261..ff9a42494 100644 --- a/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb +++ b/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb @@ -5,7 +5,7 @@ class BulkUpdateFromCsv::UpdateSchemesFromCsvService end def call - s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) original_schemes_csv = csv_from_path(@original_file_name, s3_service) updated_schemes_csv = csv_from_path(@updated_file_name, s3_service) diff --git a/app/services/bulk_upload/downloader.rb b/app/services/bulk_upload/downloader.rb index 452aed689..a7dc9aad0 100644 --- a/app/services/bulk_upload/downloader.rb +++ b/app/services/bulk_upload/downloader.rb @@ -37,7 +37,7 @@ private end def s3_storage_service - Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) end def local_disk_storage_service diff --git a/lib/tasks/data_export.rake b/lib/tasks/data_export.rake index e62d6ee65..719462cb4 100644 --- a/lib/tasks/data_export.rake +++ b/lib/tasks/data_export.rake @@ -9,7 +9,7 @@ namespace :core do desc "Export all data XMLs for import into Central Data System (CDS)" task :full_data_export_xml, %i[year] => :environment do |_task, args| collection_year = args[:year].present? ? args[:year].to_i : nil - storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_PAAS_INSTANCE"]) + storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_BUCKET"]) export_service = Exports::LettingsLogExportService.new(storage_service) export_service.export_xml_lettings_logs(full_update: true, collection_year:) diff --git a/lib/tasks/import_address_from_csv.rake b/lib/tasks/import_address_from_csv.rake index e6c44872b..6b6d6e1ba 100644 --- a/lib/tasks/import_address_from_csv.rake +++ b/lib/tasks/import_address_from_csv.rake @@ -5,7 +5,7 @@ namespace :data_import do raise "Usage: rake data_import:import_lettings_addresses_from_csv['csv_file_name']" if file_name.blank? - s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) file_io = s3_service.get_file_io(file_name) file_io.set_encoding_by_bom addresses_csv = CSV.parse(file_io, headers: true) @@ -69,7 +69,7 @@ namespace :data_import do raise "Usage: rake data_import:import_sales_addresses_from_csv['csv_file_name']" if file_name.blank? - s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) + s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"]) file_io = s3_service.get_file_io(file_name) file_io.set_encoding_by_bom addresses_csv = CSV.parse(file_io, headers: true) diff --git a/spec/lib/tasks/correct_address_from_csv_spec.rb b/spec/lib/tasks/correct_address_from_csv_spec.rb index 26b048e5f..22b504eaf 100644 --- a/spec/lib/tasks/correct_address_from_csv_spec.rb +++ b/spec/lib/tasks/correct_address_from_csv_spec.rb @@ -15,7 +15,7 @@ RSpec.describe "data_import" do allow(Storage::S3Service).to receive(:new).and_return(storage_service) allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service) allow(ENV).to receive(:[]) - allow(ENV).to receive(:[]).with("CSV_DOWNLOAD_PAAS_INSTANCE").and_return(instance_name) + allow(ENV).to receive(:[]).with("BULK_UPLOAD_BUCKET").and_return(instance_name) allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return("dummy") WebMock.stub_request(:get, /api\.postcodes\.io/) diff --git a/spec/lib/tasks/data_export_spec.rb b/spec/lib/tasks/data_export_spec.rb index 8e98309a8..afb99f872 100644 --- a/spec/lib/tasks/data_export_spec.rb +++ b/spec/lib/tasks/data_export_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" require "rake" describe "rake core:data_export", type: task do - let(:export_instance) { "export_instance" } + let(:export_bucket) { "export_bucket" } let(:storage_service) { instance_double(Storage::S3Service) } let(:export_service) { instance_double(Exports::LettingsLogExportService) } @@ -14,7 +14,7 @@ describe "rake core:data_export", type: task do allow(Storage::S3Service).to receive(:new).and_return(storage_service) allow(Exports::LettingsLogExportService).to receive(:new).and_return(export_service) allow(ENV).to receive(:[]) - allow(ENV).to receive(:[]).with("EXPORT_PAAS_INSTANCE").and_return(export_instance) + allow(ENV).to receive(:[]).with("EXPORT_BUCKET").and_return(export_bucket) end context "when exporting lettings logs with no parameters" do diff --git a/spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb b/spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb index e3bdc6831..ba87cc15a 100644 --- a/spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb +++ b/spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb @@ -22,7 +22,7 @@ RSpec.describe "bulk_update" do allow(Storage::S3Service).to receive(:new).and_return(storage_service) allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service) allow(ENV).to receive(:[]) - allow(ENV).to receive(:[]).with("CSV_DOWNLOAD_PAAS_INSTANCE").and_return(instance_name) + allow(ENV).to receive(:[]).with("BULK_UPLOAD_BUCKET").and_return(instance_name) WebMock.stub_request(:get, /api\.postcodes\.io/) .to_return(status: 200, body: "{\"status\":404,\"error\":\"Postcode not found\"}", headers: {})