Skip to content

Commit

Permalink
Restore logic which is still necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Dec 21, 2023
1 parent 407f809 commit b4b8cc3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/domain/pbs/export/tabular/people/participation_nds_row.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# Copyright (c) 2012-2023, Pfadibewegung Schweiz. This file is part of
# hitobito_pbs and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_pbs.

module Pbs::Export::Tabular::People::ParticipationNdsRow
extend ActiveSupport::Concern

included do
alias_method_chain :first_language, :language
end

def first_language_with_language
lang = entry.language.presence
lang ? lang.upcase : 'DE'
end
end
3 changes: 3 additions & 0 deletions lib/hitobito_pbs/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class Wagon < Rails::Engine
Export::Tabular::People::ParticipationRow.include(
Pbs::Export::Tabular::People::ParticipationRow
)
Export::Tabular::People::ParticipationNdsRow.include(
Pbs::Export::Tabular::People::ParticipationNdsRow
)
Export::Tabular::People::PersonRow.include Pbs::Export::Tabular::People::PersonRow
Export::Tabular::People::PeopleAddress.include Pbs::Export::Tabular::People::PeopleAddress
Export::Tabular::People::PeopleFull.include Pbs::Export::Tabular::People::PeopleFull
Expand Down
25 changes: 25 additions & 0 deletions spec/domain/export/tabular/people/participation_nds_row_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

# Copyright (c) 2012-2023, Pfadibewegung Schweiz. This file is part of
# hitobito_pbs and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_pbs.

require 'spec_helper'

describe Export::Tabular::People::ParticipationNdsRow do

let(:participation) { Fabricate(:pbs_participation, person: person, event: events(:top_course)) }

let(:row) { described_class.new(participation) }

context 'with language' do
let(:person) { Fabricate(:person, language: 'it') }
it { expect(row.fetch(:first_language)).to eq 'IT' }
end

context 'without language' do
let(:person) { Fabricate(:person, language: nil) }
it { expect(row.fetch(:first_language)).to eq 'DE' }
end
end

0 comments on commit b4b8cc3

Please sign in to comment.