Commit c8ba917e authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

fix volunteer email ref problem and seeds bug

parent cb98e696
......@@ -34,7 +34,7 @@ class VolunteersController < ApplicationController
state_was_registered = @volunteer.registered?
return render :edit unless @volunteer.update(volunteer_params)
if state_was_registered && @volunteer.accepted? && invite_volunteer_user
redirect_to volunteers_path, notice: t('invite_sent', email: @volunteer.email)
redirect_to volunteers_path, notice: t('invite_sent', email: @volunteer.contact.contact_emails.first.body)
else
redirect_to @volunteer, notice: t('volunteer_updated')
end
......@@ -49,7 +49,7 @@ class VolunteersController < ApplicationController
def invite_volunteer_user
new_user = User.new(
email: @volunteer.email, password: Devise.friendly_token,
email: @volunteer.contact.contact_emails.first.body, password: Devise.friendly_token,
role: 'volunteer', volunteer: @volunteer
)
new_user.save && new_user.invite!
......
......@@ -154,5 +154,5 @@ Volunteer.state_collection_for_reviewed.each do |state|
volunteer.region = ['city', 'region', 'canton'].sample
volunteer.language_skills = make_lang_skills
volunteer.schedules << make_schedule
end
end.save
end
......@@ -44,6 +44,7 @@ class VolunteersTest < ApplicationSystemTestCase
fill_in 'Professional skills that you could bring?', with: 'asdf'
fill_in 'What are your most important leisure interests?', with: 'asdf'
page.choose('volunteer_duration_short')
page.check('volunteer_culture')
page.check('volunteer_family')
page.check('volunteer_training')
page.check('volunteer_adults')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment