Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed Apr 3, 2017
2 parents 68cc1fd + 11596fd commit 60c5a95
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 55 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ AllCops:
- tmp/**/*
- spec/**/*
- test/**/*
- vendor/bundle/**/*
38 changes: 38 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
language: ruby
cache: bundler
branches:
only:
- master
- stable
env:
global:
- HEADLESS=true
- RAILS_DB_ADAPTER=mysql2
- RAILS_DB_NAME=hitobito_test
- RAILS_ENV=development
rvm:
- 1.9.3
- 2.0.0
- 2.1.7
- 2.2.3
- 2.3.1
- 2.4.0
matrix:
allow_failures:
- rvm: 2.4.0
install:
- unset BUNDLE_GEMFILE # we bundle in different directories
- cd .. && git clone https://github.com/hitobito/hitobito_youth.git hitobito_youth
- cd hitobito_youth && git checkout -f $([[ $TRAVIS_BRANCH = 'stable' ]] && echo 'stable' || echo 'master')
- cd .. && git clone https://github.com/hitobito/hitobito.git hitobito
- cd hitobito && git checkout -f $([[ $TRAVIS_BRANCH = 'stable' ]] && echo 'stable' || echo 'master')
- export HITOBITO_CORE_DIR=$PWD
- sed -i "s/^\(gem .mysql2.\),.*$/\1/" Gemfile
- cp -v Wagonfile.ci Wagonfile
- rvm use $TRAVIS_RUBY_VERSION --fuzzy
- gem install bundler --version 1.9.10
- bundle install --path vendor/bundle && bundle update mysql2
- for d in ../hitobito_*; do cd $d && cp -v $HITOBITO_CORE_DIR/Gemfile.lock ./ && rvm use $TRAVIS_RUBY_VERSION --fuzzy && bundle install --path vendor/bundle; done
- cd $HITOBITO_CORE_DIR && rvm use $TRAVIS_RUBY_VERSION --fuzzy
script:
- bundle exec rake db:create ci:wagon --trace
12 changes: 4 additions & 8 deletions app/domain/cevi/export/tabular/people/person_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@ module PersonRow
extend ActiveSupport::Concern

def canton
entry.canton_value
end

def correspondence_language
entry.correspondence_language_value
entry.canton_label
end

def confession
entry.confession_value
entry.confession_label
end

def salutation
entry.salutation_value
entry.salutation_label
end

def ortsgruppe_id
entry.ortsgruppe_value
entry.ortsgruppe_label
end

end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/event_participations_cevi_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module EventParticipationsCeviHelper

def format_ortsgruppe(participation)
participation.person.ortsgruppe_value
participation.person.ortsgruppe_label
end

def format_payed(participation)
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/people_cevi_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module PeopleCeviHelper
IdLabel = Struct.new(:id, :to_s)

def format_person_canton(person)
person.canton_value
person.canton_label
end

def possible_person_cantons
Expand All @@ -20,15 +20,15 @@ def possible_person_cantons
end

def format_person_confession(person)
person.confession_value
person.confession_label
end

def possible_person_confessions
candidates_from_i18n(:confessions)
end

def format_person_salutation(person)
person.salutation_value
person.salutation_label
end

def possible_person_salutations
Expand All @@ -44,7 +44,7 @@ def existing_person_nationalities
end

def format_person_ortsgruppe(person)
person.ortsgruppe_value
person.ortsgruppe_label
end

private
Expand Down
38 changes: 14 additions & 24 deletions app/models/cevi/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,41 +64,31 @@ module Cevi::Person
included do
Person::PUBLIC_ATTRS.push(:salutation_parents, :name_parents, :ortsgruppe_id)

CONFESSIONS = %w(ev rk ck none other).freeze
SALUTATIONS = %w(formal informal).freeze

belongs_to :ortsgruppe, class_name: 'Group::Ortsgruppe'
end

def canton
self[:canton]
end
include I18nSettable
include I18nEnums

def canton_value
Cantons.full_name(canton)
end
i18n_enum :confession, CONFESSIONS
i18n_setter :confession, CONFESSIONS

def confession_value
value_from_i18n(:confession)
i18n_enum :salutation, SALUTATIONS
i18n_setter :salutation, SALUTATIONS
end

def correspondence_language_value
value_from_i18n(:correspondence_language)
def canton
self[:canton]
end

def salutation_value
value_from_i18n(:salutation)
def canton_label
Cantons.full_name(canton)
end

def ortsgruppe_value
def ortsgruppe_label
ortsgruppe && (ortsgruppe.short_name || ortsgruppe.name)
end

private

def value_from_i18n(key)
value = send(key)

if value.present?
I18n.t("activerecord.attributes.person.#{key.to_s.pluralize}.#{value}")
end
end

end
7 changes: 2 additions & 5 deletions config/locales/models.cevi.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -808,13 +808,9 @@ de:
ck: Christkatholisch
none: Konfessionlos
other: Andere
_nil: unbekannt

correspondence_language: Korrespondenzsprache
correspondence_languages:
de: Deutsch
fr: Französisch
it: Italienisch

joined: Eintrittsdatum
j_s_number: J+S Nummer
member_card_number: Mitgliederkarte Nummer
Expand All @@ -827,6 +823,7 @@ de:
salutations:
formal: Sie
informal: Du
_nil: unbekannt

salutation_parents: Anrede Eltern
title: Titel
Expand Down
17 changes: 10 additions & 7 deletions db/seeds/development/1_people.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ def amount(role_type)

end

puzzlers = ['Pascal Zumkehr',
'Pierre Fritsch',
'Andreas Maierhofer',
'Andre Kunz',
'Roland Studer',
'Mathis Hofer',
'Bruno Santschi']
puzzlers = [
'Andre Kunz',
'Andreas Maierhofer',
'Bruno Santschi',
'Mathis Hofer',
'Matthias Viehweger',
'Pascal Zumkehr',
'Pierre Fritsch',
'Roland Studer',
]

devs = {}
puzzlers.each do |puz|
Expand Down
1 change: 1 addition & 0 deletions rubocop-must.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ AllCops:
- bin/**/*
- spec/**/*
- test/**/*
- vendor/**/*
2 changes: 1 addition & 1 deletion spec/domain/export/tabular/member_count_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def count(conditions = { year: 2012 })
end

def export(conditions = { year: 2012 })
Export::Tabular::MemberCount.csv(MemberCount.where(conditions))
Export::Tabular::MemberCount.csv(MemberCount.where(conditions).order(:id))
end

end
2 changes: 1 addition & 1 deletion spec/domain/export/tabular/people/person_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
its(['Anrede']) { should eq 'Sie' }
its(['Kanton']) { should eq 'Bern' }
its(['Konfession']) { should eq 'Römisch-katholisch' }
its(['Korrespondenzsprache']) { should eq 'Deutsch' }
its(['Korrespondenzsprache']) { should eq 'de' }
end
end
end
8 changes: 4 additions & 4 deletions spec/models/person_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
end
end

context 'canton_value' do
context 'canton_label' do

it 'is blank for nil value' do
expect(Person.new.canton_value).to be_blank
expect(Person.new.canton_label).to be_blank
end

it 'is blank for blank value' do
expect(Person.new(canton: '').canton_value).to be_blank
expect(Person.new(canton: '').canton_label).to be_blank
end

it 'is locale specific value for valid key' do
expect(Person.new(canton: 'be').canton_value).to eq 'Bern'
expect(Person.new(canton: 'be').canton_label).to eq 'Bern'
end
end

Expand Down

0 comments on commit 60c5a95

Please sign in to comment.