Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from hitobito/feature/2226-structured-addresses
Browse files Browse the repository at this point in the history
Adapt to changed columns
  • Loading branch information
kronn committed Jun 4, 2024
2 parents 4708fc6 + 6209178 commit 96a36a1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 57 deletions.
2 changes: 1 addition & 1 deletion app/models/kljb/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Kljb::Person
extend ActiveSupport::Concern

included do
Person::PUBLIC_ATTRS -= [:nickname]
Person::PUBLIC_ATTRS.delete(:nickname)
used_attributes.delete(:nickname)
end

Expand Down
118 changes: 62 additions & 56 deletions spec/domain/export/csv/groups/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,76 @@
let(:list) { group.self_and_descendants.without_deleted.includes(:contact) }
let(:data) { described_class.csv(list) }
let(:data_without_bom) { data.gsub(Regexp.new("^#{Export::Csv::UTF8_BOM}"), '') }
let(:csv) { CSV.parse(data_without_bom, headers: true, col_sep: Settings.csv.separator) }
let(:csv) { CSV.parse(data_without_bom, headers: true, col_sep: Settings.csv.separator) }

subject { csv }

it 'has the correct headers' do
expected = ['Id',
'Elterngruppe',
'Name',
'Kurzname',
'Gruppentyp',
'Haupt-E-Mail',
'Adresse',
'PLZ',
'Ort',
'Land',
'Geändert',
'Ebene',
'Beschreibung',
'Link zu Nextcloud',
'normale Mitglieder',
'vergünstigte Mitglieder',
'Telefonnummern',
'Anzahl Mitglieder',
'Social Media']
it 'has the correct headers' do
expected = ['Id',
'Elterngruppe',
'Name',
'Kurzname',
'Gruppentyp',
'Haupt-E-Mail',
'PLZ',
'Ort',
'Land',
'Geändert',
'Ebene',
'Beschreibung',
'Link zu Nextcloud',
'Strasse',
'Hausnummer',
'zusätzliche Adresszeile',
'Postfach',
'normale Mitglieder',
'vergünstigte Mitglieder',
'Telefonnummern',
'Anzahl Mitglieder',
'Social Media']

expect(subject.headers).to match_array expected
expect(subject.headers).to eq expected
end
expect(subject.headers).to match_array expected
expect(subject.headers).to eq expected
end

it 'has 4 items' do
expect(subject.size).to eq(16)
end
it 'has 4 items' do
expect(subject.size).to eq(16)
end

context 'first row' do
subject { csv[0] }
context 'first row' do
subject { csv[0] }

its(['Id']) { should == group.id.to_s }
its(['Elterngruppe']) { should == group.parent_id&.to_s }
its(['Name']) { should == group.name }
its(['Kurzname']) { should == group.short_name }
its(['Gruppentyp']) { should == 'Regionalverband' }
its(['Haupt-E-Mail']) { should == group.email }
its(['Adresse']) { should == group.address }
its(['PLZ']) { should == group.zip_code.to_s }
its(['Ort']) { should == group.town }
its(['Land']) { should == group.country_label }
its(['Ebene']) { should == group.id.to_s }
its(['normale Mitglieder']) { should be_blank }
its(['vergünstigte Mitglieder']) { should be_blank }
end
its(['Id']) { should == group.id.to_s }
its(['Elterngruppe']) { should == group.parent_id&.to_s }
its(['Name']) { should == group.name }
its(['Kurzname']) { should == group.short_name }
its(['Gruppentyp']) { should == 'Regionalverband' }
its(['Haupt-E-Mail']) { should == group.email }
its(['zusätzliche Adressezeile']) { should == group.address_care_of }
its(['Strasse']) { should == group.street }
its(['Hausnummer']) { should == group.housenumber }
its(['Postfach']) { should == group.postbox }
its(['PLZ']) { should == group.zip_code.to_s }
its(['Ort']) { should == group.town }
its(['Land']) { should == group.country_label }
its(['Ebene']) { should == group.id.to_s }
its(['normale Mitglieder']) { should be_blank }
its(['vergünstigte Mitglieder']) { should be_blank }
end

context 'group with members' do
subject { csv.find { |row| row['Name'] == group_with_members.name } }
let(:group_with_members) { groups(:paderborn) }
context 'group with members' do
subject { csv.find { |row| row['Name'] == group_with_members.name } }
let(:group_with_members) { groups(:paderborn) }

before do
group_with_members.update!(
members_normal: 23,
members_discounted: 7
)
end
before do
group_with_members.update!(
members_normal: 23,
members_discounted: 7
)
end

its(['Gruppentyp']) { should == 'Ortsgruppe' }
its(['normale Mitglieder']) { should == "23" }
its(['vergünstigte Mitglieder']) { should == "7" }
end
its(['Gruppentyp']) { should == 'Ortsgruppe' }
its(['normale Mitglieder']) { should == '23' }
its(['vergünstigte Mitglieder']) { should == '7' }
end
end

0 comments on commit 96a36a1

Please sign in to comment.