Browse Source

Merge branch 'main' into CLDC-2571-create-absorbed-relationship

# Conflicts:
#	db/schema.rb
pull/1789/head
natdeanlewissoftwire 3 years ago
parent
commit
be6ed8fbb7
  1. 4
      .github/workflows/production_pipeline.yml
  2. 6
      .github/workflows/staging_pipeline.yml
  3. 2
      .nvmrc
  4. 2
      .ruby-version
  5. 4
      Dockerfile
  6. 2
      Dockerfile_dev
  7. 2
      Gemfile
  8. 2
      Gemfile.lock
  9. 10
      app/components/bulk_upload_error_row_component.html.erb
  10. 8
      app/components/check_answers_summary_list_card_component.html.erb
  11. 2
      app/frontend/application.js
  12. 2
      app/frontend/controllers/govukfrontend_controller.js
  13. 11
      app/helpers/organisation_helper.rb
  14. 40
      app/helpers/organisations_helper.rb
  15. 2
      app/helpers/tag_helper.rb
  16. 23
      app/models/organisation.rb
  17. 7
      app/models/user.rb
  18. 2
      app/services/exports/lettings_log_export_constants.rb
  19. 4
      app/views/form/_interruption_screen_question.html.erb
  20. 8
      app/views/form/review.html.erb
  21. 4
      app/views/organisations/_organisation_list.html.erb
  22. 5
      app/views/organisations/edit.html.erb
  23. 3
      app/views/organisations/show.html.erb
  24. 2
      config/cloud_foundry/review_manifest.yml
  25. 1
      config/locales/en.yml
  26. 5
      db/migrate/20230718151955_add_merge_date_to_organisation.rb
  27. 6
      db/schema.rb
  28. 4
      docs/setup.md
  29. 2
      manifest.yml
  30. 6
      package.json
  31. 6
      spec/features/form/check_answers_page_lettings_logs_spec.rb
  32. 30
      spec/features/form/check_answers_page_sales_logs_spec.rb
  33. 2
      spec/fixtures/exports/general_needs_log.xml
  34. 2
      spec/fixtures/exports/general_needs_log_23_24.xml
  35. 2
      spec/fixtures/exports/supported_housing_logs.xml
  36. 23
      spec/helpers/organisations_helper_spec.rb
  37. 1
      spec/helpers/tag_helper_spec.rb
  38. 19
      spec/models/organisation_spec.rb
  39. 10
      spec/models/user_spec.rb
  40. 8
      spec/requests/organisations_controller_spec.rb
  41. 2
      spec/views/bulk_upload_lettings_results/show.html.erb_spec.rb
  42. 2
      spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb
  43. 2
      spec/views/bulk_upload_sales_results/show.html.erb_spec.rb
  44. 2
      spec/views/bulk_upload_sales_results/summary.html.erb_spec.rb
  45. 2
      webpack.config.js
  46. 2138
      yarn.lock

4
.github/workflows/production_pipeline.yml

@ -68,7 +68,7 @@ jobs:
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16
node-version: 18
- name: Create database
run: |
@ -127,7 +127,7 @@ jobs:
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16
node-version: 18
- name: Create database
run: |

6
.github/workflows/staging_pipeline.yml

@ -60,7 +60,7 @@ jobs:
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16
node-version: 18
- name: Create database
run: |
@ -118,7 +118,7 @@ jobs:
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16
node-version: 18
- name: Create database
run: |
@ -149,7 +149,7 @@ jobs:
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16
node-version: 18
- name: Install packages and symlink local dependencies
run: |

2
.nvmrc

@ -1 +1 @@
16
18

2
.ruby-version

@ -1 +1 @@
3.1.2
3.1.4

4
Dockerfile

@ -1,5 +1,5 @@
# Build compilation image
FROM ruby:3.1.2-alpine as builder
FROM ruby:3.1.4-alpine as builder
# The application runs from /app
WORKDIR /app
@ -45,7 +45,7 @@ RUN rm -rf node_modules log tmp && \
find /usr/local/bundle/gems -name "*.html" -delete
# Build runtime image
FROM ruby:3.1.2-alpine as production
FROM ruby:3.1.4-alpine as production
# The application runs from /app
WORKDIR /app

2
Dockerfile_dev

@ -1,5 +1,5 @@
# Build compilation image
FROM ruby:3.1.2-alpine
FROM ruby:3.1.4-alpine
# The application runs from /app
WORKDIR /app

2
Gemfile

@ -3,7 +3,7 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.1.2"
ruby "3.1.4"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem "rails", "~> 7.0.2"

2
Gemfile.lock

@ -501,7 +501,7 @@ DEPENDENCIES
webmock
RUBY VERSION
ruby 3.1.2p20
ruby 3.1.4p223
BUNDLED WITH
2.3.14

10
app/components/bulk_upload_error_row_component.html.erb

@ -1,13 +1,13 @@
<div class="x-govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__header">
<div class="govuk-summary-card govuk-!-margin-bottom-6">
<div class="govuk-summary-card__title-wrapper">
<% if lettings? %>
<h3 class="x-govuk-summary-card__title"><strong>Row <%= row %></strong> <%= tenant_code_html %> <%= property_ref_html %></h3>
<h3 class="govuk-summary-card__title"><strong>Row <%= row %></strong> <%= tenant_code_html %> <%= property_ref_html %></h3>
<% else %>
<h3 class="x-govuk-summary-card__title"><strong>Row <%= row %></strong> <%= purchaser_code_html %></h3>
<h3 class="govuk-summary-card__title"><strong>Row <%= row %></strong> <%= purchaser_code_html %></h3>
<% end %>
</div>
<div class="x-govuk-summary-card__body">
<div class="govuk-summary-card__content">
<%= govuk_table do |table| %>
<% table.head do |head| %>
<% head.row do |row| %>

8
app/components/check_answers_summary_list_card_component.html.erb

@ -1,12 +1,12 @@
<% if applicable_questions.first %>
<div class="x-govuk-summary-card govuk-!-margin-bottom-6">
<div class="govuk-summary-card govuk-!-margin-bottom-6">
<% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %>
<div class="x-govuk-summary-card__header">
<h3 class="x-govuk-summary-card__title"><%= check_answers_card_title(applicable_questions.first) %></h3>
<div class="govuk-summary-card__title-wrapper">
<h3 class="govuk-summary-card__title"><%= check_answers_card_title(applicable_questions.first) %></h3>
</div>
<% end %>
<div class="x-govuk-summary-card__body">
<div class="govuk-summary-card__content">
<%= govuk_summary_list do |summary_list| %>
<% applicable_questions.each do |question| %>
<% summary_list.row do |row| %>

2
app/frontend/application.js

@ -13,7 +13,7 @@ import 'regenerator-runtime/runtime'
//
import { initAll as GOVUKFrontend } from 'govuk-frontend'
import { initAll as GOVUKPrototypeComponents } from 'govuk-prototype-components'
import { initAll as GOVUKPrototypeComponents } from '@x-govuk/govuk-prototype-components'
import './controllers'
import './cookie-banner'
import './styles/application.scss'

2
app/frontend/controllers/govukfrontend_controller.js

@ -1,5 +1,5 @@
import { initAll as GOVUKFrontend } from 'govuk-frontend'
import { initAll as GOVUKPrototypeComponents } from 'govuk-prototype-components'
import { initAll as GOVUKPrototypeComponents } from '@x-govuk/govuk-prototype-components'
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {

11
app/helpers/organisation_helper.rb

@ -1,11 +0,0 @@
module OrganisationHelper
def organisation_header(path, user, current_organisation)
if path == "/organisations"
"Organisations"
elsif user.organisation_id == current_organisation.id
"Your organisation"
else
current_organisation.name
end
end
end

40
app/helpers/organisations_helper.rb

@ -0,0 +1,40 @@
module OrganisationsHelper
def organisation_header(path, user, current_organisation)
if path == "/organisations"
"Organisations"
elsif user.organisation_id == current_organisation.id
"Your organisation"
else
current_organisation.name
end
end
def display_organisation_attributes(organisation)
[
{ name: "Organisation ID", value: "ORG#{organisation.id}", editable: false },
{ name: "Address", value: organisation.address_string, editable: true },
{ name: "Telephone number", value: organisation.phone, editable: true },
{ name: "Type of provider", value: organisation.display_provider_type, editable: false },
{ name: "Registration number", value: organisation.housing_registration_no || "", editable: false },
{ name: "Rent periods", value: organisation.rent_period_labels, editable: false, format: :bullet },
{ name: "Owns housing stock", value: organisation.holds_own_stock ? "Yes" : "No", editable: false },
{ name: "Status", value: status_tag(organisation.status), editable: false },
]
end
def organisation_name_row(user:, organisation:, summary_list:)
summary_list.row do |row|
row.key { "Name" }
row.value { organisation.name }
if user.support?
row.action(
visually_hidden_text: organisation.name.humanize.downcase,
href: edit_organisation_path(organisation),
html_attributes: { "data-qa": "change-#{organisation.name.downcase}" },
)
else
row.action
end
end
end
end

2
app/helpers/tag_helper.rb

@ -13,6 +13,7 @@ module TagHelper
reactivating_soon: "Reactivating soon",
deactivated: "Deactivated",
deleted: "Deleted",
merged: "Merged",
}.freeze
COLOUR = {
@ -27,6 +28,7 @@ module TagHelper
reactivating_soon: "blue",
deactivated: "grey",
deleted: "red",
merged: "orange",
}.freeze
def status_tag(status, classes = [])

23
app/models/organisation.rb

@ -110,19 +110,6 @@ class Organisation < ApplicationRecord
DISPLAY_PROVIDER_TYPE[provider_type.to_sym]
end
def display_organisation_attributes
[
{ name: "Name", value: name, editable: true },
{ name: "Organisation ID", value: "ORG#{id}", editable: false },
{ name: "Address", value: address_string, editable: true },
{ name: "Telephone number", value: phone, editable: true },
{ name: "Type of provider", value: display_provider_type, editable: false },
{ name: "Registration number", value: housing_registration_no || "", editable: false },
{ name: "Rent periods", value: rent_period_labels, editable: false, format: :bullet },
{ name: "Owns housing stock", value: holds_own_stock ? "Yes" : "No", editable: false },
]
end
def has_managing_agents?
managing_agents.count.positive?
end
@ -130,4 +117,14 @@ class Organisation < ApplicationRecord
def has_stock_owners?
stock_owners.count.positive?
end
def status
@status ||= status_at(Time.zone.now)
end
def status_at(date)
return :merged if merge_date.present? && merge_date < date
:active
end
end

7
app/models/user.rb

@ -21,6 +21,7 @@ class User < ApplicationRecord
after_validation :send_data_protection_confirmation_reminder, if: :is_dpo_changed?
validates :organisation_id, presence: true
validate :organisation_not_merged
has_paper_trail ignore: %w[last_sign_in_at
current_sign_in_at
@ -190,6 +191,12 @@ protected
private
def organisation_not_merged
if organisation&.merge_date.present? && organisation.merge_date < Time.zone.now
errors.add :organisation_id, I18n.t("validations.organisation.merged")
end
end
def send_data_protection_confirmation_reminder
return unless persisted?
return unless is_dpo?

2
app/services/exports/lettings_log_export_constants.rb

@ -20,7 +20,9 @@ module Exports::LettingsLogExportConstants
"cligrp1",
"cligrp2",
"createddate", # New metadata coming from our system
"creation_method",
"confidential",
"discarded_at",
"earnings",
"ethnic",
"formid",

4
app/views/form/_interruption_screen_question.html.erb

@ -3,8 +3,8 @@
<h1 class="govuk-heading-m">
Make sure these answers are correct:
</h1>
<div class="x-govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__body">
<div class="govuk-summary-card govuk-!-margin-bottom-6">
<div class="govuk-summary-card__content">
<%= render partial: "form/check_answers_summary_list", locals: {
lettings_log:,

8
app/views/form/review.html.erb

@ -14,11 +14,11 @@
<h2 class="govuk-heading-m"><%= section.label %></h2>
<% section.subsections.map do |subsection| %>
<% if total_applicable_questions(subsection, @log, current_user).any? %>
<div class="x-govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__header">
<h3 class="x-govuk-summary-card__title"><%= subsection.label %></h3>
<div class="govuk-summary-card govuk-!-margin-bottom-6">
<div class="govuk-summary-card__title-wrapper">
<h3 class="govuk-summary-card__title"><%= subsection.label %></h3>
</div>
<div class="x-govuk-summary-card__body">
<div class="govuk-summary-card__content">
<%= render partial: "form/check_answers_summary_list", locals: { subsection:, questions: total_applicable_questions(subsection, @log, current_user), referrer: "check_answers" } %>
</div>
</div>

4
app/views/organisations/_organisation_list.html.erb

@ -14,6 +14,9 @@
<% row.cell(header: true, text: "Type", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Status", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @organisations.each do |organisation| %>
@ -26,6 +29,7 @@
<% end %>
<% row.cell(text: organisation.housing_registration_no) %>
<% row.cell(text: organisation.display_provider_type) %>
<% row.cell(text: status_tag(organisation.status)) %>
<% end %>
<% end %>
<% end %>

5
app/views/organisations/edit.html.erb

@ -11,8 +11,9 @@
<%= content_for(:title) %>
</h1>
<%= f.govuk_text_field :name,
autocomplete: "name" %>
<% if current_user.support? %>
<%= f.govuk_text_field :name, autocomplete: "name" %>
<% end %>
<%= f.govuk_text_field :address_line1,
label: { text: "Address line 1" },

3
app/views/organisations/show.html.erb

@ -14,7 +14,8 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<%= govuk_summary_list do |summary_list| %>
<% @organisation.display_organisation_attributes.each do |attr| %>
<%= organisation_name_row(user: current_user, organisation: @organisation, summary_list:) %>
<% display_organisation_attributes(@organisation).each do |attr| %>
<% if can_edit_org?(current_user) && attr[:editable] %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name] } %>

2
config/cloud_foundry/review_manifest.yml

@ -1,7 +1,7 @@
---
defaults: &defaults
buildpacks:
- https://github.com/cloudfoundry/ruby-buildpack.git#v1.8.59
- https://github.com/cloudfoundry/ruby-buildpack.git
processes:
- type: web
command: bundle exec rake cf:on_first_instance db:migrate db:seed && bin/rails server

1
config/locales/en.yml

@ -198,6 +198,7 @@ en:
managing_agent:
blank: "You must choose a managing agent"
already_added: "You have already added this managing agent"
merged: "That organisation has already been merged. Select a different organisation."
not_answered: "You must answer %{question}"
invalid_option: "Enter a valid value for %{question}"
invalid_number: "Enter a number for %{question}"

5
db/migrate/20230718151955_add_merge_date_to_organisation.rb

@ -0,0 +1,5 @@
class AddMergeDateToOrganisation < ActiveRecord::Migration[7.0]
def change
add_column :organisations, :merge_date, :datetime
end
end

6
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_07_19_150610) do
ActiveRecord::Schema[7.0].define(version: 2023_07_18_151955) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -433,8 +433,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_07_19_150610) do
t.integer "unspecified_units"
t.string "old_org_id"
t.string "old_visible_id"
t.bigint "absorbing_organisation_id"
t.index ["absorbing_organisation_id"], name: "index_organisations_on_absorbing_organisation_id"
t.datetime "merge_date"
t.index ["old_visible_id"], name: "index_organisations_on_old_visible_id", unique: true
end
@ -716,7 +715,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_07_19_150610) do
add_foreign_key "locations", "schemes"
add_foreign_key "organisation_relationships", "organisations", column: "child_organisation_id"
add_foreign_key "organisation_relationships", "organisations", column: "parent_organisation_id"
add_foreign_key "organisations", "organisations", column: "absorbing_organisation_id"
add_foreign_key "sales_logs", "organisations", column: "owning_organisation_id", on_delete: :cascade
add_foreign_key "schemes", "organisations", column: "owning_organisation_id", on_delete: :cascade
add_foreign_key "users", "organisations", on_delete: :cascade

4
docs/setup.md

@ -64,8 +64,8 @@ We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS version
4. Install Ruby and Bundler
```bash
rbenv install 3.1.2
rbenv global 3.1.2
rbenv install 3.1.4
rbenv global 3.1.4
source ~/.bashrc
gem install bundler
```

2
manifest.yml

@ -1,7 +1,7 @@
---
defaults: &defaults
buildpacks:
- https://github.com/cloudfoundry/ruby-buildpack.git#v1.8.59
- https://github.com/cloudfoundry/ruby-buildpack.git
processes:
- type: web
command: bundle exec rake cf:on_first_instance db:migrate && bin/rails server

6
package.json

@ -2,7 +2,7 @@
"name": "data-collector",
"private": true,
"engines": {
"node": "^16.0.0"
"node": "^18.0.0"
},
"dependencies": {
"@babel/core": "^7.17.7",
@ -11,6 +11,7 @@
"@hotwired/stimulus": "^3.0.0",
"@stimulus/polyfills": "^2.0.0",
"@webcomponents/webcomponentsjs": "^2.6.0",
"@x-govuk/govuk-prototype-components": "^2.0.1",
"accessible-autocomplete": "^2.0.3",
"babel-loader": "^8.2.3",
"babel-plugin-macros": "^3.1.0",
@ -19,8 +20,7 @@
"css-loader": "^6.7.1",
"custom-event-polyfill": "^1.0.7",
"file-loader": "^6.2.0",
"govuk-frontend": "4.2.0",
"govuk-prototype-components": "^0.4.0",
"govuk-frontend": "4.7.0",
"html5shiv": "^3.7.3",
"intersection-observer": "^0.12.0",
"mini-css-extract-plugin": "^2.6.0",

6
spec/features/form/check_answers_page_lettings_logs_spec.rb

@ -148,14 +148,14 @@ RSpec.describe "Lettings Log Check Answers Page" do
it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do
visit("/lettings-logs/#{completed_lettings_log.id}/household-needs/check-answers")
assert_selector ".x-govuk-summary-card__title", count: 0
assert_selector ".govuk-summary-card__title", count: 0
end
context "when the user is checking their answers for the household characteristics subsection" do
it "they see a separate summary card for each member of the household" do
visit("/lettings-logs/#{completed_lettings_log.id}/#{subsection}/check-answers")
assert_selector ".x-govuk-summary-card__title", text: "Lead tenant", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 1
assert_selector ".govuk-summary-card__title", text: "Lead tenant", count: 1
assert_selector ".govuk-summary-card__title", text: "Person 2", count: 1
end
end

30
spec/features/form/check_answers_page_sales_logs_spec.rb

@ -36,33 +36,33 @@ RSpec.describe "Sales Log Check Answers Page" do
it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do
visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/household-needs/check-answers")
assert_selector ".x-govuk-summary-card__title", count: 0
assert_selector ".govuk-summary-card__title", count: 0
end
context "when the user is checking their answers for the household characteristics subsection" do
context "and the log is for a joint purchase" do
it "they see a separate summary card for each member of the household" do
visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/#{subsection}/check-answers")
assert_selector ".x-govuk-summary-card__title", text: "Buyer 1", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Buyer 2", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 1", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 3", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 4", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 5", count: 1
assert_selector ".govuk-summary-card__title", text: "Buyer 1", count: 1
assert_selector ".govuk-summary-card__title", text: "Buyer 2", count: 1
assert_selector ".govuk-summary-card__title", text: "Person 1", count: 0
assert_selector ".govuk-summary-card__title", text: "Person 2", count: 0
assert_selector ".govuk-summary-card__title", text: "Person 3", count: 1
assert_selector ".govuk-summary-card__title", text: "Person 4", count: 1
assert_selector ".govuk-summary-card__title", text: "Person 5", count: 1
end
end
context "and the log is for a non-joint purchase" do
it "they see a separate summary card for each member of the household" do
visit("/sales-logs/#{completed_sales_log_non_joint_purchase.id}/#{subsection}/check-answers")
assert_selector ".x-govuk-summary-card__title", text: "Buyer 1", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Buyer 2", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 1", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 3", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 4", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 5", count: 1
assert_selector ".govuk-summary-card__title", text: "Buyer 1", count: 1
assert_selector ".govuk-summary-card__title", text: "Buyer 2", count: 0
assert_selector ".govuk-summary-card__title", text: "Person 1", count: 0
assert_selector ".govuk-summary-card__title", text: "Person 2", count: 1
assert_selector ".govuk-summary-card__title", text: "Person 3", count: 1
assert_selector ".govuk-summary-card__title", text: "Person 4", count: 1
assert_selector ".govuk-summary-card__title", text: "Person 5", count: 1
end
end
end

2
spec/fixtures/exports/general_needs_log.xml vendored

@ -142,6 +142,8 @@
<address_line2/>
<town_or_city>London</town_or_city>
<county/>
<discarded_at/>
<creation_method>1</creation_method>
<formid>{id}</formid>
<owningorgid>{owning_org_id}</owningorgid>
<owningorgname>DLUHC</owningorgname>

2
spec/fixtures/exports/general_needs_log_23_24.xml vendored

@ -143,6 +143,8 @@
<address_line2/>
<town_or_city>London</town_or_city>
<county/>
<discarded_at/>
<creation_method>1</creation_method>
<formid>{id}</formid>
<owningorgid>{owning_org_id}</owningorgid>
<owningorgname>DLUHC</owningorgname>

2
spec/fixtures/exports/supported_housing_logs.xml vendored

@ -141,6 +141,8 @@
<address_line2/>
<town_or_city/>
<county/>
<discarded_at/>
<creation_method>1</creation_method>
<formid>{id}</formid>
<owningorgid>{owning_org_id}</owningorgid>
<owningorgname>DLUHC</owningorgname>

23
spec/helpers/organisations_helper_spec.rb

@ -0,0 +1,23 @@
require "rails_helper"
RSpec.describe OrganisationsHelper do
include TagHelper
describe "display_organisation_attributes" do
let(:organisation) { create(:organisation) }
it "does not include data protection agreement" do
expect(display_organisation_attributes(organisation)).to eq(
[{ editable: false, name: "Organisation ID", value: "ORG#{organisation.id}" },
{ editable: true,
name: "Address",
value: "2 Marsham Street\nLondon\nSW1P 4DF" },
{ editable: true, name: "Telephone number", value: nil },
{ editable: false, name: "Type of provider", value: "Local authority" },
{ editable: false, name: "Registration number", value: "1234" },
{ editable: false, format: :bullet, name: "Rent periods", value: %w[All] },
{ editable: false, name: "Owns housing stock", value: "Yes" },
{ editable: false, name: "Status", value: status_tag(organisation.status) }],
)
end
end
end

1
spec/helpers/tag_helper_spec.rb

@ -20,6 +20,7 @@ RSpec.describe TagHelper do
expect(status_tag("activating_soon", "app-tag--small")).to eq("<strong class=\"govuk-tag govuk-tag--blue app-tag--small\">Activating soon</strong>")
expect(status_tag("reactivating_soon", "app-tag--small")).to eq("<strong class=\"govuk-tag govuk-tag--blue app-tag--small\">Reactivating soon</strong>")
expect(status_tag("deactivated", "app-tag--small")).to eq("<strong class=\"govuk-tag govuk-tag--grey app-tag--small\">Deactivated</strong>")
expect(status_tag("merged", "app-tag--small")).to eq("<strong class=\"govuk-tag govuk-tag--orange app-tag--small\">Merged</strong>")
end
end
end

19
spec/models/organisation_spec.rb

@ -230,23 +230,4 @@ RSpec.describe Organisation, type: :model do
end
end
end
describe "display_organisation_attributes" do
let(:organisation) { create(:organisation) }
it "does not include data protection agreement" do
expect(organisation.display_organisation_attributes).to eq(
[{ editable: true, name: "Name", value: "DLUHC" },
{ editable: false, name: "Organisation ID", value: "ORG#{organisation.id}" },
{ editable: true,
name: "Address",
value: "2 Marsham Street\nLondon\nSW1P 4DF" },
{ editable: true, name: "Telephone number", value: nil },
{ editable: false, name: "Type of provider", value: "Local authority" },
{ editable: false, name: "Registration number", value: "1234" },
{ editable: false, format: :bullet, name: "Rent periods", value: %w[All] },
{ editable: false, name: "Owns housing stock", value: "Yes" }],
)
end
end
end

10
spec/models/user_spec.rb

@ -355,6 +355,16 @@ RSpec.describe User, type: :model do
.to raise_error(ActiveRecord::RecordInvalid, error_message)
end
end
context "when a user is added to a merged organisation" do
let(:merged_organisation) { create(:organisation, merge_date: Time.zone.yesterday) }
let(:error_message) { "Validation failed: Organisation #{I18n.t('validations.organisation.merged')}" }
it "validates organisation merge status" do
expect { create(:user, organisation: merged_organisation) }
.to raise_error(ActiveRecord::RecordInvalid, error_message)
end
end
end
describe "delete" do

8
spec/requests/organisations_controller_spec.rb

@ -262,9 +262,9 @@ RSpec.describe OrganisationsController, type: :request do
expect(response.body).to include(organisation.name)
end
it "has a change details link" do
it "does not include a change details link" do
expected_html = "data-qa=\"change-name\" href=\"/organisations/#{organisation.id}/edit\""
expect(response.body).to include(expected_html)
expect(response.body).not_to include(expected_html)
end
it "displays a link to merge organisations" do
@ -345,9 +345,9 @@ RSpec.describe OrganisationsController, type: :request do
get "/organisations/#{organisation.id}/edit", headers:, params: {}
end
it "shows an edit form" do
it "shows an edit form without name field" do
expect(response.body).to include("Change #{organisation.name}’s details")
expect(page).to have_field("organisation-name-field")
expect(page).not_to have_field("organisation-name-field")
expect(page).to have_field("organisation-phone-field")
end
end

2
spec/views/bulk_upload_lettings_results/show.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_lettings_results/show.html.erb" do
fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end
end

2
spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_lettings_results/summary.html.erb" do
fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end
end

2
spec/views/bulk_upload_sales_results/show.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_sales_results/show.html.erb" do
fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end
end

2
spec/views/bulk_upload_sales_results/summary.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_sales_results/summary.html.erb" do
fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end
end

2
webpack.config.js

@ -40,7 +40,7 @@ module.exports = {
resolve: {
alias: {
'govuk-frontend-styles': path.resolve(__dirname, 'node_modules/govuk-frontend/govuk/all.scss'),
'govuk-prototype-styles': path.resolve(__dirname, 'node_modules/govuk-prototype-components/x-govuk/all.scss')
'govuk-prototype-styles': path.resolve(__dirname, 'node_modules/@x-govuk/govuk-prototype-components/x-govuk/all.scss')
},
modules: ['node_modules', 'node_modules/govuk-frontend/govuk']
},

2138
yarn.lock

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