Commit d1c3da85 authored by Beat Seeliger's avatar Beat Seeliger
Browse files

Merge branch 'features/responsibility_filter_on_spvindex' into 'develop'

Features/responsibility filter on spvindex

See merge request !847
parents cdd2c1ff 0cbb0293
Pipeline #30985 passed with stage
in 37 minutes and 22 seconds
......@@ -39,8 +39,10 @@ class SemesterProcessVolunteersController < ApplicationController
def index
authorize SemesterProcessVolunteer
@spvs = SemesterProcessVolunteer.index(Semester.parse(params[:semester])).page(params[:page])
@spvs_sorted = @spvs.sort { |spv1, spv2| spv1.volunteer.contact.full_name <=> spv2.volunteer.contact.full_name}
@q = SemesterProcessVolunteer.index(Semester.parse(params[:semester])).ransack(params[:q])
@q.sorts = ['volunteer_contact_last_name asc'] if @q.sorts.empty?
@spvs = @q.result.paginate(page: params[:page])
set_responsibles
end
def show; end
......@@ -104,6 +106,19 @@ class SemesterProcessVolunteersController < ApplicationController
end
end
def set_responsibles
@responsibles = SemesterProcessVolunteer.joins(responsible: [profile: [:contact]])
.distinct
.select('users.id, contacts.full_name')
.map do |responsible|
{
q: :responsible_id_eq,
text: "Übernommen von #{responsible.full_name}",
value: responsible.id
}
end
end
def semester_process_volunteer_params
params.require(:semester_process_volunteer).permit(:semester)
end
......
nav.navbar.section-navigation
hr
ul.list-inline
li= clear_filter_button
li= button_link 'Neuen Semester Prozess erstellen', new_semester_process_path, dimension: 'sm'
li= render 'semester_filter'
= custom_filter_dropdown('Übernommen',
{ q: :responsible_id_null, text: 'Offen', value: 'true' },
{ q: :responsible_id_not_null, text: 'Übernommen', value: 'true' },
*@responsibles)
hr
......@@ -19,10 +19,10 @@ h1= t_title(:index)
th Bemerkungen
th= t_attr(:commited_by)
th Letzte Bestätigung
th Aktionen
th= sort_link @q, :responsible_profile_contact_full_name, 'Übernommen'
tbody
- @spvs_sorted.each do |spv|
- @spvs.each do |spv|
tr
td.index-action-cell.hidden-print
= button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten'
......
......@@ -4,6 +4,7 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase
setup do
@superadmin = create :user
@volunteer = create :volunteer_with_user
@volunteer.contact.update(first_name: 'Walter', last_name: 'White')
@assignment = create :assignment, volunteer: @volunteer
@group_assignment = create :group_assignment, volunteer: @volunteer
......@@ -24,4 +25,83 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase
assert page.has_text? "Übernommen durch #{@superadmin.email}"\
" am #{I18n.l(@spv1.responsibility_taken_at.to_date)}"
end
test 'take responsibility for semester process volunteer filter works' do
login_as @superadmin
visit semester_process_volunteers_path
## SETUP ##
# Offen/open -> @spv1
# Übernommen/responsibility taken over from superadmin1
@volunteer2 = create :volunteer_with_user
@volunteer2.contact.update(first_name: 'volunteer2', last_name: 'volunteer2')
@spv2 = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer2,
semester_process: create(:semester_process))
@superadmin2 = create :user
@spv2.update(responsible: @superadmin2)
# Übernommen/responsibility taken over from superadmin2
@volunteer3 = create :volunteer_with_user
@volunteer3.contact.update(first_name: 'volunteer3', last_name: 'volunteer3')
@spv3 = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer3,
semester_process: create(:semester_process))
@superadmin3 = create :user
@spv3.update(responsible: @superadmin3)
## SETUP END ##
# filter for Alle/all
within page.find_all('nav.section-navigation').last do
click_link 'Übernommen'
click_link 'Alle'
end
visit current_url
within 'tbody' do
assert page.find("[data-url$=\"#{take_responsibility_semester_process_volunteer_path(@spv1)}\"]")
end
assert page.has_text? "Übernommen durch #{@superadmin2.email}"\
" am #{I18n.l(@spv2.responsibility_taken_at.to_date)}"
assert page.has_text? "Übernommen durch #{@superadmin3.email}"\
" am #{I18n.l(@spv3.responsibility_taken_at.to_date)}"
# filter for Offen/open
within page.find_all('nav.section-navigation').last do
click_link 'Übernommen'
click_link 'Offen'
end
visit current_url
within 'tbody' do
assert page.find("[data-url$=\"#{take_responsibility_semester_process_volunteer_path(@spv1)}\"]")
end
refute page.has_text? "Übernommen durch #{@superadmin2.email}"\
" am #{I18n.l(@spv2.responsibility_taken_at.to_date)}"
refute page.has_text? "Übernommen durch #{@superadmin3.email}"\
" am #{I18n.l(@spv3.responsibility_taken_at.to_date)}"
# filter for Übernommen/responsibility taken over in general
click_link 'Übernommen: Offen', match: :first
within 'li.dropdown.open' do
click_link 'Übernommen'
end
visit current_url
refute page.has_link? 'Übernehmen', href: take_responsibility_semester_process_volunteer_path(@spv1)
assert page.has_text? "Übernommen durch #{@superadmin2.email}"\
" am #{I18n.l(@spv2.responsibility_taken_at.to_date)}"
assert page.has_text? "Übernommen durch #{@superadmin3.email}"\
" am #{I18n.l(@spv3.responsibility_taken_at.to_date)}"
# filter for Übernommen von superadmin1/responsibility taken over by superadmin1
click_link 'Übernommen: Übernommen', match: :first
within 'li.dropdown.open' do
assert page.has_link? "Übernommen von #{@superadmin2.profile.contact.full_name}"
assert page.has_link? "Übernommen von #{@superadmin3.profile.contact.full_name}"
click_link "Übernommen von #{@superadmin2.profile.contact.full_name}"
end
visit current_url
refute page.has_link? 'Übernehmen', href: take_responsibility_semester_process_volunteer_path(@spv1)
assert page.has_text? "Übernommen durch #{@superadmin2.email}"\
" am #{I18n.l(@spv2.responsibility_taken_at.to_date)}"
refute page.has_text? "Übernommen durch #{@superadmin3.email}"\
" am #{I18n.l(@spv3.responsibility_taken_at.to_date)}"
end
end
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