Commit 75828baa authored by Tugce Nur Tas's avatar Tugce Nur Tas

Merge branch 'develop' into 'master'

Merge develop into master for production development

See merge request !1008
parents 9f9f23a8 b96ceb2c
Pipeline #64424 passed with stage
in 41 minutes and 5 seconds
......@@ -31,3 +31,20 @@
.billing-expenses.new .table-scrollable {
max-height: 500px;
}
.table-multicolumn {
display: flex;
flex-wrap: wrap;
& > table:first-child {
margin-bottom: 0;
}
@media (min-width: $container-md) {
flex-wrap: nowrap;
& > table:not(:first-child) {
margin-left: 10px;
}
}
}
......@@ -18,7 +18,17 @@
body {
&.pdf {
.container {
padding-left: $container-sm / 12;
padding-left: 3.2cm;
}
.header {
padding-top: 1.4cm;
padding-left: 1.5cm;
padding-bottom: 1.6cm;
}
.col-input, .col-label {
font-size: 12px;
}
.col-xs-6 {
......@@ -118,3 +128,13 @@ body {
overflow: hidden;
height: 60px;
}
.row-no-top-padding {
padding-top: 0;
margin-top: 0;
}
.row-no-bottom-padding {
padding-bottom: 0 !important;
margin-bottom: 0 !important;
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ class BillingExpensesController < ApplicationController
billing_expenses.each do |billing_expense|
@billing_expense = billing_expense
merged_expenses << CombinePDF.parse(render_to_pdf('show.html'))
merged_expenses << CombinePDF.parse(render_to_pdf('show.html', layout: WickedPdf.config[:layout]))
end
send_data merged_expenses.to_pdf,
......
......@@ -19,9 +19,10 @@ module PdfHelpers
filename: pdf_file_name(record)
end
# currently only used for assignments
def save_with_pdf(record, action = 'show.html', options = {})
{ layout: 'pdf_layout.pdf.slim', zoom: 1.15,
dpi: 600, margin: { top: 10, bottom: 10, left: 0, right: 0 }
{ layout: 'assignments.pdf.slim', zoom: 1.15,
dpi: 600, margin: { top: 0, bottom: 10, left: 0, right: 14 },
}.each do |k,v|
next if options.key?(k)
options[k] = v
......
module ProcessedByConcern
extend ActiveSupport::Concern
included do
def register_acceptance_change(resource)
return unless resource.will_save_change_to_attribute?(:acceptance)
if resource.respond_to?("#{resource.acceptance}_by_id".to_sym)
resource["#{resource.acceptance}_by_id".to_sym] = current_user.id
end
end
end
end
class VolunteersController < ApplicationController
include ProcessedByConcern
before_action :set_volunteer, only: [:show, :edit, :update, :terminate, :account, :update_bank_details, :reactivate]
before_action :set_active_and_archived_missions, only: [:show, :edit]
......@@ -62,11 +63,16 @@ class VolunteersController < ApplicationController
def update
@volunteer.attributes = volunteer_params
return render :edit unless @volunteer.valid?
register_acceptance_change(@volunteer)
if @volunteer.will_save_change_to_attribute?(:acceptance, to: 'accepted') &&
@volunteer.internal? && !@volunteer.user && @volunteer.save
auto_assign_department!
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
......@@ -81,7 +87,7 @@ class VolunteersController < ApplicationController
def terminate
if @volunteer.terminatable?
@volunteer.terminate!
@volunteer.terminate!(current_user)
redirect_back fallback_location: edit_volunteer_path(@volunteer),
notice: 'Freiwillige/r wurde erfolgreich beendet.'
else
......@@ -120,6 +126,13 @@ class VolunteersController < ApplicationController
private
def auto_assign_department!
return if !current_user.department_manager? || current_user.department.empty? || @volunteer.department.present?
# association
@volunteer.update(department: current_user.department.first)
end
def not_resigned
return if params[:q]
@volunteers = @volunteers.not_resigned
......
......@@ -153,11 +153,18 @@ module ApplicationHelper
tag.abbr(abbr.to_s, title: full_term)
end
def show_status_date(record, *args)
tag.ul(class: "list-unstyled") do
def show_status_date(record, include_processing_person, *args)
tag.ul(class: "list-unstyled") do
record.slice(*args).compact.each do |key, value|
concat tag.li(t_attr(key) +' '+ l(value))
if include_processing_person
updated_by_attr = key.include?('_at') ? key.sub('_at', '_by') : nil
concat tag.li([
t_attr(key) +' '+ l(value), record.send(updated_by_attr).to_s
].reject(&:blank?).join(" #{I18n.t('by')} "))
else
concat tag.li(t_attr(key) +' '+ l(value))
end
end
end
end
end
end
......@@ -81,7 +81,7 @@ class Client < ApplicationRecord
}
def terminatable?
assignments.unterminated.none?
assignments.active_or_not_yet_active.none?
end
def self.acceptences_restricted
......
......@@ -17,6 +17,7 @@ module TerminationScopes
date_between_inclusion(:termination_submitted_at, start_date, end_date)
}
scope :no_active_assignments, -> { joins(:clients).where("period_end < ?", Time.zone.now)}
scope :unterminated, (-> { field_nil(:termination_verified_by_id) })
scope :terminated, (-> { field_not_nil(:termination_verified_by_id) })
......
......@@ -28,11 +28,19 @@ class Volunteer < ApplicationRecord
belongs_to :user, -> { with_deleted }, inverse_of: 'volunteer', optional: true
belongs_to :registrar, -> { with_deleted }, class_name: 'User', foreign_key: 'registrar_id', optional: true,
inverse_of: :volunteers
belongs_to :reactivated_by, class_name: 'User', inverse_of: 'reactivated_volunteers',
belongs_to :reactivated_by, -> { with_deleted }, class_name: 'User', inverse_of: 'reactivated_volunteers',
optional: true
belongs_to :department, optional: true
belongs_to :secondary_department, class_name: 'Department', optional: true
# accepance updating person
belongs_to :invited_by, -> { with_deleted }, class_name: 'User', optional: true
belongs_to :accepted_by, -> { with_deleted }, class_name: 'User', optional: true
belongs_to :resigned_by, -> { with_deleted }, class_name: 'User', optional: true
belongs_to :rejected_by, -> { with_deleted }, class_name: 'User', optional: true
belongs_to :undecided_by, -> { with_deleted }, class_name: 'User', optional: true
belongs_to :created_by, -> { with_deleted }, class_name: 'User', foreign_key: 'registrar_id', optional: true
has_one :registrar_department, through: :registrar
has_many :departments, through: :group_offers
......@@ -443,6 +451,10 @@ class Volunteer < ApplicationRecord
end
end
def undecided_by
super || registrar
end
def assignment_group_offer_collection
assignments_hour_form_collection + group_offers_form_collection
end
......@@ -491,9 +503,9 @@ class Volunteer < ApplicationRecord
['active', 'inactive', 'not_resigned', 'process_eq']
end
def terminate!
def terminate!(resigned_by)
self.class.transaction do
update(acceptance: :resigned, resigned_at: Time.zone.now)
update(acceptance: :resigned, resigned_at: Time.zone.now, resigned_by: resigned_by)
user&.destroy
end
end
......@@ -538,7 +550,7 @@ class Volunteer < ApplicationRecord
end
def reactivate!(user)
update!(acceptance: 'accepted', reactivated_by: user, reactivated_at: Time.zone.now, resigned_at: nil)
update!(acceptance: 'accepted', accepted_by: user, reactivated_by: user, reactivated_at: Time.zone.now, resigned_at: nil)
return true if external?
if user.present? && (user.sign_in_count.zero? || !user.invitation_accepted?)
......
......@@ -5,63 +5,63 @@ h4.m-b-10= t('assignment_pdf.volunteer_title')
.row.m-b-10
.col-xs-6
.row
.col-xs-3= t('assignment_pdf.last_name')
.col-xs-3.col-label= t('assignment_pdf.last_name')
.col-xs-7.col-input= @assignment.volunteer.contact.last_name
.col-xs-3= t('assignment_pdf.street')
.col-xs-3.col-label= t('assignment_pdf.street')
.col-xs-7.col-input= @assignment.volunteer.contact.street
.col-xs-3= t('assignment_pdf.telephone')
.col-xs-3.col-label= t('assignment_pdf.telephone')
.col-xs-7.col-input= @assignment.volunteer.contact.primary_phone
.col-xs-3= t('assignment_pdf.email')
.col-xs-3.col-label= t('assignment_pdf.email')
.col-xs-7.col-input= @assignment.volunteer.contact.primary_email
.col-xs-6
.row
.col-xs-5= t('assignment_pdf.first_name')
.col-xs-5.col-label= t('assignment_pdf.first_name')
.col-xs-7.col-input= @assignment.volunteer.contact.first_name
.col-xs-5 #{t('assignment_pdf.postal_code')} / #{t('assignment_pdf.city')}
.col-xs-5.col-label #{t('assignment_pdf.postal_code')} / #{t('assignment_pdf.city')}
.col-xs-7.col-input= @assignment.volunteer.contact.full_city
.col-xs-5= t('assignment_pdf.birth_year')
.col-xs-5.col-label= t('assignment_pdf.birth_year')
.col-xs-7.col-input= @assignment.volunteer.birth_year.try(:year)
h4.m-b-10= t('assignment_pdf.client_title')
.row.m-b-10
.col-xs-6
.row
.col-xs-3= t('assignment_pdf.last_name')
.col-xs-3.col-label= t('assignment_pdf.last_name')
.col-xs-7.col-input= @assignment.client.contact.last_name
.col-xs-3= t('assignment_pdf.street')
.col-xs-3.col-label= t('assignment_pdf.street')
.col-xs-7.col-input= @assignment.client.contact.street
.col-xs-3= t('assignment_pdf.telephone')
.col-xs-3.col-label= t('assignment_pdf.telephone')
.col-xs-7.col-input= @assignment.client.contact.primary_phone
.col-xs-3= t('assignment_pdf.email')
.col-xs-3.col-label= t('assignment_pdf.email')
.col-xs-7.col-input= @assignment.client.contact.primary_email
.col-xs-3= t('assignment_pdf.birth_year')
.col-xs-3.col-label= t('assignment_pdf.birth_year')
.col-xs-7.col-input= @assignment.client.birth_year.try(:year)
.col-xs-6
.row
.col-xs-5= t('assignment_pdf.first_name')
.col-xs-5.col-label= t('assignment_pdf.first_name')
.col-xs-7.col-input= @assignment.client.contact.first_name
.col-xs-5 #{t('assignment_pdf.postal_code')} / #{t('assignment_pdf.city')}
.col-xs-5.col-label #{t('assignment_pdf.postal_code')} / #{t('assignment_pdf.city')}
.col-xs-7.col-input #{@assignment.client.contact.postal_code} #{@assignment.client.contact.city}
.col-xs-5= t('assignment_pdf.telephone_2')
.col-xs-5.col-label= t('assignment_pdf.telephone_2')
.col-xs-7.col-input= @assignment.client.contact.secondary_phone
.col-xs-5 #{t('assignment_pdf.nationality')}, #{t('assignment_pdf.state')}
.col-xs-5.col-label #{t('assignment_pdf.nationality')}, #{t('assignment_pdf.state')}
.col-xs-7.col-input
= [nationality_name(@assignment.client.nationality), @assignment.client.permit].compact.reject(&:empty?).join(', ')
.col-xs-5= t('assignment_pdf.languages')
.col-xs-5.col-label= t('assignment_pdf.languages')
.col-xs-7.col-input
- @assignment.client.language_skills.each do |language|
= "#{language.language_name} "
......@@ -69,17 +69,17 @@ h4.m-b-10= t('assignment_pdf.client_title')
.row-box
.col-xs-12
.row
.col-xs-4= t('assignment_pdf.assignment_description')
.col-xs-4.col-label= t('assignment_pdf.assignment_description')
.col-xs-8.col-input = @assignment.assignment_description
.col-xs-4= t('assignment_pdf.frequency')
.col-xs-4.col-label= t('assignment_pdf.frequency')
.col-xs-8.col-input= @assignment.frequency
.col-xs-4= t('assignment_pdf.first_time')
.col-xs-4.col-label= t('assignment_pdf.first_time')
.col-xs-8.col-input= @assignment.first_meeting
.col-xs-4= t('assignment_pdf.trial_time')
.col-xs-4.col-label= t('assignment_pdf.trial_time')
.col-xs-8.col-input= @assignment.trial_period_end
.col-xs-4= t('assignment_pdf.duration')
.col-xs-4.col-label= t('assignment_pdf.duration')
.col-xs-8.col-input= @assignment.duration
.col-xs-4= t('assignment_pdf.special')
.col-xs-4.col-label= t('assignment_pdf.special')
.col-xs-8.col-input= @assignment.special_agreement
h4.m-b-10.m-t-20= t('assignment_pdf.creator_title')
......@@ -87,23 +87,23 @@ h4.m-b-10.m-t-20= t('assignment_pdf.creator_title')
.row.m-b-10
.col-xs-6
.row
.col-xs-3= t('assignment_pdf.last_name')
.col-xs-3.col-label= t('assignment_pdf.last_name')
.col-xs-9.col-input= @assignment.involved_authority_contact.last_name
.row
.col-xs-3= t('assignment_pdf.function')
.col-xs-3.col-label= t('assignment_pdf.function')
.col-xs-9.col-input= @assignment.involved_authority.profession
.row
.col-xs-3= t('assignment_pdf.email')
.col-xs-3.col-label= t('assignment_pdf.email')
.col-xs-9.col-input= @assignment.involved_authority_contact.primary_email
.col-xs-6
.row
.col-xs-3= t('assignment_pdf.first_name')
.col-xs-3.col-label= t('assignment_pdf.first_name')
.col-xs-9.col-input= @assignment.involved_authority_contact.first_name
.row
.col-xs-3= t('assignment_pdf.organization')
.col-xs-3.col-label= t('assignment_pdf.organization')
.col-xs-9.col-input= @assignment.involved_authority_contact.full_address
.row
.col-xs-3= t('assignment_pdf.telephone')
.col-xs-3.col-label= t('assignment_pdf.telephone')
.col-xs-9.col-input= @assignment.involved_authority_contact.primary_phone
.row-box
......
......@@ -65,5 +65,6 @@ nav.navbar.section-navigation.hidden-print
- else
= link_to 'Dossier Freiwillig Engagiert', volunteer_certificate_path(assignment.volunteer, assignment.volunteer.certificates.last)
= link_to 'Freiwillige/n beenden', terminate_volunteer_path(assignment.volunteer), method: :put unless assignment.volunteer.resigned?
= link_to 'Klient/in beenden', set_terminated_client_path(assignment.client), method: :patch unless assignment.client.resigned?
= bootstrap_paginate(@assignments)
......@@ -11,7 +11,7 @@ h1
ul.list-inline
li= clear_filter_button
= custom_filter_dropdown(t_attr(:semester, BillingExpense), *@billing_semester_filters)
li=> f.button :submit, 'Auswahl herunterladen', data: { disable_with: false }
li= f.button :submit, 'Auswahl herunterladen', data: { disable_with: false }
li
- if @volunteer
=> button_link icon_span(:back), @volunteer
......
......@@ -7,7 +7,7 @@
data: { confirm: t('.reactivate.confirm') }
hr.m-y-30
fieldset
= show_status_date(@client, :created_at)
= show_status_date(@client, false, :created_at)
.row
.col-xs-12.col-md-6
......
......@@ -2,7 +2,7 @@ h1.m-b-20= @client.contact.full_name
= render 'show_navigation'
.table-responsive.m-t-20
.table-responsive.table-multicolumn.m-t-20
table.table.table-no-border-top
tbody
tr
......@@ -75,7 +75,9 @@ h1.m-b-20= @client.contact.full_name
tr
td= t_attr(:created_at)
td= l(@client.created_at)
- if policy(Client).show_comments?
- if policy(Client).show_comments?
table.table.table-no-border-top.table-right
tbody
tr
td= t_attr(:comments_internal)
td= @client.comments
......
doctype html
html.pdf-export-html
head
= csrf_meta_tags
= wicked_pdf_stylesheet_link_tag 'application'
= wicked_pdf_stylesheet_link_tag 'pdf_styles'
= wicked_pdf_javascript_include_tag 'application'
body.pdf
.header
.row.row-no-top-padding.row-no-bottom-padding
.col-xs-3
.pdf-logo-image
.logo-image = wicked_pdf_image_tag 'AOZ_Logo.svg'
.row.row-no-top-padding.row-no-bottom-padding
.col-xs-3
.col-xs-3
b= t('pdf_header.title').html_safe
.col-xs-3
- if controller_name == 'assignments'
= ContactHelper.address_for_pdf(@assignment&.creator.profile.contact).html_safe
- elsif controller_name == 'group_offers'
= ContactHelper.address_for_pdf(@group_offer&.creator.profile.contact).html_safe
- else
= t('pdf_header.address').html_safe
.col-xs-3
- if controller_name == 'assignments'
== t('pdf_header.contact', phone: @assignment&.creator.profile.contact.primary_phone, email: @assignment&.creator.profile.contact.primary_email)
- elsif controller_name == 'group_offers'
== t('pdf_header.contact', phone: @group_offer&.creator.profile.contact.primary_phone, email: @group_offer&.creator.profile.contact.primary_email)
- elsif controller_name == 'billing_expenses'
== t('pdf_header.contact', phone: @billing_expense&.user.profile.contact.primary_phone, email: 'freiwillige@aoz.ch')
- else
== t('pdf_header.contact', phone: '044 415 66 72', email: 'freiwillige@aoz.ch')
.container
= yield
......@@ -6,7 +6,7 @@ html.pdf-export-html
title= t('voluntary_platform')
= wicked_pdf_stylesheet_link_tag 'certificate_pdf'
= wicked_pdf_stylesheet_link_tag 'pdf_styles'
= wicked_pdf_javascript_include_tag 'application'
body.pdf-export
......
......@@ -3,7 +3,7 @@ html.pdf-export-html
head
= csrf_meta_tags
= wicked_pdf_stylesheet_link_tag 'application'
= wicked_pdf_stylesheet_link_tag 'certificate_pdf'
= wicked_pdf_stylesheet_link_tag 'pdf_styles'
= wicked_pdf_javascript_include_tag 'application'
body.pdf
.container
......
h1= t('.title', email: @terminated.termination_submitted_by.email)
- if @terminated.assignment?
p= link_to t('.link_text.terminated_assignment'), terminated_index_assignments_url(@link_params)
p= link_to t('.link_text.terminated_assignment'), terminated_index_assignments_url
- elsif @terminated.group_assignment?
p= link_to t('.link_text.terminated_group_assignment'), terminated_index_group_assignments_url(@link_params)
p= link_to t('.link_text.terminated_group_assignment'), terminated_index_group_assignments_url
p AOZ Fachstelle Freiwilligenarbeit
......@@ -2,10 +2,10 @@
<% if @terminated.assignment? %>
<%= t('.link_text.terminated_assignment') %>:
<%= url_for(terminated_index_assignments_url(@link_params)) %>
<%= url_for(terminated_index_assignments_url) %>
<% elsif @terminated.group_assignment? %>
<%= t('.link_text.terminated_group_assignment') %>:
<%= url_for(terminated_index_group_assignments_url(@link_params)) %>
<%= url_for(terminated_index_group_assignments_url) %>
<% end %>
AOZ Fachstelle Freiwilligenarbeit
......@@ -13,7 +13,7 @@
legend= t('.acceptance.management')
= acceptance_select(@volunteer, f)
- unless @volunteer.undecided?
= show_status_date(@volunteer, :created_at, :invited_at, :accepted_at, :undecided_at, :rejected_at, :resigned_at)
= show_status_date(@volunteer, true, :created_at, :invited_at, :accepted_at, :undecided_at, :rejected_at, :resigned_at)
= f.input :external, input_html: { data: { hide: ['bank-data', 'checklist'] }, class: 'volunteer-active-checkbox-changes' }
......
......@@ -25,8 +25,8 @@ h2.small Persönlicher Hintergrund
.row
.col-xs-12.col-md-4
fieldset
= show_status_date(@volunteer, :created_at)
.table-responsive
= show_status_date(@volunteer, true, :created_at, :invited_at, :accepted_at, :undecided_at, :rejected_at, :resigned_at)
.table-responsive.table-multicolumn
table.table.table-no-border-top
tbody
tr
......@@ -87,7 +87,9 @@ h2.small Persönlicher Hintergrund
= t('volunteer_self_applicant')
- else
= link_to @volunteer.registrar.full_name, profile_url_path(@volunteer.registrar)
- if policy(Volunteer).show_comments?
- if policy(Volunteer).show_comments?
table.table.table-no-border-top
tbody
tr
td= t_attr(:comments_internal)
td= @volunteer.comments
......
......@@ -11,4 +11,4 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += ['pdf.css', 'certificate_pdf.css']
Rails.application.config.assets.precompile += ['pdf.css', 'pdf_styles.css']
......@@ -4,6 +4,7 @@ de:
actions: Aktionen
expand_all: Alle anzeigen
collapse_all: Alle einklappen
by: von
generic_keys: &id-generic_keys
salutation: Anrede
first_name: Vorname
......
class AddVolunteerProcessedBy < ActiveRecord::Migration[5.1]
def change
change_table :volunteers do |t|
t.references :invited_by
t.references :accepted_by
t.references :resigned_by
t.references :rejected_by
t.references :undecided_by
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20191122122407) do
ActiveRecord::Schema.define(version: 20191122135842) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -832,8 +832,14 @@ ActiveRecord::Schema.define(version: 20191122122407) do
t.bigint "reactivated_by_id"
t.datetime "reactivated_at"
t.bigint "secondary_department_id"
t.bigint "invited_by_id"
t.bigint "accepted_by_id"
t.bigint "resigned_by_id"
t.bigint "rejected_by_id"
t.bigint "undecided_by_id"
t.index ["acceptance"], name: "index_volunteers_on_acceptance"
t.index ["accepted_at"], name: "index_volunteers_on_accepted_at"
t.index ["accepted_by_id"], name: "index_volunteers_on_accepted_by_id"
t.index ["active"], name: "index_volunteers_on_active"
t.index ["activeness_might_end"], name: "index_volunteers_on_activeness_might_end"
t.index ["birth_year"], name: "index_volunteers_on_birth_year"
......@@ -841,12 +847,16 @@ ActiveRecord::Schema.define(version: 20191122122407) do
t.index ["department_id"], name: "index_volunteers_on_department_id"
t.index ["external"], name: "index_volunteers_on_external"
t.index ["invited_at"], name: "index_volunteers_on_invited_at"
t.index ["invited_by_id"], name: "index_volunteers_on_invited_by_id"
t.index ["nationality"], name: "index_volunteers_on_nationality"
t.index ["reactivated_by_id"], name: "index_volunteers_on_reactivated_by_id"
t.index ["rejected_at"], name: "index_volunteers_on_rejected_at"
t.index ["rejected_by_id"], name: "index_volunteers_on_rejected_by_id"
t.index ["resigned_at"], name: "index_volunteers_on_resigned_at"
t.index ["resigned_by_id"], name: "index_volunteers_on_resigned_by_id"
t.index ["salutation"], name: "index_volunteers_on_salutation"
t.index ["undecided_at"], name: "index_volunteers_on_undecided_at"
t.index ["undecided_by_id"], name: "index_volunteers_on_undecided_by_id"
t.index ["user_id"], name: "index_volunteers_on_user_id"
end
......
......@@ -18,8 +18,8 @@ class NotificationMailerest < ActionMailer::TestCase
assert_match @other_superadmin.email, text
assert_match @other_superadmin.email, html
assert_match '/assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', text
assert_match '/assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', html
assert_match '/assignments/terminated_index', text
assert_match '/assignments/terminated_index', html
end
test 'termination_submitted group_assignment' do
......@@ -34,7 +34,7 @@ class NotificationMailerest < ActionMailer::TestCase
assert_match @other_superadmin.email, text
assert_match @other_superadmin.email, html
assert_match '/group_assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', text
assert_match '/group_assignments/terminated_index?q%5Btermination_verified_by_id_not_null%5D=true', html
assert_match '/group_assignments/terminated_index', text
assert_match '/group_assignments/terminated_index', html
end
end
......@@ -44,22 +44,26 @@ class VolunteerTest < ActiveSupport::TestCase
end
test 'when an internal volunteer gets terminated will be marked as resigned' do
superadmin = create :user, role: 'superadmin'
volunteer = create :volunteer, external: false
assert volunteer.valid?
volunteer.terminate!
volunteer.terminate!(superadmin)
volunteer.reload
assert volunteer.resigned?
assert_equal volunteer.resigned_by, superadmin
refute volunteer.active?
refute volunteer.user.present?
end
test 'terminate_volunteer_without_user' do
superadmin = create :user, role: 'superadmin'
volunteer = create :volunteer, external: true, acceptance: :accepted
assert_nil volunteer.user
volunteer.terminate!
volunteer.terminate!(superadmin)
assert_equal volunteer.resigned_by, superadmin
assert volunteer.resigned?
end
......
......@@ -33,6 +33,40 @@ class AssignmentTerminationIndexTest < ApplicationSystemTestCase
refute_text termination_index_table_text(@verified)
end
test 'client with no active assignments can be terminated' do
Assignment.destroy_all
client = create :client
assignment1 = create :assignment, client: client, period_start: 3.weeks.ago, period_end: 2.days.ago, period_end_set_by: @superadmin
assignment2 = create :assignment, client: client, period_start: 3.weeks.ago, period_end: nil
refute client.resigned?
visit assignments_path
click_link 'Beendete Begleitungen'
assert_text termination_index_table_text(assignment1)
refute_text termination_index_table_text(assignment2)
click_link 'Klient/in beenden'
assert_text 'Beenden fehlgeschlagen.'
refute client.resigned?
assert page.has_link? 'Klient/in beenden'
assignment2.update(period_end: 4.days.ago, period_end_set_by: @superadmin)
visit current_url
assert_text termination_index_table_text(assignment1)
assert_text termination_index_table_text(assignment2)
click_link 'Klient/in beenden', match: :first
refute page.has_link? 'Klient/in beenden'
assert_text 'Klient/in wurde erfolgreich beendet.'
assert client.reload.resigned?
end
test 'filtering_submitted_terminations' do
visit terminated_index_assignments_path
click_link 'Ende Bestätigt'
......