Skip to content

Commit

Permalink
Update citext length
Browse files Browse the repository at this point in the history
  • Loading branch information
samnang committed Jan 9, 2025
1 parent cc532ec commit 15d008d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
9 changes: 9 additions & 0 deletions app/models/beneficiary_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ class BeneficiaryAddress < ApplicationRecord
enumerize :iso_country_code, in: ISO3166::Country.codes.freeze

belongs_to :beneficiary, class_name: "Contact"

validates :iso_region_code,
:administrative_division_level_2_code,
:administrative_division_level_2_name,
:administrative_division_level_3_code,
:administrative_division_level_3_name,
:administrative_division_level_4_code,
:administrative_division_level_4_name,
length: { maximum: 255 }
end
14 changes: 7 additions & 7 deletions app/request_schemas/v1/beneficiary_address_request_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class BeneficiaryAddressRequestSchema < JSONAPIRequestSchema
required(:type).filled(:str?, eql?: "address")
required(:attributes).value(:hash).schema do
required(:iso_country_code).filled(Types::UpcaseString, included_in?: Contact.iso_country_code.values)
required(:iso_region_code).filled(:string)
optional(:administrative_division_level_2_code).maybe(:string)
optional(:administrative_division_level_2_name).maybe(:string)
optional(:administrative_division_level_3_code).maybe(:string)
optional(:administrative_division_level_3_name).maybe(:string)
optional(:administrative_division_level_4_code).maybe(:string)
optional(:administrative_division_level_4_name).maybe(:string)
required(:iso_region_code).filled(:string, max_size?: 255)
optional(:administrative_division_level_2_code).maybe(:string, max_size?: 255)
optional(:administrative_division_level_2_name).maybe(:string, max_size?: 255)
optional(:administrative_division_level_3_code).maybe(:string, max_size?: 255)
optional(:administrative_division_level_3_name).maybe(:string, max_size?: 255)
optional(:administrative_division_level_4_code).maybe(:string, max_size?: 255)
optional(:administrative_division_level_4_name).maybe(:string, max_size?: 255)
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions app/request_schemas/v1/beneficiary_request_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class BeneficiaryRequestSchema < JSONAPIRequestSchema

optional(:address).filled(:hash).schema do
required(:iso_country_code).filled(Types::UpcaseString, included_in?: Contact.iso_country_code.values)
required(:iso_region_code).filled(:string)
optional(:administrative_division_level_2_code).maybe(:string)
optional(:administrative_division_level_2_name).maybe(:string)
optional(:administrative_division_level_3_code).maybe(:string)
optional(:administrative_division_level_3_name).maybe(:string)
optional(:administrative_division_level_4_code).maybe(:string)
optional(:administrative_division_level_4_name).maybe(:string)
required(:iso_region_code).filled(:string, max_size?: 255)
optional(:administrative_division_level_2_code).maybe(:string, max_size?: 255)
optional(:administrative_division_level_2_name).maybe(:string, max_size?: 255)
optional(:administrative_division_level_3_code).maybe(:string, max_size?: 255)
optional(:administrative_division_level_3_name).maybe(:string, max_size?: 255)
optional(:administrative_division_level_4_code).maybe(:string, max_size?: 255)
optional(:administrative_division_level_4_name).maybe(:string, max_size?: 255)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/requests/open_ews_api/v1/beneficiaries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
required: true
)


example "Fetch beneficiaries stats" do
account = create(:account)
create_list(:beneficiary, 2, account:, gender: "M")
Expand Down

0 comments on commit 15d008d

Please sign in to comment.