Skip to content

Commit

Permalink
Delete fabricated people after migration spec
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWalkingLeek committed Nov 23, 2023
1 parent 331ebdb commit cc30c90
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions spec/migrations/migrate_nationality_to_new_nds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@
let(:migration) { described_class.new.tap { |m| m.verbose = false } }

context 'up' do
it 'updates nationality_j_s from DIV to ANDERE' do
person_with_div_nationality = Fabricate(:person)
person_with_div_nationality.update_attribute(:nationality_j_s, 'DIV') # not in Person::NATIONALITIES_J_S
let(:person_with_div_nationality) do
p = Fabricate(:person)
p.update_attribute(:nationality_j_s, 'DIV') # not in Person::NATIONALITIES_J_S
p
end

person_with_ch_nationality = Fabricate(:person, nationality_j_s: 'CH')
let(:person_with_ch_nationality) { Fabricate(:person, nationality_j_s: 'CH') }

after do
person_with_div_nationality.delete
person_with_ch_nationality.delete
end

it 'updates nationality_j_s from DIV to ANDERE' do
event_contact_data_for_div_person = Event::ParticipationContactData.new(events(:top_event),
person_with_div_nationality)
expect(person_with_div_nationality.nationality_j_s).to eq('DIV')
Expand All @@ -30,18 +38,28 @@
expect(person_with_div_nationality.reload.nationality_j_s).to eq('ANDERE')
expect(event_contact_data_for_div_person.nationality_j_s).to eq('ANDERE')
expect(person_with_ch_nationality.reload.nationality_j_s).to eq('CH')
person_with_div_nationality.delete
person_with_ch_nationality.delete
end
end

context 'down' do
after { migration.up }

it 'updates nationality_j_s from ANDERE to DIV' do
person_with_andere_nationality = Fabricate(:person)
person_with_andere_nationality.update_attribute(:nationality_j_s, 'ANDERE')
let(:person_with_andere_nationality) do
p = Fabricate(:person)
p.update_attribute(:nationality_j_s, 'ANDERE')
p
end

person_with_ch_nationality = Fabricate(:person, nationality_j_s: 'CH')
let(:person_with_ch_nationality) { Fabricate(:person, nationality_j_s: 'CH') }

after do
person_with_andere_nationality.delete
person_with_ch_nationality.delete
end

it 'updates nationality_j_s from ANDERE to DIV' do
event_contact_data_for_div_person = Event::ParticipationContactData.new(events(:top_event),
person_with_andere_nationality)
expect(person_with_andere_nationality.nationality_j_s).to eq('ANDERE')
Expand All @@ -54,6 +72,8 @@
expect(person_with_andere_nationality.reload.nationality_j_s).to eq('DIV')
expect(event_contact_data_for_div_person.nationality_j_s).to eq('DIV')
expect(person_with_ch_nationality.reload.nationality_j_s).to eq('CH')
person_with_andere_nationality.delete
person_with_ch_nationality.delete
end
end
end

0 comments on commit cc30c90

Please sign in to comment.