|
|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
require "rails_helper" |
|
|
|
|
require "rails_helper" |
|
|
|
|
|
|
|
|
|
include TagHelper |
|
|
|
|
include TagHelper |
|
|
|
|
|
|
|
|
|
RSpec.describe SchemesHelper do |
|
|
|
|
RSpec.describe SchemesHelper do |
|
|
|
|
describe "Active periods" do |
|
|
|
|
let(:scheme) { FactoryBot.create(:scheme, created_at: Time.zone.today) } |
|
|
|
|
|
|
|
|
|
@ -89,76 +89,84 @@
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "display_scheme_attributes" do |
|
|
|
|
let(:owning_organisation) {FactoryBot.create(:organisation, name: "Acme LTD Owning")} |
|
|
|
|
let(:managing_organisation) {FactoryBot.create(:organisation, name: "Acme LTD Managing")} |
|
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, |
|
|
|
|
id: 19, |
|
|
|
|
service_name: "Test service_name", |
|
|
|
|
sensitive: 0, |
|
|
|
|
scheme_type: 7, |
|
|
|
|
registered_under_care_act: 3, |
|
|
|
|
owning_organisation: owning_organisation, |
|
|
|
|
managing_organisation: managing_organisation, |
|
|
|
|
arrangement_type: "V", |
|
|
|
|
primary_client_group: "S", |
|
|
|
|
has_other_client_group: 1, |
|
|
|
|
secondary_client_group: "I", |
|
|
|
|
support_type: 4, |
|
|
|
|
intended_stay: "P", |
|
|
|
|
created_at: Time.zone.local(2022, 4, 1), |
|
|
|
|
) } |
|
|
|
|
let(:support_user) { FactoryBot.create(:user, :support) } |
|
|
|
|
let(:coordinator_user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
|
|
|
|
|
it "returns correct display attributes for a support user" do |
|
|
|
|
attributes = [ |
|
|
|
|
{ name: "Scheme code", value: "S19" }, |
|
|
|
|
{ name: "Name", value: "Test service_name", edit: true }, |
|
|
|
|
{ name: "Confidential information", value: "No", edit: true }, |
|
|
|
|
{ name: "Type of scheme", value: "Housing for older people" }, |
|
|
|
|
{ name: "Registered under Care Standards Act 2000", value: "Yes – registered care home providing personal care" }, |
|
|
|
|
{ name: "Housing stock owned by", value: "Acme LTD Owning", edit: true }, |
|
|
|
|
{ name: "Support services provided by", value: "A registered charity or voluntary organisation" }, |
|
|
|
|
{ name: "Organisation providing support", value: "Acme LTD Managing" }, |
|
|
|
|
{ name: "Primary client group", value: "Rough sleepers" }, |
|
|
|
|
{ name: "Has another client group", value: "Yes" }, |
|
|
|
|
{ name: "Secondary client group", value: "Refugees (permanent)" }, |
|
|
|
|
{ name: "Level of support given", value: "High level" }, |
|
|
|
|
{ name: "Intended length of stay", value: "Permanent" }, |
|
|
|
|
{ name: "Availability", value: "Active from 1 April 2022" }, |
|
|
|
|
{ name: "Status", value: status_tag(:active) }, |
|
|
|
|
] |
|
|
|
|
expect(display_scheme_attributes(scheme, support_user)).to eq(attributes) |
|
|
|
|
end |
|
|
|
|
describe "display_scheme_attributes" do |
|
|
|
|
let(:owning_organisation) {FactoryBot.create(:organisation, name: "Acme LTD Owning")} |
|
|
|
|
let(:managing_organisation) {FactoryBot.create(:organisation, name: "Acme LTD Managing")} |
|
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, |
|
|
|
|
id: 19, |
|
|
|
|
service_name: "Test service_name", |
|
|
|
|
sensitive: 0, |
|
|
|
|
scheme_type: 7, |
|
|
|
|
registered_under_care_act: 3, |
|
|
|
|
owning_organisation: owning_organisation, |
|
|
|
|
managing_organisation: managing_organisation, |
|
|
|
|
arrangement_type: "V", |
|
|
|
|
primary_client_group: "S", |
|
|
|
|
has_other_client_group: 1, |
|
|
|
|
secondary_client_group: "I", |
|
|
|
|
support_type: 4, |
|
|
|
|
intended_stay: "P", |
|
|
|
|
created_at: Time.zone.local(2022, 4, 1), |
|
|
|
|
) } |
|
|
|
|
let(:support_user) { FactoryBot.create(:user, :support) } |
|
|
|
|
let(:coordinator_user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
|
|
|
|
|
it "returns correct display attributes for a support user" do |
|
|
|
|
attributes = [ |
|
|
|
|
{ name: "Scheme code", value: "S19" }, |
|
|
|
|
{ name: "Name", value: "Test service_name", edit: true }, |
|
|
|
|
{ name: "Confidential information", value: "No", edit: true }, |
|
|
|
|
{ name: "Type of scheme", value: "Housing for older people" }, |
|
|
|
|
{ name: "Registered under Care Standards Act 2000", value: "Yes – registered care home providing personal care" }, |
|
|
|
|
{ name: "Housing stock owned by", value: "Acme LTD Owning", edit: true }, |
|
|
|
|
{ name: "Support services provided by", value: "A registered charity or voluntary organisation" }, |
|
|
|
|
{ name: "Organisation providing support", value: "Acme LTD Managing" }, |
|
|
|
|
{ name: "Primary client group", value: "Rough sleepers" }, |
|
|
|
|
{ name: "Has another client group", value: "Yes" }, |
|
|
|
|
{ name: "Secondary client group", value: "Refugees (permanent)" }, |
|
|
|
|
{ name: "Level of support given", value: "High level" }, |
|
|
|
|
{ name: "Intended length of stay", value: "Permanent" }, |
|
|
|
|
{ name: "Availability", value: "Active from 1 April 2022" }, |
|
|
|
|
{ name: "Status", value: status_tag(:active) }, |
|
|
|
|
] |
|
|
|
|
expect(display_scheme_attributes(scheme, support_user)).to eq(attributes) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns correct display attributes for a coordinator user" do |
|
|
|
|
attributes = [ |
|
|
|
|
{ name: "Scheme code", value: "S19" }, |
|
|
|
|
{ name: "Name", value: "Test service_name", edit: true }, |
|
|
|
|
{ name: "Confidential information", value: "No", edit: true }, |
|
|
|
|
{ name: "Type of scheme", value: "Housing for older people" }, |
|
|
|
|
{ name: "Registered under Care Standards Act 2000", value: "Yes – registered care home providing personal care" }, |
|
|
|
|
{ name: "Support services provided by", value: "A registered charity or voluntary organisation" }, |
|
|
|
|
{ name: "Organisation providing support", value: "Acme LTD Managing" }, |
|
|
|
|
{ name: "Primary client group", value: "Rough sleepers" }, |
|
|
|
|
{ name: "Has another client group", value: "Yes" }, |
|
|
|
|
{ name: "Secondary client group", value: "Refugees (permanent)" }, |
|
|
|
|
{ name: "Level of support given", value: "High level" }, |
|
|
|
|
{ name: "Intended length of stay", value: "Permanent" }, |
|
|
|
|
{ name: "Availability", value: "Active from 1 April 2022" }, |
|
|
|
|
{ name: "Status", value: status_tag(:active) }, |
|
|
|
|
] |
|
|
|
|
expect(display_scheme_attributes(scheme, coordinator_user)).to eq(attributes) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns correct display attributes for a coordinator user" do |
|
|
|
|
attributes = [ |
|
|
|
|
{ name: "Scheme code", value: "S19" }, |
|
|
|
|
{ name: "Name", value: "Test service_name", edit: true }, |
|
|
|
|
{ name: "Confidential information", value: "No", edit: true }, |
|
|
|
|
{ name: "Type of scheme", value: "Housing for older people" }, |
|
|
|
|
{ name: "Registered under Care Standards Act 2000", value: "Yes – registered care home providing personal care" }, |
|
|
|
|
{ name: "Support services provided by", value: "A registered charity or voluntary organisation" }, |
|
|
|
|
{ name: "Organisation providing support", value: "Acme LTD Managing" }, |
|
|
|
|
{ name: "Primary client group", value: "Rough sleepers" }, |
|
|
|
|
{ name: "Has another client group", value: "Yes" }, |
|
|
|
|
{ name: "Secondary client group", value: "Refugees (permanent)" }, |
|
|
|
|
{ name: "Level of support given", value: "High level" }, |
|
|
|
|
{ name: "Intended length of stay", value: "Permanent" }, |
|
|
|
|
{ name: "Availability", value: "Active from 1 April 2022" }, |
|
|
|
|
{ name: "Status", value: status_tag(:active) }, |
|
|
|
|
] |
|
|
|
|
expect(display_scheme_attributes(scheme, coordinator_user)).to eq(attributes) |
|
|
|
|
context "when the scheme toggle is disabled" do |
|
|
|
|
it "doesn't show the scheme status" do |
|
|
|
|
allow(FeatureToggle).to receive(:scheme_toggle_enabled?).and_return(false) |
|
|
|
|
attributes = display_scheme_attributes(scheme, support_user).find { |x| x[:name] == "Status" } |
|
|
|
|
expect(attributes).to be_nil |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the scheme toggle is disabled" do |
|
|
|
|
it "doesn't show the scheme status" do |
|
|
|
|
allow(FeatureToggle).to receive(:scheme_toggle_enabled?).and_return(false) |
|
|
|
|
attributes = display_scheme_attributes(scheme, support_user).find { |x| x[:name] == "Status" } |
|
|
|
|
expect(attributes).to be_nil |
|
|
|
|
end |
|
|
|
|
context "when the scheme toggle is disabled" do |
|
|
|
|
it "doesn't show the scheme status" do |
|
|
|
|
allow(FeatureToggle).to receive(:scheme_toggle_enabled?).and_return(false) |
|
|
|
|
attributes = display_scheme_attributes(scheme, support_user).find { |x| x[:name] == "Status" } |
|
|
|
|
expect(attributes).to be_nil |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when viewing availability" do |
|
|
|
|
context "with no deactivations" do |
|
|
|
|
|