Browse Source

Merge branch 'main' into CLDC-2041-multiple-errors

pull/2840/head
kosiakkatrina 8 months ago committed by GitHub
parent
commit
f5cb70dd1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Gemfile
  2. 4
      Gemfile.lock
  3. 2
      app/controllers/lettings_logs_controller.rb
  4. 4
      app/controllers/organisations_controller.rb
  5. 2
      app/controllers/sales_logs_controller.rb
  6. 4
      app/models/validations/soft_validations.rb
  7. 6
      app/services/exports/organisation_export_service.rb
  8. 1
      app/services/exports/user_export_service.rb
  9. 16
      app/services/feature_toggle.rb
  10. 2
      app/views/locations/check_answers.html.erb
  11. 2
      app/views/locations/show.html.erb
  12. 2
      app/views/schemes/check_answers.html.erb
  13. 2
      app/views/schemes/show.html.erb
  14. 2
      app/views/users/show.html.erb
  15. 4
      config/locales/validations/sales/2024/bulk_upload.en.yml
  16. 2
      package.json
  17. 2
      spec/fixtures/exports/user.xml
  18. 28
      spec/models/validations/soft_validations_spec.rb
  19. 2
      spec/services/exports/organisation_export_service_spec.rb
  20. 2
      spec/services/exports/user_export_service_spec.rb
  21. 1649
      yarn.lock

2
Gemfile

@ -90,7 +90,7 @@ group :development do
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem "erb_lint", require: false
gem "rack-mini-profiler", "~> 2.0"
gem "rack-mini-profiler", "~> 3.3.0"
gem "rubocop-govuk", "4.3.0", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false

4
Gemfile.lock

@ -340,7 +340,7 @@ GEM
rack (3.1.8)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-mini-profiler (2.3.4)
rack-mini-profiler (3.3.1)
rack (>= 1.2.0)
rack-session (2.0.0)
rack (>= 3.0.0)
@ -581,7 +581,7 @@ DEPENDENCIES
pundit
rack (>= 2.2.6.3)
rack-attack
rack-mini-profiler (~> 2.0)
rack-mini-profiler (~> 3.3.0)
rails (~> 7.2.2)
rails_admin (~> 3.1)
redcarpet (~> 3.6)

2
app/controllers/lettings_logs_controller.rb

@ -22,7 +22,7 @@ class LettingsLogsController < LogsController
@total_count = all_logs.size
@unresolved_count = all_logs.unresolved.assigned_to(current_user).count
@filter_type = "lettings_logs"
@duplicate_sets_count = FeatureToggle.duplicate_summary_enabled? && !current_user.support? ? duplicate_sets_count(current_user, current_user.organisation) : 0
@duplicate_sets_count = !current_user.support? ? duplicate_sets_count(current_user, current_user.organisation) : 0
render "logs/index"
end

4
app/controllers/organisations_controller.rb

@ -186,7 +186,7 @@ class OrganisationsController < ApplicationController
@total_count = organisation_logs.size
@log_type = :lettings
@filter_type = "lettings_logs"
@duplicate_sets_count = FeatureToggle.duplicate_summary_enabled? ? duplicate_sets_count(current_user, @organisation) : 0
@duplicate_sets_count = duplicate_sets_count(current_user, @organisation)
render "logs", layout: "application"
end
@ -218,7 +218,7 @@ class OrganisationsController < ApplicationController
@total_count = organisation_logs.size
@log_type = :sales
@filter_type = "sales_logs"
@duplicate_sets_count = FeatureToggle.duplicate_summary_enabled? ? duplicate_sets_count(current_user, @organisation) : 0
@duplicate_sets_count = duplicate_sets_count(current_user, @organisation)
render "logs", layout: "application"
end

2
app/controllers/sales_logs_controller.rb

@ -24,7 +24,7 @@ class SalesLogsController < LogsController
@searched = search_term.presence
@total_count = all_logs.size
@filter_type = "sales_logs"
@duplicate_sets_count = FeatureToggle.duplicate_summary_enabled? && !current_user.support? ? duplicate_sets_count(current_user, current_user.organisation) : 0
@duplicate_sets_count = !current_user.support? ? duplicate_sets_count(current_user, current_user.organisation) : 0
render "logs/index"
end

4
app/models/validations/soft_validations.rb

@ -84,6 +84,8 @@ module Validations::SoftValidations
end
def all_tenants_age_and_gender_information_completed?
return false if hhmemb.present? && hhmemb > 8
person_count = hhmemb || 8
(1..person_count).all? do |n|
@ -235,6 +237,8 @@ private
end
def all_male_tenants_in_the_household?
return false if hhmemb.present? && hhmemb > 8
person_count = hhmemb || 8
(1..person_count).all? do |n|

6
app/services/exports/organisation_export_service.rb

@ -56,11 +56,13 @@ module Exports
def apply_cds_transformation(organisation)
attribute_hash = organisation.attributes
attribute_hash["deleted_at"] = organisation.discarded_at
attribute_hash["deleted_at"] = organisation.discarded_at&.iso8601
attribute_hash["dsa_signed"] = organisation.data_protection_confirmed?
attribute_hash["dsa_signed_at"] = organisation.data_protection_confirmation&.signed_at
attribute_hash["dsa_signed_at"] = organisation.data_protection_confirmation&.signed_at&.iso8601
attribute_hash["dpo_email"] = organisation.data_protection_confirmation&.data_protection_officer_email
attribute_hash["provider_type"] = organisation.provider_type_before_type_cast
attribute_hash["merge_date"] = organisation.merge_date&.iso8601
attribute_hash["available_from"] = organisation.available_from&.iso8601
attribute_hash["profit_status"] = nil # will need update when we add the field to the org
attribute_hash["group"] = nil # will need update when we add the field to the org

1
app/services/exports/user_export_service.rb

@ -60,6 +60,7 @@ module Exports
attribute_hash["organisation_name"] = user.organisation.name
attribute_hash["active"] = user.active?
attribute_hash["phone"] = [user.phone, user.phone_extension].compact.join(" ")
attribute_hash["last_sign_in_at"] = user.last_sign_in_at&.iso8601
attribute_hash
end
end

16
app/services/feature_toggle.rb

@ -11,10 +11,6 @@ class FeatureToggle
!Rails.env.development?
end
def self.duplicate_summary_enabled?
true
end
def self.service_unavailable?
false
end
@ -23,18 +19,6 @@ class FeatureToggle
false
end
def self.delete_scheme_enabled?
true
end
def self.delete_location_enabled?
true
end
def self.delete_user_enabled?
true
end
def self.local_storage?
Rails.env.development?
end

2
app/views/locations/check_answers.html.erb

@ -42,7 +42,7 @@
<% if LocationPolicy.new(current_user, @location).create? %>
<div class="govuk-button-group">
<%= govuk_button_to "Save and return to locations", scheme_location_confirm_path(@scheme, @location, route: params[:route]), method: :patch %>
<% if LocationPolicy.new(current_user, @location).delete? && FeatureToggle.delete_location_enabled? %>
<% if LocationPolicy.new(current_user, @location).delete? %>
<%= delete_location_link(@location) %>
<% end %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>

2
app/views/locations/show.html.erb

@ -51,6 +51,6 @@
<%= toggle_location_link(@location) %>
<% end %>
<% if LocationPolicy.new(current_user, @location).delete? && FeatureToggle.delete_location_enabled? %>
<% if LocationPolicy.new(current_user, @location).delete? %>
<%= delete_location_link(@location) %>
<% end %>

2
app/views/schemes/check_answers.html.erb

@ -24,7 +24,7 @@
<%= f.govuk_submit button_label %>
<% end %>
<% if SchemePolicy.new(current_user, @scheme).delete? && FeatureToggle.delete_scheme_enabled? %>
<% if SchemePolicy.new(current_user, @scheme).delete? %>
<%= delete_scheme_link(@scheme) %>
<% end %>
<% end %>

2
app/views/schemes/show.html.erb

@ -56,6 +56,6 @@
<%= toggle_scheme_link(@scheme) %>
<% end %>
<% if SchemePolicy.new(current_user, @scheme).delete? && FeatureToggle.delete_scheme_enabled? %>
<% if SchemePolicy.new(current_user, @scheme).delete? %>
<%= delete_scheme_link(@scheme) %>
<% end %>

2
app/views/users/show.html.erb

@ -157,7 +157,7 @@
</span>
<% end %>
<% end %>
<% if UserPolicy.new(current_user, @user).delete? && FeatureToggle.delete_user_enabled? %>
<% if UserPolicy.new(current_user, @user).delete? %>
<%= delete_user_link(@user) %>
<% end %>
</div>

4
config/locales/validations/sales/2024/bulk_upload.en.yml

@ -18,8 +18,8 @@ en:
owning_organisation:
not_found: "The owning organisation code is incorrect."
not_stock_owner: "The owning organisation code provided is for an organisation that does not own stock."
not_permitted:
support: "This owning organisation is not affiliated with %(name)."
not_permitted:
support: "This owning organisation is not affiliated with %{name}."
not_support: "You do not have permission to add logs for this owning organisation."
assigned_to:
not_found: "User with the specified email could not be found."

2
package.json

@ -11,7 +11,7 @@
"@hotwired/stimulus": "^3.0.0",
"@stimulus/polyfills": "^2.0.0",
"@webcomponents/webcomponentsjs": "^2.6.0",
"@x-govuk/govuk-prototype-components": "^3.0.1",
"@x-govuk/govuk-prototype-components": "^3.0.9",
"accessible-autocomplete": "^2.0.3",
"babel-loader": "^8.2.3",
"babel-plugin-macros": "^3.1.0",

2
spec/fixtures/exports/user.xml vendored

@ -6,7 +6,7 @@
<name>Danny Rojas</name>
<organisation_id>{organisation_id}</organisation_id>
<sign_in_count>5</sign_in_count>
<last_sign_in_at/>
<last_sign_in_at>2022-03-03T00:00:00+00:00</last_sign_in_at>
<role>data_provider</role>
<phone>1234512345123 123</phone>
<is_dpo>false</is_dpo>

28
spec/models/validations/soft_validations_spec.rb

@ -174,6 +174,20 @@ RSpec.describe Validations::SoftValidations do
end
end
context "when all tenants are male and household members are over 8" do
it "does not show the interruption screen" do
(1..8).each do |n|
record.send("sex#{n}=", "M")
record.send("age#{n}=", 30)
record.send("age#{n}_known=", 0)
record.send("details_known_#{n}=", 0) unless n == 1
end
record.preg_occ = 1
record.hhmemb = 9
expect(record.all_male_tenants_in_a_pregnant_household?).to be false
end
end
context "when female tenants are under 16" do
it "shows the interruption screen" do
record.age2 = 14
@ -219,6 +233,20 @@ RSpec.describe Validations::SoftValidations do
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be false
end
end
context "when number of household members is over 8" do
it "does not show the interruption screen" do
(1..8).each do |n|
record.send("sex#{n}=", "F")
record.send("age#{n}=", 50)
record.send("age#{n}_known=", 0)
record.send("details_known_#{n}=", 0) unless n == 1
end
record.preg_occ = 1
record.hhmemb = 9
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be false
end
end
end
describe "major repairs date soft validations" do

2
spec/services/exports/organisation_export_service_spec.rb

@ -17,7 +17,7 @@ RSpec.describe Exports::OrganisationExportService do
def replace_entity_ids(organisation, export_template)
export_template.sub!(/\{id\}/, organisation["id"].to_s)
export_template.sub!(/\{name\}/, organisation["name"])
export_template.sub!(/\{dsa_signed_at\}/, organisation.data_protection_confirmation&.signed_at.to_s)
export_template.sub!(/\{dsa_signed_at\}/, organisation.data_protection_confirmation&.signed_at&.iso8601)
export_template.sub!(/\{dpo_email\}/, organisation.data_protection_confirmation&.data_protection_officer_email)
end

2
spec/services/exports/user_export_service_spec.rb

@ -43,7 +43,7 @@ RSpec.describe Exports::UserExportService do
end
context "and one user is available for export" do
let!(:user) { create(:user, organisation:, name: "Danny Rojas", phone_extension: "123") }
let!(:user) { create(:user, organisation:, name: "Danny Rojas", phone_extension: "123", last_sign_in_at: Time.zone.local(2022, 3, 3)) }
it "generates a ZIP export file with the expected filename" do
expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args)

1649
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save