Skip to content

Commit

Permalink
refactoring: Removing inclusion validation on region for ASCOR country
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomas committed Feb 9, 2024
1 parent e8dfcac commit d55a7f8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion app/admin/ascor/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
f.inputs do
f.input :name
f.input :iso, label: 'Country ISO code'
f.input :region, as: :select, collection: ASCOR::Country::REGIONS
f.input :region
f.input :wb_lending_group, as: :select, collection: ASCOR::Country::LENDING_GROUPS, label: 'World Bank lending group'
f.input :fiscal_monitor_category, as: :select, collection: ASCOR::Country::MONITOR_CATEGORIES,
label: 'International Monetary Fund fiscal monitor category'
Expand Down
9 changes: 0 additions & 9 deletions app/models/ascor/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ class ASCOR::Country < ApplicationRecord
include VisibilityStatus
extend FriendlyId

REGIONS = [
'Africa',
'Asia',
'Europe',
'Latin America and Caribbean',
'North America',
'Oceania'
].freeze
LENDING_GROUPS = %w[High-income Upper-middle-income Lower-middle-income Low-income].freeze
MONITOR_CATEGORIES = [
'Advanced economies',
Expand All @@ -49,7 +41,6 @@ class ASCOR::Country < ApplicationRecord

validates_presence_of :name, :slug, :iso, :region, :wb_lending_group, :fiscal_monitor_category
validates_uniqueness_of :name, :slug, :iso
validates :region, inclusion: {in: REGIONS}, allow_nil: true
validates :wb_lending_group, inclusion: {in: LENDING_GROUPS}, allow_nil: true
validates :fiscal_monitor_category, inclusion: {in: MONITOR_CATEGORIES}, allow_nil: true
validates :type_of_party, inclusion: {in: TYPE_OF_PARTY}, allow_nil: true
Expand Down
5 changes: 0 additions & 5 deletions spec/models/ascor/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
expect(subject).to have(1).errors_on(:iso)
end

it 'should be invalid if region is not in REGIONS' do
subject.region = 'TEST'
expect(subject).to have(1).errors_on(:region)
end

it 'should be invalid if wb_lending_group is not in LENDING_GROUPS' do
subject.wb_lending_group = 'TEST'
expect(subject).to have(1).errors_on(:wb_lending_group)
Expand Down

0 comments on commit d55a7f8

Please sign in to comment.