Browse Source

add optional fields

pull/95/head
magicmilo 3 years ago
parent
commit
d6c4027dd2
  1. 5
      app/models/case_log.rb
  2. 2
      spec/fixtures/complete_case_log.json

5
app/models/case_log.rb

@ -111,10 +111,9 @@ class CaseLog < ApplicationRecord
enum property_relet: DbEnums.polar, _suffix: true enum property_relet: DbEnums.polar, _suffix: true
enum armedforces: DbEnums.armed_forces, _suffix: true enum armedforces: DbEnums.armed_forces, _suffix: true
enum first_time_property_let_as_social_housing: DbEnums.polar, _suffix: true enum first_time_property_let_as_social_housing: DbEnums.polar, _suffix: true
enum do_you_know_the_postcode: DbEnums.polar, _suffix: true
enum do_you_know_the_local_authority: DbEnums.polar, _suffix: true
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze
OPTIONAL_FIELDS = %w[do_you_know_the_postcode do_you_know_the_local_authority].freeze
def self.editable_fields def self.editable_fields
attribute_names - AUTOGENERATED_FIELDS attribute_names - AUTOGENERATED_FIELDS
@ -224,7 +223,7 @@ private
end end
def mandatory_fields def mandatory_fields
required = attributes.except(*AUTOGENERATED_FIELDS) required = attributes.except(*(AUTOGENERATED_FIELDS + OPTIONAL_FIELDS))
dynamically_not_required = [] dynamically_not_required = []

2
spec/fixtures/complete_case_log.json vendored

@ -138,8 +138,6 @@
"postcod2": "w3", "postcod2": "w3",
"ppostc1": "w3", "ppostc1": "w3",
"ppostc2": "w3", "ppostc2": "w3",
"do_you_know_the_postcode": "Yes",
"do_you_know_the_local_authority": "Yes",
"why_dont_you_know_la": "Forgot", "why_dont_you_know_la": "Forgot",
"first_time_property_let_as_social_housing": "Yes", "first_time_property_let_as_social_housing": "Yes",
"type_property_most_recently_let_as": "Affordable rent basis", "type_property_most_recently_let_as": "Affordable rent basis",

Loading…
Cancel
Save