Browse Source

Use find insted of select

pull/713/head
Kat 3 years ago
parent
commit
93151c496f
  1. 2
      app/models/derived_variables/case_log_variables.rb
  2. 2
      db/seeds.rb
  3. 2
      spec/factories/location.rb

2
app/models/derived_variables/case_log_variables.rb

@ -84,7 +84,7 @@ module DerivedVariables::CaseLogVariables
self.la = location.county
self.postcode_full = location.postcode
self.unittype_sh = TYPE_OF_UNIT_MAP[location.type_of_unit]
self.builtype = form.questions.find { |x| x.id == "builtype" }.answer_options.select { |_key, value| value["value"] == location.type_of_building }.keys.first
self.builtype = form.questions.find { |x| x.id == "builtype" }.answer_options.find { |_key, value| value["value"] == location.type_of_building }.first
wheelchair_adaptation_map = { 1 => 1, 0 => 2 }
self.wchair = wheelchair_adaptation_map[location.wheelchair_adaptation.to_i]
end

2
db/seeds.rb

@ -115,7 +115,7 @@ unless Rails.env.test?
postcode: "CU193AA",
name: "Rectory Road",
type_of_unit: 4,
type_of_building: "Purpose-built",
type_of_building: "Purpose built",
county: "Mid Sussex",
wheelchair_adaptation: 0,
)

2
spec/factories/location.rb

@ -4,7 +4,7 @@ FactoryBot.define do
postcode { Faker::Address.postcode.delete(" ") }
name { Faker::Address.street_name }
type_of_unit { Faker::Number.within(range: 1..6) }
type_of_building { Faker::Lorem.word }
type_of_building { "Purpose built" }
wheelchair_adaptation { 0 }
county { Faker::Address.state }
scheme

Loading…
Cancel
Save