Browse Source

Merge branch 'main' into organisation_page

pull/114/head
baarkerlounger 4 years ago
parent
commit
4f85f9467e
  1. 1
      .nvmrc
  2. 3
      Gemfile.lock
  3. 4
      app/helpers/check_answers_helper.rb
  4. 4
      app/helpers/tasklist_helper.rb
  5. 31
      app/validations/date_validations.rb
  6. 2
      app/views/case_logs/_log_list.html.erb
  7. 2
      app/views/case_logs/edit.html.erb
  8. 5
      app/views/case_logs/index.html.erb
  9. 2
      app/views/devise/mailer/confirmation_instructions.html.erb
  10. 2
      app/views/devise/mailer/reset_password_instructions.html.erb
  11. 2
      app/views/devise/mailer/unlock_instructions.html.erb
  12. 5
      app/views/devise/passwords/new.html.erb
  13. 5
      app/views/devise/registrations/edit.html.erb
  14. 12
      app/views/devise/shared/_links.html.erb
  15. 2
      app/views/form/_check_answers_table.html.erb
  16. 5
      app/views/form/page.html.erb
  17. 36
      app/views/layouts/_footer.html.erb
  18. 19
      app/views/layouts/application.html.erb
  19. 2
      app/views/test/index.html.erb
  20. 2
      app/views/users/account/index.html.erb
  21. 5
      app/views/users/account/personal_details.html.erb
  22. 10
      config/forms/2021_2022.json
  23. 2
      config/locales/devise.en.yml
  24. 15
      db/migrate/20211125154916_change_property_void_date_type.rb
  25. 2
      db/schema.rb
  26. 14
      docs/api/DLUHC-CORE-Data.v1.json
  27. 3
      package.json
  28. 4
      public/404.html
  29. 2
      public/422.html
  30. 4
      spec/features/form/tasklist_page_spec.rb
  31. 14
      spec/fixtures/complete_case_log.json
  32. 4
      spec/fixtures/forms/test_validator.json
  33. 137
      spec/models/case_log_spec.rb
  34. 3
      spec/requests/case_log_controller_spec.rb
  35. 6
      spec/views/case_log_index_view_spec.rb

1
.nvmrc

@ -0,0 +1 @@
14

3
Gemfile.lock

@ -231,6 +231,8 @@ GEM
minitest (5.14.4) minitest (5.14.4)
msgpack (1.4.2) msgpack (1.4.2)
nio4r (2.5.8) nio4r (2.5.8)
nokogiri (1.12.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.12.5-x86_64-darwin) nokogiri (1.12.5-x86_64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.12.5-x86_64-linux) nokogiri (1.12.5-x86_64-linux)
@ -394,6 +396,7 @@ GEM
zeitwerk (2.5.1) zeitwerk (2.5.1)
PLATFORMS PLATFORMS
arm64-darwin-21
x86_64-darwin-19 x86_64-darwin-19
x86_64-darwin-20 x86_64-darwin-20
x86_64-linux x86_64-linux

4
app/helpers/check_answers_helper.rb

@ -1,3 +1,5 @@
include GovukLinkHelper
module CheckAnswersHelper module CheckAnswersHelper
def display_answered_questions_summary(subsection, case_log) def display_answered_questions_summary(subsection, case_log)
total = subsection.applicable_questions_count(case_log) total = subsection.applicable_questions_count(case_log)
@ -15,6 +17,6 @@ private
def create_next_missing_question_link(subsection, case_log) def create_next_missing_question_link(subsection, case_log)
pages_to_fill_in = subsection.unanswered_questions(case_log).map(&:page) pages_to_fill_in = subsection.unanswered_questions(case_log).map(&:page)
url = "/case_logs/#{case_log.id}/#{pages_to_fill_in.first.id}" url = "/case_logs/#{case_log.id}/#{pages_to_fill_in.first.id}"
link_to("Answer the missing questions", url, class: "govuk-link").html_safe govuk_link_to("Answer the missing questions", url).html_safe
end end
end end

4
app/helpers/tasklist_helper.rb

@ -1,3 +1,5 @@
include GovukLinkHelper
module TasklistHelper module TasklistHelper
STATUSES = { STATUSES = {
not_started: "Not started", not_started: "Not started",
@ -38,6 +40,6 @@ module TasklistHelper
else else
"#" "#"
end end
link_to(subsection.label, next_page_path, class: "task-name govuk-link") govuk_link_to(subsection.label, next_page_path, class: "task-name")
end end
end end

31
app/validations/date_validations.rb

@ -1,6 +1,31 @@
module DateValidations module DateValidations
def validate_property_major_repairs(record) def validate_property_major_repairs(record)
date_valid?("mrcdate", record) date_valid?("mrcdate", record)
if record["startdate"].present? && record["mrcdate"].present? && record["startdate"] < record["mrcdate"]
record.errors.add :mrcdate, "Major repairs date must be before the tenancy start date"
end
if is_rsnvac_first_let?(record) && record["mrcdate"].present?
record.errors.add :mrcdate, "Major repairs date must not be completed if the tenancy is first let"
end
if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 730
record.errors.add :mrcdate, "Major repairs cannot be more than 730 days before the tenancy start date"
end
end
def validate_property_void_date(record)
if record["property_void_date"].present? && record["startdate"].present? && record["startdate"].to_date - record["property_void_date"].to_date > 3650
record.errors.add :property_void_date, "Void date cannot be more than 730 days before the tenancy start date"
end
if record["property_void_date"].present? && record["startdate"].present? && record["startdate"].to_date < record["property_void_date"].to_date
record.errors.add :property_void_date, "Void date must be before the tenancy start date"
end
if record["property_void_date"].present? && record["mrcdate"].present? && record["mrcdate"].to_date < record["property_void_date"].to_date
record.errors.add :property_void_date, "Void date must be after the major repair date if a major repair date has been provided"
end
end end
def validate_startdate(record) def validate_startdate(record)
@ -18,4 +43,10 @@ private
record.errors.add question, "Please enter a valid date" record.errors.add question, "Please enter a valid date"
end end
end end
def is_rsnvac_first_let?(record)
record["rsnvac"] == "First let of newbuild property" ||
record["rsnvac"] == "First let of conversion/rehabilitation/acquired property" ||
record["rsnvac"] == "First let of leased property"
end
end end

2
app/views/case_logs/_log_list.html.erb

@ -12,7 +12,7 @@
<% case_logs.map do |log| %> <% case_logs.map do |log| %>
<tr class="govuk-table__row"> <tr class="govuk-table__row">
<th scope="row" class="govuk-table__header"> <th scope="row" class="govuk-table__header">
<%= link_to log.id, case_log_path(log), class: "govuk-link" %> <%= govuk_link_to log.id, case_log_path(log) %>
</th> </th>
<td class="govuk-table__cell govuk-table__cell"> <td class="govuk-table__cell govuk-table__cell">
<%= log.property_postcode %> <%= log.property_postcode %>

2
app/views/case_logs/edit.html.erb

@ -6,7 +6,7 @@
<h2 class="govuk-heading-s govuk-!-margin-bottom-2">This submission is <h2 class="govuk-heading-s govuk-!-margin-bottom-2">This submission is
<%= @case_log.status.to_s.humanize.downcase %></h2> <%= @case_log.status.to_s.humanize.downcase %></h2>
<p class="govuk-body govuk-!-margin-bottom-7">You've completed <%= get_subsections_count(@form, @case_log, :completed) %> of <%= get_subsections_count(@form, @case_log, :all) %> sections.</p> <p class="govuk-body govuk-!-margin-bottom-7">Youve completed <%= get_subsections_count(@form, @case_log, :completed) %> of <%= get_subsections_count(@form, @case_log, :all) %> sections.</p>
<p class="govuk-body govuk-!-margin-bottom-7"> <p class="govuk-body govuk-!-margin-bottom-7">
<% next_incomplete_section = get_next_incomplete_section(@form, @case_log).id %> <% next_incomplete_section = get_next_incomplete_section(@form, @case_log).id %>
<a class="govuk-link" href="#<%= next_incomplete_section %>" <a class="govuk-link" href="#<%= next_incomplete_section %>"

5
app/views/case_logs/index.html.erb

@ -3,14 +3,15 @@
<h1 class="govuk-heading-l">Your logs</h1> <h1 class="govuk-heading-l">Your logs</h1>
</div> </div>
<div class="govuk-grid-column-two-thirds-from-desktop"> <div class="govuk-grid-column-two-thirds-from-desktop">
<%= link_to "Create new log", case_logs_path, method: :post, class: "govuk-button" %>
<%= govuk_button_link_to "Create new log", case_logs_path, method: :post %>
<% if @in_progress_case_logs.present? %> <% if @in_progress_case_logs.present? %>
<%= render partial: "log_list", locals: { case_logs: @in_progress_case_logs, title: "Logs you need to complete", date_title: "Last Changed" } %> <%= render partial: "log_list", locals: { case_logs: @in_progress_case_logs, title: "Logs you need to complete", date_title: "Last Changed" } %>
<% end %> <% end %>
<% if @completed_case_logs.present? %> <% if @completed_case_logs.present? %>
<%= render partial: "log_list", locals: { case_logs: @completed_case_logs, title: "Logs you've submitted", date_title: "Date Submitted" } %> <%= render partial: "log_list", locals: { case_logs: @completed_case_logs, title: "Logs youve submitted", date_title: "Date Submitted" } %>
<% end %> <% end %>
<p><a href="#" class="govuk-link">See all completed logs (<%= @completed_case_logs.count %>)</a></p> <p><a href="#" class="govuk-link">See all completed logs (<%= @completed_case_logs.count %>)</a></p>

2
app/views/devise/mailer/confirmation_instructions.html.erb

@ -2,4 +2,4 @@
<p>You can confirm your account email through the link below:</p> <p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p> <p><%= govuk_link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>

2
app/views/devise/mailer/reset_password_instructions.html.erb

@ -2,7 +2,7 @@
<p>Someone has requested a link to change your password. You can do this through the link below.</p> <p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p> <p><%= govuk_link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p> <p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p> <p>Your password won't change until you access the link above and create a new one.</p>

2
app/views/devise/mailer/unlock_instructions.html.erb

@ -4,4 +4,4 @@
<p>Click the link below to unlock your account:</p> <p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p> <p><%= govuk_link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>

5
app/views/devise/passwords/new.html.erb

@ -1,5 +1,8 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= link_to 'Back', :back, class: "govuk-back-link" %> <%= govuk_back_link(
text: 'Back',
href: :back,
) %>
<% end %> <% end %>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>

5
app/views/devise/registrations/edit.html.erb

@ -1,5 +1,8 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= link_to 'Back', :back, class: "govuk-back-link" %> <%= govuk_back_link(
text: 'Back',
href: :back,
) %>
<% end %> <% end %>
<%= form_for(resource, as: resource_name, url: user_registration_path(), html: { method: :patch }) do |f| %> <%= form_for(resource, as: resource_name, url: user_registration_path(), html: { method: :patch }) do |f| %>

12
app/views/devise/shared/_links.html.erb

@ -1,25 +1,25 @@
<%- if controller_name != 'sessions' %> <%- if controller_name != 'sessions' %>
<p class="govuk-body">Already have an account? <%= link_to "Sign in", new_session_path(resource_name) %>.</p><br /> <p class="govuk-body">Already have an account? <%= govuk_link_to "Sign in", new_session_path(resource_name) %>.</p><br />
<% end %> <% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %> <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br /> <%= govuk_link_to "Sign up", new_registration_path(resource_name) %><br />
<% end %> <% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<p class="govuk-body"> You can <%= link_to "reset your password", new_password_path(resource_name) %> if you've forgotten it.<p><br /> <p class="govuk-body"> You can <%= govuk_link_to "reset your password", new_password_path(resource_name) %> if youve forgotten it.<p><br />
<% end %> <% end %>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br /> <%= govuk_link_to "Didn’t receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end %> <% end %>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br /> <%= govuk_link_to "Didn’t receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end %> <% end %>
<%- if devise_mapping.omniauthable? %> <%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %> <%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %><br /> <%= govuk_link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %><br />
<% end %> <% end %>
<% end %> <% end %>

2
app/views/form/_check_answers_table.html.erb

@ -6,6 +6,6 @@
<%= question.answer_label(@case_log) %> <%= question.answer_label(@case_log) %>
</dd> </dd>
<dd class="govuk-summary-list__actions"> <dd class="govuk-summary-list__actions">
<%= link_to(question.update_answer_link_name(@case_log), "/case_logs/#{@case_log.id}/#{question.page.id}", class: "govuk-link").html_safe %> <%= govuk_link_to(question.update_answer_link_name(@case_log), "/case_logs/#{@case_log.id}/#{question.page.id}").html_safe %>
</dd> </dd>
</div> </div>

5
app/views/form/page.html.erb

@ -1,5 +1,8 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= link_to 'Back', 'javascript:history.back()', class: "govuk-back-link" %> <%= govuk_back_link(
text: 'Back',
href: 'javascript:history.back()',
) %>
<% end %> <% end %>
<%= turbo_frame_tag "case_log_form", target: "_top" do %> <%= turbo_frame_tag "case_log_form", target: "_top" do %>

36
app/views/layouts/_footer.html.erb

@ -1,17 +1,11 @@
<div class="govuk-width-container "> <%= govuk_footer do |footer| %>
<%= footer.meta do %>
<div class="govuk-footer__meta">
<div class="govuk-footer__meta-item govuk-footer__meta-item--grow"> <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
<h2 class="govuk-visually-hidden">Support links</h2>
<div class="govuk-footer__meta-custom">
<h2 class="govuk-heading-m">Get help with this service</h2> <h2 class="govuk-heading-m">Get help with this service</h2>
<h3 class="govuk-heading-s govuk-!-margin-bottom-1">Online helpdesk</h3> <h3 class="govuk-heading-s govuk-!-margin-bottom-1">Online helpdesk</h3>
<p class="govuk-body govuk-!-font-size-16"> <p class="govuk-body govuk-!-font-size-16">
<a class="govuk-link govuk-footer__link" href="https://digital.dclg.gov.uk/jira/servicedesk/customer/portal/4/group/21" target="_blank">CORE helpdesk</a> <a class="govuk-link govuk-footer__link" href="https://digital.dclg.gov.uk/jira/servicedesk/customer/portal/4/group/21" target="_blank">CORE helpdesk</a> (opens in a new tab)</p>
(opens in a new tab)</p>
<h3 class="govuk-heading-s govuk-!-margin-bottom-1">Telephone</h3> <h3 class="govuk-heading-s govuk-!-margin-bottom-1">Telephone</h3>
<ul class="govuk-list govuk-!-font-size-16"> <ul class="govuk-list govuk-!-font-size-16">
@ -20,29 +14,15 @@
</ul> </ul>
<h3 class="govuk-heading-s govuk-!-margin-bottom-1">Email</h3> <h3 class="govuk-heading-s govuk-!-margin-bottom-1">Email</h3>
<ul class="govuk-list govuk-!-font-size-16"> <ul class="govuk-list govuk-!-font-size-16 govuk-!-margin-bottom-0">
<li> <li>
<a class="govuk-link govuk-footer__link" href="mailto:mhclg.digital-services@communities.gov.uk?subject=CORE">dluhc.digital-services@communities.gov.uk</a> <a class="govuk-link govuk-footer__link" href="mailto:mhclg.digital-services@communities.gov.uk?subject=CORE">dluhc.digital-services@communities.gov.uk</a>
</li> </li>
<li>We aim to respond within 2 working days</li> <li class="govuk-!-margin-bottom-0">We aim to respond within 2 working days</li>
</ul> </ul>
<h2 class="govuk-visually-hidden">Footer links</h2>
</div>
<svg aria-hidden="true" focusable="false" class="govuk-footer__licence-logo" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 483.2 195.7" height="17" width="41">
<path
fill="currentColor"
d="M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145"/>
</svg>
<span class="govuk-footer__licence-description">
All content is available under the
<a class="govuk-footer__link" href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" rel="license">Open Government Licence v3.0</a>, except where otherwise stated
</span>
</div> </div>
<div class="govuk-footer__meta-item"> <div class="govuk-footer__meta-item">
<a class="govuk-footer__link govuk-footer__copyright-logo" href="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/">© Crown copyright</a> <a class="govuk-footer__link govuk-footer__copyright-logo" href="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/">© Crown copyright</a>
</div> </div>
</div> <% end %>
</div> <% end %>

19
app/views/layouts/application.html.erb

@ -25,16 +25,13 @@
</head> </head>
<body class="govuk-template__body "> <body class="govuk-template__body ">
<script> <script>
document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled'); document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');
</script> </script>
<a href="#main-content" class="govuk-skip-link">Skip to main content</a> <%= govuk_skip_link %>
<header class="govuk-header" role="banner" data-module="govuk-header"> <%= govuk_header(
<%= render GovukComponent::HeaderComponent.new(
logotype: 'GOV.UK', logotype: 'GOV.UK',
service_name: 'Share Lettings and Sales for Social Housing in England Data with DLUHC', service_name: 'Share Lettings and Sales for Social Housing in England Data with DLUHC',
service_url: '/' service_url: '/'
@ -47,22 +44,20 @@
end end
end end
%> %>
</header>
<aside class="govuk-width-container"> <div class="govuk-width-container">
<%= render GovukComponent::PhaseBannerComponent.new( <%= govuk_phase_banner(
tag: { text: 'Beta' }, tag: { text: 'Beta' },
text: "This is a new service – #{govuk_mail_to("test@mhclg.gov.uk", "give feedback or report a problem", subject: "Feedback about Lettings and Sales of Social Housing in England Data Collection")}".html_safe text: "This is a new service – #{govuk_mail_to("test@mhclg.gov.uk", "give feedback or report a problem", subject: "Feedback about Lettings and Sales of Social Housing in England Data Collection")}".html_safe
) %> ) %>
</aside>
<div class="govuk-width-container">
<div role="navigation"> <div role="navigation">
<%= content_for(:before_content) %> <%= content_for(:before_content) %>
</div> </div>
<main class="govuk-main-wrapper" id="main-content" role="main"> <main class="govuk-main-wrapper" id="main-content" role="main">
<% flash.each do |type, msg| %> <% flash.each do |type, msg| %>
<%= render GovukComponent::NotificationBannerComponent.new( <%= govuk_notification_banner(
title_text: 'Success', title_text: 'Success',
success: true, title_heading_level: 3, success: true, title_heading_level: 3,
title_id: "swanky-notifications") do |notification_banner| title_id: "swanky-notifications") do |notification_banner|
@ -74,8 +69,6 @@
</main> </main>
</div> </div>
<footer class="govuk-footer">
<%= render partial: "layouts/footer" %> <%= render partial: "layouts/footer" %>
</footer>
</body> </body>
</html> </html>

2
app/views/test/index.html.erb

@ -27,4 +27,4 @@
end end
end %> end %>
<%= link_to('About', about_path) %> <%= govuk_link_to('About', about_path) %>

2
app/views/users/account/index.html.erb

@ -43,7 +43,7 @@
•••••••• ••••••••
</dd> </dd>
<dd class="govuk-summary-list__actions"> <dd class="govuk-summary-list__actions">
<%= link_to "Change", edit_user_registration_path, id: "change-password" %> <%= govuk_link_to "Change", edit_user_registration_path, id: "change-password" %>
</dd> </dd>
</div> </div>
<div class="govuk-summary-list__row"> <div class="govuk-summary-list__row">

5
app/views/users/account/personal_details.html.erb

@ -1,5 +1,8 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= link_to 'Back', :back, class: "govuk-back-link" %> <%= govuk_back_link(
text: 'Back',
href: :back,
) %>
<% end %> <% end %>
<%= form_for(current_user, as: :user, url: account_update_path(), html: { method: :patch }) do |f| %> <%= form_for(current_user, as: :user, url: account_update_path(), html: { method: :patch }) do |f| %>

10
config/forms/2021_2022.json

@ -822,11 +822,11 @@
"15": "Under occupation - no incentive", "15": "Under occupation - no incentive",
"16": "Property unsuitable because of ill health / disability", "16": "Property unsuitable because of ill health / disability",
"17": "Property unsuitable because of poor condition", "17": "Property unsuitable because of poor condition",
"18": "Couldn't afford fees attached to renewing the tenancy", "18": "Couldnt afford fees attached to renewing the tenancy",
"19": "Couldn't afford increase in rent", "19": "Couldnt afford increase in rent",
"20": "Couldn't afford rent or mortgage - welfare reforms", "20": "Couldnt afford rent or mortgage - welfare reforms",
"21": "Couldn't afford rent or mortgage - employment", "21": "Couldnt afford rent or mortgage - employment",
"22": "Couldn't afford rent or mortgage - other", "22": "Couldnt afford rent or mortgage - other",
"23": "To move nearer to family / friends / school", "23": "To move nearer to family / friends / school",
"24": "To move nearer to work", "24": "To move nearer to work",
"25": "To move to accomodation with support", "25": "To move to accomodation with support",

2
config/locales/devise.en.yml

@ -31,7 +31,7 @@ en:
failure: "Could not authenticate you from %{kind} because \"%{reason}\"." failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
success: "Successfully authenticated from %{kind} account." success: "Successfully authenticated from %{kind} account."
passwords: passwords:
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." no_token: "You cant access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
updated: "Your password has been changed successfully. You are now signed in." updated: "Your password has been changed successfully. You are now signed in."

15
db/migrate/20211125154916_change_property_void_date_type.rb

@ -0,0 +1,15 @@
class ChangePropertyVoidDateType < ActiveRecord::Migration[6.1]
def up
change_table :case_logs, bulk: true do |t|
t.remove :property_void_date
t.column :property_void_date, :datetime
end
end
def down
change_table :case_logs, bulk: true do |t|
t.remove :property_void_date
t.column :property_void_date, :string
end
end
end

2
db/schema.rb

@ -83,7 +83,6 @@ ActiveRecord::Schema.define(version: 2021_11_26_142105) do
t.integer "rsnvac" t.integer "rsnvac"
t.integer "unittype_gn" t.integer "unittype_gn"
t.integer "beds" t.integer "beds"
t.string "property_void_date"
t.integer "offered" t.integer "offered"
t.integer "wchair" t.integer "wchair"
t.integer "earnings" t.integer "earnings"
@ -168,6 +167,7 @@ ActiveRecord::Schema.define(version: 2021_11_26_142105) do
t.integer "builtype" t.integer "builtype"
t.bigint "owning_organisation_id" t.bigint "owning_organisation_id"
t.bigint "managing_organisation_id" t.bigint "managing_organisation_id"
t.datetime "property_void_date"
t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id" t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_case_logs_on_owning_organisation_id" t.index ["owning_organisation_id"], name: "index_case_logs_on_owning_organisation_id"

14
docs/api/DLUHC-CORE-Data.v1.json

@ -740,19 +740,19 @@
"Other problems with neighbours", "Other problems with neighbours",
"Property unsuitable because of overcrowding", "Property unsuitable because of overcrowding",
"End of assured shorthold tenancy - no fault", "End of assured shorthold tenancy - no fault",
"End of assured shorthold tenancy - tenant's fault", "End of assured shorthold tenancy - tenants fault",
"End of fixed term tenancy - no fault", "End of fixed term tenancy - no fault",
"End of fixed term tenancy - tenant's fault", "End of fixed term tenancy - tenants fault",
"Repossession", "Repossession",
"Under occupation - offered incentive to downsize", "Under occupation - offered incentive to downsize",
"Under occupation - no incentive", "Under occupation - no incentive",
"Property unsuitable because of ill health / disability", "Property unsuitable because of ill health / disability",
"Property unsuitable because of poor condition", "Property unsuitable because of poor condition",
"Couldn't afford fees attached to renewing the tenancy", "Couldnt afford fees attached to renewing the tenancy",
"Couldn't afford increase in rent", "Couldnt afford increase in rent",
"Couldn't afford rent or mortgage - welfare reforms", "Couldnt afford rent or mortgage - welfare reforms",
"Couldn't afford rent or mortgage - employment", "Couldnt afford rent or mortgage - employment",
"Couldn't afford rent or mortgage - other", "Couldnt afford rent or mortgage - other",
"To move nearer to family / friends / school", "To move nearer to family / friends / school",
"To move nearer to work", "To move nearer to work",
"To move to accomodation with support", "To move to accomodation with support",

3
package.json

@ -1,6 +1,9 @@
{ {
"name": "data-collector", "name": "data-collector",
"private": true, "private": true,
"engines": {
"node": "^14.0.0"
},
"dependencies": { "dependencies": {
"@activeadmin/activeadmin": "^2.9.0", "@activeadmin/activeadmin": "^2.9.0",
"@hotwired/stimulus": "^3.0.0", "@hotwired/stimulus": "^3.0.0",

4
public/404.html

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>The page you were looking for doesn't exist (404)</title> <title>The page you were looking for doesnt exist (404)</title>
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<style> <style>
.rails-default-error-page { .rails-default-error-page {
@ -58,7 +58,7 @@
<!-- This file lives in public/404.html --> <!-- This file lives in public/404.html -->
<div class="dialog"> <div class="dialog">
<div> <div>
<h1>The page you were looking for doesn't exist.</h1> <h1>The page you were looking for doesnt exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p> <p>You may have mistyped the address or the page may have moved.</p>
</div> </div>
<p>If you are the application owner check the logs for more information.</p> <p>If you are the application owner check the logs for more information.</p>

2
public/422.html

@ -59,7 +59,7 @@
<div class="dialog"> <div class="dialog">
<div> <div>
<h1>The change you wanted was rejected.</h1> <h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p> <p>Maybe you tried to change something you didnt have access to.</p>
</div> </div>
<p>If you are the application owner check the logs for more information.</p> <p>If you are the application owner check the logs for more information.</p>
</div> </div>

4
spec/features/form/tasklist_page_spec.rb

@ -56,12 +56,12 @@ RSpec.describe "Task List" do
it "shows the number of completed sections if no sections are completed" do it "shows the number of completed sections if no sections are completed" do
visit("/case_logs/#{empty_case_log.id}") visit("/case_logs/#{empty_case_log.id}")
expect(page).to have_content("You've completed 0 of 9 sections.") expect(page).to have_content("Youve completed 0 of 9 sections.")
end end
it "shows the number of completed sections if one section is completed" do it "shows the number of completed sections if one section is completed" do
answer_all_questions_in_income_subsection(empty_case_log) answer_all_questions_in_income_subsection(empty_case_log)
visit("/case_logs/#{empty_case_log.id}") visit("/case_logs/#{empty_case_log.id}")
expect(page).to have_content("You've completed 1 of 9 sections.") expect(page).to have_content("Youve completed 1 of 9 sections.")
end end
end end

14
spec/fixtures/complete_case_log.json vendored

@ -50,7 +50,7 @@
"accessibility_requirements": "No", "accessibility_requirements": "No",
"condition_effects": "dummy", "condition_effects": "dummy",
"tenancy_code": "BZ757", "tenancy_code": "BZ757",
"startdate": "12/03/2019", "startdate": "12/12/2020",
"startertenancy": "No", "startertenancy": "No",
"tenancylength": "5", "tenancylength": "5",
"tenancy": "Secure (including flexible)", "tenancy": "Secure (including flexible)",
@ -59,16 +59,16 @@
"la": "Barnet", "la": "Barnet",
"property_postcode": "NW1 5TY", "property_postcode": "NW1 5TY",
"property_relet": "No", "property_relet": "No",
"rsnvac": "First let of newbuild property", "rsnvac": "Renewal of fixed-term tenancy",
"property_reference": "P9876", "property_reference": "P9876",
"unittype_gn": "House", "unittype_gn": "House",
"property_building_type": "dummy", "property_building_type": "dummy",
"beds": 3, "beds": 3,
"property_void_date": "03/11/2019", "property_void_date": "10/10/2020",
"majorrepairs": "No", "majorrepairs": "Yes",
"mrcdate": "05/05/2020", "mrcdate": "11/11/2020",
"mrcday": 5, "mrcday": 11,
"mrcmonth": 5, "mrcmonth": 11,
"mrcyear": 2020, "mrcyear": 2020,
"offered": 2, "offered": 2,
"wchair": "Yes", "wchair": "Yes",

4
spec/fixtures/forms/test_validator.json vendored

@ -8,12 +8,12 @@
"subsections": { "subsections": {
"household_characteristics": { "household_characteristics": {
"label": "Household characteristics", "label": "Household characteristics",
"ShouldThrowError": "Shouldn't be here but what you gonna do?", "ShouldThrowError": "Shouldnt be here but what you gonna do?",
"pages": { "pages": {
"tenant_code": { "tenant_code": {
"header": "", "header": "",
"description": "", "description": "",
"ShouldThrowError": "Shouldn't be here but what you gonna do?", "ShouldThrowError": "Shouldnt be here but what you gonna do?",
"questions": { "questions": {
"tenant_code": { "tenant_code": {
"check_answer_label": "Tenant code", "check_answer_label": "Tenant code",

137
spec/models/case_log_spec.rb

@ -621,6 +621,143 @@ RSpec.describe Form, type: :model do
end end
end end
end end
context "major repairs date" do
it "cannot be later than the tenancy start date" do
expect {
CaseLog.create!(
mrcdate: Date.new(2020, 10, 10),
startdate: Date.new(2020, 10, 9),
)
}.to raise_error(ActiveRecord::RecordInvalid)
expect {
CaseLog.create!(
mrcdate: Date.new(2020, 10, 9),
startdate: Date.new(2020, 10, 10),
)
}.not_to raise_error
end
it "must not be completed if reason for vacancy is first let" do
expect {
CaseLog.create!(
mrcdate: Date.new(2020, 10, 10),
rsnvac: "First let of newbuild property",
)
}.to raise_error(ActiveRecord::RecordInvalid)
expect {
CaseLog.create!(
mrcdate: Date.new(2020, 10, 10),
rsnvac: "First let of conversion/rehabilitation/acquired property",
)
}.to raise_error(ActiveRecord::RecordInvalid)
expect {
CaseLog.create!(
mrcdate: Date.new(2020, 10, 10),
rsnvac: "First let of leased property",
)
}.to raise_error(ActiveRecord::RecordInvalid)
end
it "must have less than two years between the tenancy start date and major repairs date" do
expect {
CaseLog.create!(
startdate: Date.new(2020, 10, 10),
mrcdate: Date.new(2017, 10, 10),
)
}.to raise_error(ActiveRecord::RecordInvalid)
end
end
context "void date" do
it "must have less than 10 years between the tenancy start date and void" do
expect {
CaseLog.create!(
startdate: Date.new(2020, 10, 10),
property_void_date: Date.new(2009, 10, 10),
)
}.to raise_error(ActiveRecord::RecordInvalid)
expect {
CaseLog.create!(
startdate: Date.new(2020, 10, 10),
property_void_date: Date.new(2015, 10, 10),
)
}.not_to raise_error
end
it "must be before the tenancy start date" do
expect {
CaseLog.create!(
startdate: Date.new(2020, 10, 10),
property_void_date: Date.new(2021, 10, 10),
)
}.to raise_error(ActiveRecord::RecordInvalid)
expect {
CaseLog.create!(
startdate: Date.new(2020, 10, 10),
property_void_date: Date.new(2019, 10, 10),
)
}.not_to raise_error
end
it "must be before major repairs date if major repairs date provided" do
expect {
CaseLog.create!(
startdate: Date.new(2020, 10, 10),
mrcdate: Date.new(2019, 10, 10),
property_void_date: Date.new(2019, 11, 11),
)
}.to raise_error(ActiveRecord::RecordInvalid)
end
end
context "Validate pregnancy questions" do
it "Cannot answer yes if no female tenants" do
expect {
CaseLog.create!(preg_occ: "Yes",
sex1: "Male",
age1: 20)
}.to raise_error(ActiveRecord::RecordInvalid)
end
it "Cannot answer yes if no female tenants within age range" do
expect {
CaseLog.create!(preg_occ: "Yes",
sex1: "Female",
age1: 51)
}.to raise_error(ActiveRecord::RecordInvalid)
end
it "Cannot answer prefer not to say if no valid tenants" do
expect {
CaseLog.create!(preg_occ: "Prefer not to say",
sex1: "Male",
age1: 20)
}.to raise_error(ActiveRecord::RecordInvalid)
end
it "Can answer yes if valid tenants" do
expect {
CaseLog.create!(preg_occ: "Yes",
sex1: "Female",
age1: 20)
}.not_to raise_error
end
it "Can answer yes if valid second tenant" do
expect {
CaseLog.create!(preg_occ: "Yes",
sex1: "Male", age1: 99,
sex2: "Female",
age2: 20)
}.not_to raise_error
end
end
end end
describe "status" do describe "status" do

3
spec/requests/case_log_controller_spec.rb

@ -97,6 +97,7 @@ RSpec.describe CaseLogsController, type: :request do
it "marks the record as completed" do it "marks the record as completed" do
json_response = JSON.parse(response.body) json_response = JSON.parse(response.body)
expect(json_response).not_to have_key("errors")
expect(json_response["status"]).to eq(completed) expect(json_response["status"]).to eq(completed)
end end
end end
@ -435,7 +436,7 @@ RSpec.describe CaseLogsController, type: :request do
case_log: { case_log: {
page: page_id, page: page_id,
age1: answer, age1: answer,
age2: 2000 age2: 2000,
}, },
} }
end end

6
spec/views/case_log_index_view_spec.rb

@ -10,7 +10,7 @@ RSpec.describe "case_logs/index" do
render render
expect(rendered).to match(/<table class="govuk-table">/) expect(rendered).to match(/<table class="govuk-table">/)
expect(rendered).to match(/Logs you need to complete/) expect(rendered).to match(/Logs you need to complete/)
expect(rendered).not_to match(/Logs you&#39;ve submitted/) expect(rendered).not_to match(/Logs youve submitted/)
expect(rendered).to match(in_progress_log.tenant_code) expect(rendered).to match(in_progress_log.tenant_code)
expect(rendered).to match(in_progress_log.property_postcode) expect(rendered).to match(in_progress_log.property_postcode)
end end
@ -22,7 +22,7 @@ RSpec.describe "case_logs/index" do
assign(:completed_case_logs, [completed_log]) assign(:completed_case_logs, [completed_log])
render render
expect(rendered).to match(/<table class="govuk-table">/) expect(rendered).to match(/<table class="govuk-table">/)
expect(rendered).to match(/Logs you&#39;ve submitted/) expect(rendered).to match(/Logs youve submitted/)
expect(rendered).not_to match(/Logs you need to complete/) expect(rendered).not_to match(/Logs you need to complete/)
expect(rendered).to match(completed_log.tenant_code) expect(rendered).to match(completed_log.tenant_code)
expect(rendered).to match(completed_log.property_postcode) expect(rendered).to match(completed_log.property_postcode)
@ -35,7 +35,7 @@ RSpec.describe "case_logs/index" do
assign(:completed_case_logs, [completed_log]) assign(:completed_case_logs, [completed_log])
render render
expect(rendered).to match(/<table class="govuk-table">/) expect(rendered).to match(/<table class="govuk-table">/)
expect(rendered).to match(/Logs you&#39;ve submitted/) expect(rendered).to match(/Logs youve submitted/)
expect(rendered).to match(/Logs you need to complete/) expect(rendered).to match(/Logs you need to complete/)
end end
end end

Loading…
Cancel
Save