Browse Source

CLDC-2471 Add org id to about your org page (#1715)

* feat: add org id to about page and update tests

* refactor: tidying

* feat: just enforce names are strings adn remove humanization to display ID in caps as required

* refactor: lint

* feat: fix tests
pull/1733/head
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
964cd2742e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/models/organisation.rb
  2. 4
      app/views/organisations/show.html.erb
  3. 10
      spec/models/organisation_spec.rb
  4. 12
      spec/requests/delete_logs_controller_spec.rb

5
app/models/organisation.rb

@ -105,11 +105,12 @@ class Organisation < ApplicationRecord
def display_organisation_attributes def display_organisation_attributes
attrs = [ attrs = [
{ name: "Name", value: name, editable: true }, { name: "Name", value: name, editable: true },
{ name: "Organisation ID", value: "ORG#{id}", editable: false },
{ name: "Address", value: address_string, editable: true }, { name: "Address", value: address_string, editable: true },
{ name: "Telephone_number", value: phone, editable: true }, { name: "Telephone number", value: phone, editable: true },
{ name: "Type of provider", value: display_provider_type, editable: false }, { name: "Type of provider", value: display_provider_type, editable: false },
{ name: "Registration number", value: housing_registration_no || "", editable: false }, { name: "Registration number", value: housing_registration_no || "", editable: false },
{ name: "Rent_periods", value: rent_period_labels, editable: false, format: :bullet }, { name: "Rent periods", value: rent_period_labels, editable: false, format: :bullet },
{ name: "Owns housing stock", value: holds_own_stock ? "Yes" : "No", editable: false }, { name: "Owns housing stock", value: holds_own_stock ? "Yes" : "No", editable: false },
].compact ].compact

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

@ -17,7 +17,7 @@
<% @organisation.display_organisation_attributes.each do |attr| %> <% @organisation.display_organisation_attributes.each do |attr| %>
<% if can_edit_org?(current_user) && attr[:editable] %> <% if can_edit_org?(current_user) && attr[:editable] %>
<%= summary_list.row do |row| %> <%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s.humanize } %> <% row.key { attr[:name] } %>
<% row.value { details_html(attr) } %> <% row.value { details_html(attr) } %>
<% row.action( <% row.action(
visually_hidden_text: attr[:name].to_s.humanize.downcase, visually_hidden_text: attr[:name].to_s.humanize.downcase,
@ -27,7 +27,7 @@
<% end %> <% end %>
<% else %> <% else %>
<%= summary_list.row do |row| %> <%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s.humanize } %> <% row.key { attr[:name] } %>
<% row.value { details_html(attr) } %> <% row.value { details_html(attr) } %>
<% row.action %> <% row.action %>
<% end %> <% end %>

10
spec/models/organisation_spec.rb

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

12
spec/requests/delete_logs_controller_spec.rb

@ -118,7 +118,7 @@ RSpec.describe "DeleteLogs", type: :request do
end end
before do before do
post delete_logs_confirmation_lettings_logs_path, params: params post delete_logs_confirmation_lettings_logs_path, params:
end end
it "requires delete logs form data to be provided" do it "requires delete logs form data to be provided" do
@ -188,7 +188,7 @@ RSpec.describe "DeleteLogs", type: :request do
end end
before do before do
post delete_logs_confirmation_lettings_logs_path, params: params post delete_logs_confirmation_lettings_logs_path, params:
end end
it "renders the list of logs table again" do it "renders the list of logs table again" do
@ -358,7 +358,7 @@ RSpec.describe "DeleteLogs", type: :request do
end end
before do before do
post delete_logs_confirmation_sales_logs_path, params: params post delete_logs_confirmation_sales_logs_path, params:
end end
it "requires delete logs form data to be provided" do it "requires delete logs form data to be provided" do
@ -428,7 +428,7 @@ RSpec.describe "DeleteLogs", type: :request do
end end
before do before do
post delete_logs_confirmation_sales_logs_path, params: params post delete_logs_confirmation_sales_logs_path, params:
end end
it "renders the list of logs table again" do it "renders the list of logs table again" do
@ -602,7 +602,7 @@ RSpec.describe "DeleteLogs", type: :request do
end end
before do before do
post delete_lettings_logs_confirmation_organisation_path(id: organisation), params: params post delete_lettings_logs_confirmation_organisation_path(id: organisation), params:
end end
it "requires delete logs form data to be provided" do it "requires delete logs form data to be provided" do
@ -827,7 +827,7 @@ RSpec.describe "DeleteLogs", type: :request do
end end
before do before do
post delete_sales_logs_confirmation_organisation_path(id: organisation), params: params post delete_sales_logs_confirmation_organisation_path(id: organisation), params:
end end
it "requires delete logs form data to be provided" do it "requires delete logs form data to be provided" do

Loading…
Cancel
Save