|
|
|
|
@ -20,4 +20,39 @@ RSpec.describe OrganisationsHelper do
|
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "rent_periods_with_checked_attr" do |
|
|
|
|
let(:fake_rent_periods) do |
|
|
|
|
{ |
|
|
|
|
"1" => { "value" => "Every minute" }, |
|
|
|
|
"2" => { "value" => "Every decade" }, |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
allow(RentPeriod).to receive(:rent_period_mappings).and_return fake_rent_periods |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns rent_period_mappings" do |
|
|
|
|
actual = rent_periods_with_checked_attr |
|
|
|
|
expect(actual.keys).to eq RentPeriod.rent_period_mappings.keys |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when checked_periods is nil" do |
|
|
|
|
it "returns all rent periods with checked true" do |
|
|
|
|
actual = rent_periods_with_checked_attr |
|
|
|
|
checked_attrs = actual.values.map { |p| p[:checked] } |
|
|
|
|
expect(checked_attrs).to all be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when checked_periods is not nil" do |
|
|
|
|
it "returns the rent_periods with the correct values checked" do |
|
|
|
|
checked_rent_period = "1" |
|
|
|
|
actual = rent_periods_with_checked_attr(checked_periods: [checked_rent_period]) |
|
|
|
|
expect(actual[checked_rent_period][:checked]).to be true |
|
|
|
|
expect(actual["2"][:checked]).to be_falsey |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|