expected_selection=[OpenStruct.new(id:"Wheelchair-user standard",name:"Wheelchair-user standard",description:"The majority of units are suitable for someone who uses a wheelchair and offer the full use of all rooms and facilities."),
OpenStruct.new(id:"Fitted with equipment and adaptations",name:"Fitted with equipment and adaptations",description:"For example, the majority of units have been fitted with stairlifts, ramps, level access showers or grab rails."),
OpenStruct.new(id:"None",name:"None",description:"The majority of units are not designed to wheelchair-user standards or fitted with any equipment and adaptations.")]
expected_selection=[OpenStruct.new(id:"Wheelchair-user standard",name:"Wheelchair-user standard",description:"Suitable for someone who uses a wheelchair and offers the full use of all rooms and facilities."),
OpenStruct.new(id:"Fitted with equipment and adaptations",name:"Fitted with equipment and adaptations",description:"Fitted with stairlifts, ramps, level access showers or grab rails."),
OpenStruct.new(id:"None",name:"None",description:"Not designed to wheelchair-user standards or fitted with any equipment or adaptations.")]
it"does add an error when the postcode is invalid"do
it"does add an error when units is nil"do
location.units=nil
expect{location.save!}
.toraise_error(ActiveRecord::RecordInvalid,"Validation failed: Units #{I18n.t('activerecord.errors.models.location.attributes.units.blank')}")
location.valid?(:units)
expect(location.errors.count).toeq(1)
end
end
describe"#type_of_unit"do
let(:location){FactoryBot.build(:location)}
it"does add an error when the postcode is invalid"do
it"does add an error when the type_of_unit is nil"do
location.type_of_unit=nil
expect{location.save!}
.toraise_error(ActiveRecord::RecordInvalid,"Validation failed: Type of unit #{I18n.t('activerecord.errors.models.location.attributes.type_of_unit.blank')}")