Skip to content

Commit

Permalink
Merge pull request #10362 from DFE-Digital/cv/fix-ethnic-background-bug
Browse files Browse the repository at this point in the history
Fix ethnic background form no method error
  • Loading branch information
CatalinVoineag authored Feb 11, 2025
2 parents 0e75c33 + 93e636e commit da92bc6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def save(application_form)
end

def self.listed_ethnic_background?(group, background)
ETHNIC_BACKGROUNDS[group].include?(background) || OTHER_ETHNIC_BACKGROUNDS[group] == background
ETHNIC_BACKGROUNDS[group]&.include?(background) || OTHER_ETHNIC_BACKGROUNDS[group] == background
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,21 @@
describe 'validations' do
it { is_expected.to validate_presence_of(:ethnic_background) }
end

describe '.listed_ethnic_background?' do
it 'returns true if the group and background are in the ethnic backgrounds' do
result = described_class.listed_ethnic_background?('Another ethnic group', 'Arab')
expect(result).to be_truthy
end

it 'returns false if the group and background are not the ethnic backgrounds' do
result = described_class.listed_ethnic_background?('Another ethnic group', 'Another ethnic group')
expect(result).to be_falsey
end

it 'returns false if the group does not exist' do
result = described_class.listed_ethnic_background?('wrong group', '')
expect(result).to be_falsey
end
end
end

0 comments on commit da92bc6

Please sign in to comment.