Skip to content

Commit

Permalink
add language mapping for nds export
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Oct 20, 2023
1 parent 9f9370d commit 8b1000e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/domain/export/tabular/people/participation_nds_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

module Export::Tabular::People
class ParticipationNdsRow < Export::Tabular::People::PersonRow
NDS_LANGUAGE_MAPPING = %w[DE FR IT].to_h { [_1, _1] }.freeze
NDS_LANGUAGES = %w[DE FR IT].freeze

attr_reader :participation

Expand Down Expand Up @@ -69,7 +69,8 @@ def email_work
end

def first_language
NDS_LANGUAGE_MAPPING.fetch(entry.language.presence&.to_s&.upcase, 'Andere')
language = entry.language.presence&.to_s&.upcase
NDS_LANGUAGES.include?(language) ? language : 'Andere'
end

def second_language
Expand Down
18 changes: 18 additions & 0 deletions spec/domain/export/tabular/people/participation_nds_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
it { expect(row.fetch(:nationality_j_s)).to eq 'ANDERE' }
end

describe 'first_language' do
context 'with supported language' do
before do
person.language = :fr
end

it { expect(row.fetch(:first_language)).to eq 'FR' }
end

context 'with unsupported language' do
before do
person.language = :en
end

it { expect(row.fetch(:first_language)).to eq 'Andere' }
end
end

describe 'j_s_number format' do
before do
person.j_s_number = '169-55-79'
Expand Down

0 comments on commit 8b1000e

Please sign in to comment.