Commit cc379f1d authored by Jiri Strojil's avatar Jiri Strojil

Merge branch 'feat/assign-department-on-invited' into 'develop'

Automatically add department for invited

See merge request !1003
parents bf928d32 2ab6fe79
Pipeline #63328 failed with stage
in 48 minutes and 17 seconds
......@@ -72,6 +72,7 @@ class VolunteersController < ApplicationController
redirect_to(edit_volunteer_path(@volunteer),
notice: t('invite_sent', email: @volunteer.primary_email))
elsif @volunteer.save
auto_assign_department! if @volunteer.saved_change_to_attribute?(:acceptance) && @volunteer.invited?
redirect_to edit_volunteer_path(@volunteer), notice: t('volunteer_updated')
else
render :edit
......
......@@ -114,6 +114,24 @@ class VolunteersTest < ApplicationSystemTestCase
assert_equal volunteer.reload.department, department
end
test 'automatically assigned department if invited by department manager' do
volunteer = Volunteer.last
department = create :department
department_manager = create :department_manager, department: [department]
volunteer.update department: nil
volunteer.undecided!
login_as department_manager
visit edit_volunteer_path volunteer
select 'Eingeladen', from: 'Prozess'
click_button 'Freiwillige/n aktualisieren', match: :first
assert volunteer.reload.invited?
assert_equal volunteer.reload.department, department
end
test 'department will not be automatically assigned if already selected' do
volunteer = create :volunteer, acceptance: :undecided, waive: false
department1 = create :department
......
Markdown is supported
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