natdeanlewissoftwire
8 months ago
135 changed files with 1259 additions and 467 deletions
@ -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 |
@ -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 |
@ -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| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<h1 class="govuk-heading-l"> |
||||
<span class="govuk-caption-l"><%= @organisation.name %></span> |
||||
Are you sure you want to <%= action %> this organisation? |
||||
</h1> |
||||
<%= 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" %> |
||||
|
||||
<p class="govuk-body"> |
||||
<%= govuk_link_to("Cancel", organisation_path(@organisation)) %> |
||||
</p> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,5 @@
|
||||
class AddReactivateWithOrganisationToUsers < ActiveRecord::Migration[7.0] |
||||
def change |
||||
add_column :users, :reactivate_with_organisation, :boolean |
||||
end |
||||
end |
@ -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 |
|
|
|
@ -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 |
@ -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 |
@ -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 |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue