Browse Source

Default to dislpaying all

pull/487/head
baarkerlounger 3 years ago
parent
commit
58f4431dd7
  1. 6
      app/models/organisation.rb
  2. 12
      spec/models/organisation_spec.rb

6
app/models/organisation.rb

@ -42,7 +42,8 @@ class Organisation < ApplicationRecord
end
def local_authority_names
local_authorities.map { |ons_code| LocalAuthority.ons_code_mappings[ons_code] }
names = local_authorities.map { |ons_code| LocalAuthority.ons_code_mappings[ons_code] }
names.present? ? names : ["All"]
end
def rent_periods
@ -50,7 +51,8 @@ class Organisation < ApplicationRecord
end
def rent_period_labels
rent_periods.map { |period| RentPeriod.rent_period_mappings[period.to_s]["value"] }
labels = rent_periods.map { |period| RentPeriod.rent_period_mappings[period.to_s]["value"] }
labels.present? ? labels : ["All"]
end
def display_attributes

12
spec/models/organisation_spec.rb

@ -57,6 +57,12 @@ RSpec.describe Organisation, type: :model do
end
end
context "when the organisation has not specified which local authorities it operates in" do
it "displays `all`" do
expect(organisation.local_authority_names).to eq(%w[All])
end
end
context "when the organisation only uses specific rent periods" do
let(:rent_period_mappings) do
{ "2" => { "value" => "Weekly for 52 weeks" }, "3" => { "value" => "Every 2 weeks" } }
@ -77,6 +83,12 @@ RSpec.describe Organisation, type: :model do
end
end
context "when the organisation has not specified which rent periods it uses" do
it "displays `all`" do
expect(organisation.rent_period_labels).to eq(%w[All])
end
end
context "with case logs" do
let(:other_organisation) { FactoryBot.create(:organisation) }
let!(:owned_case_log) do

Loading…
Cancel
Save