Browse Source

style: correct indentation in spec/helpers/schemes_helper_spec.rb

pull/987/head
Sam Seed 4 years ago
parent
commit
e8bb7d638d
  1. 146
      spec/helpers/schemes_helper_spec.rb

146
spec/helpers/schemes_helper_spec.rb

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

Loading…
Cancel
Save