Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
3ab62797
Commit
3ab62797
authored
Feb 01, 2018
by
Tugce Nur Tas
Browse files
Merge branch 'features/gruppenangebot-quittieren' into 'develop'
Features/gruppenangebot quittieren See merge request
!462
parents
6adcbac7
93fa16c8
Pipeline
#13957
failed with stage
in 20 minutes and 26 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/controllers/group_assignments_controller.rb
View file @
3ab62797
...
...
@@ -108,6 +108,15 @@ class GroupAssignmentsController < ApplicationController
authorize
@group_assignment
end
def
create_update_redirect
if
@group_assignment
.
saved_change_to_period_end?
(
from:
nil
)
redirect_to
terminated_index_group_assignments_path
(
q:
{
termination_verified_by_id_null:
'true'
}),
notice:
'Die Einsatzbeendung wurde initiiert.'
else
redirect_to
@group_assignment
.
group_offer
,
make_notice
end
end
def
group_assignment_params
params
.
require
(
:group_assignment
).
permit
(
:period_start
,
:period_end
,
:termination_submitted_at
,
:terminated_at
,
:responsible
,
...
...
app/models/group_assignment.rb
View file @
3ab62797
...
...
@@ -3,8 +3,7 @@ class GroupAssignment < ApplicationRecord
include
GroupAssignmentCommon
after_save
:update_group_offer_search_field
after_update
:handle_archive_after_update_or_destroy
,
if: :dates_updated_or_termination_verified?
before_destroy
:handle_archive_after_update_or_destroy
before_destroy
:create_log_of_self_and_delete_self
has_many
:group_assignment_logs
...
...
@@ -20,12 +19,18 @@ class GroupAssignment < ApplicationRecord
scope
:running
,
(
->
{
no_end
.
have_start
})
def
save_group_assignment_logs
create_log_of_self
(
period_start_before_last_save
,
period_end_before_last_save
)
def
termination_verifiable?
ended?
&&
termination_submitted_by
.
present?
end
def
verify_termination
(
user
)
update
(
termination_verified_by:
user
,
termination_verified_at:
Time
.
zone
.
now
)
create_log_of_self
end
def
create_log_of_self
(
start_date
=
period_start
,
end_date
=
period_end
)
GroupAssignmentLog
.
create!
(
return
false
if
running?
# prevent deleting of running group assignment
GroupAssignmentLog
.
create
(
attributes
.
except
(
'id'
,
'created_at'
,
'updated_at'
,
'active'
)
.
merge
(
title:
group_offer
.
title
,
group_assignment_id:
id
,
period_start:
start_date
,
period_end:
end_date
)
...
...
@@ -52,23 +57,10 @@ class GroupAssignment < ApplicationRecord
true
end
def
verify_termination
(
user
)
update
(
termination_verified_by:
user
,
termination_verified_at:
Time
.
zone
.
now
)
end
private
def
handle_archive_after_update_or_destroy
if
!
saved_change_to_termination_verified_by_id?
(
from:
nil
)
create_log_of_self
(
period_start_before_last_save
,
period_end_before_last_save
)
elsif
create_log_of_self
&&
!
running?
delete
end
end
def
dates_updated_or_termination_verified?
saved_change_to_period_start?
||
saved_change_to_period_end?
||
saved_change_to_termination_verified_by_id?
(
from:
nil
)
def
create_log_of_self_and_delete_self
delete
if
create_log_of_self
end
def
update_group_offer_search_field
...
...
app/views/group_assignments/terminated_index.html.slim
View file @
3ab62797
...
...
@@ -5,7 +5,8 @@ nav.navbar.section-navigation.hidden-print
ul
.list-inline
li
=
button_link
'Zurück zu Gruppenangeboten'
,
group_offers_path
,
dimension: :sm
li
=
button_link
'Filter aufheben'
,
terminated_index_group_assignments_path
(q:
{
termination_verified_by_id_null:
'true'
}),
dimension:
:
sm
terminated_index_group_assignments_path
(q:
{
termination_verified_by_id_null:
'true'
}),
dimension
:
:
sm
=
custom_filter_dropdown
('Ende
Bestätigt',
{
q
:
:termination_submitted_by_id_not_null,
text:
'Bestätigt',
value:
'true'
},
{
q
:
:termination_submitted_by_id_null,
text:
'Unbestätigt',
value:
'true'
})
...
...
@@ -52,11 +53,9 @@ nav.navbar.section-navigation.hidden-print
=
link_to
'Freiwillige/n beenden'
,
'#'
-
if
policy
(
GroupAssignment
).
verify_termination?
td
-
if
assignment
.
termination_verified_by
.
blank?
=
link_to
'Beendigung Quittieren'
,
verify_termination_group_assignment_path
(
assignment
),
class:
'btn btn-default'
,
data:
{
method:
'PATCH'
}
-
else
=
"Quittiert von "
=
link_to
assignment
.
termination_verified_by
.
full_name
,
profile_link
(
assignment
.
termination_verified_by
)
=
" am
#{
l
(
assignment
.
termination_verified_at
.
to_date
)
}
"
=
link_to_if
(
assignment
.
termination_verified_by
.
blank?
,
'Beendigung Quittieren'
,
verify_termination_group_assignment_path
(
assignment
),
class:
'btn btn-default'
,
data:
{
method:
'PATCH'
})
do
=
"Quittiert von "
=
link_to
assignment
.
termination_verified_by
.
full_name
,
profile_link
(
assignment
.
termination_verified_by
)
=
" am
#{
l
(
assignment
.
termination_verified_at
.
to_date
)
}
"
app/views/group_offers/show.html.slim
View file @
3ab62797
...
...
@@ -85,24 +85,22 @@ h2= @group_offer.title
th
Funktion
th
Anfangsdatum
th
Enddatum
th
Beendet
th
Archiviert
am
th
Begleitung
Beendet
th
Archiviert
tbody
-
@group_offer
.
group_assignment_logs
.
order
(
'created_at
de
sc'
).
each
do
|
ga_log
|
-
@group_offer
.
group_assignment_logs
.
order
(
'created_at
a
sc'
).
each
do
|
ga_log
|
tr
td
=
link_to_if
(
policy
(
Volunteer
).
show?
,
ga_log
.
volunteer
.
contact
.
full_name
,
volunteer_path
(ga_log
.volunteer
))
{
ga_log
.volunteer.contact.full_name
}
td
=
ga_log
.
responsible
?
t_attr
(
:responsible
,
GroupAssignment
)
:
t_attr
(
:member
,
GroupAssignment
)
td
=
l
(
ga_log
.
period_start
)
if
ga_log
.
period_start
td
=
l
(
ga_log
.
period_end
)
if
ga_log
.
period_end
td
=
l
(
ga_log
.
period_end_set_by
.
updated_at
)
td
-
if
ga_log
.
termination_verified_by
.
blank?
=
boolean_glyph
(
false
)
-
else
=
"Quittiert von "
=
link_to
ga_log
.
termination_verified_by
.
full_name
,
profile_link
(
ga_log
.
termination_verified_by
)
=
" am
#{
l
(
ga_log
.
termination_verified_at
.
to_date
)
}
"
td
=
l
(
ga_log
.
created_at
)
-
unless
params
[
:format
]
==
'pdf'
=
form_navigation_btn
:edit
...
...
test/models/group_assignment_archive_test.rb
View file @
3ab62797
require
'test_helper'
class
GroupAssignmentArchiveTest
<
ActiveSupport
::
TestCase
test
'change_period_start_create
s
_log'
do
test
'change_period_start_
does_not_
create
_a
_log'
do
group_assignment
=
create
:group_assignment
,
period_start:
100
.
days
.
ago
,
period_end:
nil
assert
group_assignment
.
group_assignment_logs
.
size
.
zero?
group_assignment
.
update
(
period_start:
50
.
days
.
ago
)
group_assignment
.
reload
assert_equal
group_assignment
,
group_assignment
.
group_assignment_logs
.
first
.
group_assignment
assert
group_assignment
.
present?
refute
group_assignment
.
group_assignment_logs
.
any?
end
test
'set_period_end_create
s
_log'
do
test
'set_period_end_
does_not_
create
_a
_log'
do
group_assignment
=
create
:group_assignment
,
period_start:
100
.
days
.
ago
,
period_end:
nil
assert
group_assignment
.
group_assignment_logs
.
size
.
zero?
group_assignment
.
update
(
period_end:
2
.
days
.
ago
)
group_assignment
.
reload
assert_equal
group_assignment
,
group_assignment
.
group_assignment_logs
.
first
.
group_assignment
assert
group_assignment
.
ended?
refute
group_assignment
.
group_assignment_logs
.
any?
end
test
'terminating_group_assignment_creates_log_
and
_deletes_self'
do
test
'terminating_group_assignment_creates_log_
but_not
_deletes_self'
do
superadmin
=
create
:user
group_assignment
=
create
:group_assignment
,
period_start:
100
.
days
.
ago
,
period_end:
3
.
days
.
ago
,
group_assignment
=
create
:group_assignment
,
period_start:
100
.
days
.
ago
,
period_end:
3
.
days
.
ago
,
period_end_set_by:
superadmin
,
termination_submitted_at:
2
.
days
.
ago
,
termination_submitted_by:
superadmin
assert
group_assignment
.
group_assignment_logs
.
size
.
zero?
group_assignment
.
update
(
termination_verified_at:
Time
.
zone
.
now
,
termination_verified_by:
superadmin
)
group_assignment
.
verify_termination
(
superadmin
)
group_assignment
.
reload
assert_equal
group_assignment
,
group_assignment
.
group_assignment_logs
.
first
.
group_assignment
assert
group_assignment
.
deleted?
assert
group_assignment
.
group_assignment_logs
.
first
.
group_assignment
refute
group_assignment
.
deleted?
end
test
'destroying_group_assignment_create
s
_log'
do
test
'destroying_group_assignment_
does_not_
create_log
_if_not_verified
'
do
group_assignment
=
create
:group_assignment
,
period_start:
100
.
days
.
ago
,
period_end:
nil
assert
group_assignment
.
group_assignment_logs
.
size
.
zero?
group_assignment
.
destroy
group_assignment
.
reload
assert_equal
group_assignment
,
group_assignment
.
group_assignment_logs
.
first
.
group_assignment
refute
group_assignment
.
group_assignment_logs
.
any?
assert
group_assignment
.
deleted?
end
...
...
test/models/group_assignment_scopes_test.rb
View file @
3ab62797
...
...
@@ -127,7 +127,7 @@ class GroupAssignmentScopesTest < ActiveSupport::TestCase
refute
query
.
include?
started_no_end
refute
query
.
include?
started_with_end
assert
query
.
include?
submitted
refute
query
.
include?
verified
assert
query
.
include?
verified
end
test
'termination_not_submitted scope test'
do
...
...
@@ -189,7 +189,7 @@ class GroupAssignmentScopesTest < ActiveSupport::TestCase
refute
query
.
include?
started_no_end
refute
query
.
include?
started_with_end
refute
query
.
include?
submitted
refute
query
.
include?
verified
assert
query
.
include?
verified
query_deleted
=
GroupAssignment
.
with_deleted
.
terminated
refute
query_deleted
.
include?
started_no_end
refute
query_deleted
.
include?
started_with_end
...
...
test/system/group_assignment_termination_index_test.rb
View file @
3ab62797
...
...
@@ -12,10 +12,16 @@ class GroupAssignmentTerminationIndexTest < ApplicationSystemTestCase
@not_ended
=
create
:group_assignment
,
group_offer:
@group_offer1
,
volunteer:
@volunteer1
,
period_start:
3
.
weeks
.
ago
,
period_end:
nil
@un_submitted
=
create
:group_assignment
,
group_offer:
@group_offer1
,
volunteer:
@volunteer2
,
period_start:
3
.
weeks
.
ago
,
period_end:
2
.
days
.
ago
period_start:
3
.
weeks
.
ago
,
period_end:
2
.
days
.
ago
,
period_end_set_by:
@superadmin
@submitted
=
create
:group_assignment
,
group_offer:
@group_offer1
,
volunteer:
@volunteer3
,
period_start:
3
.
weeks
.
ago
,
period_end:
2
.
days
.
ago
,
termination_submitted_at:
2
.
days
.
ago
,
termination_submitted_by:
@volunteer3
.
user
termination_submitted_at:
2
.
days
.
ago
,
termination_submitted_by:
@volunteer3
.
user
,
period_end_set_by:
@superadmin
@verified
=
create
:group_assignment
,
group_offer:
@group_offer1
,
volunteer:
@volunteer4
,
period_start:
3
.
weeks
.
ago
,
period_end:
2
.
days
.
ago
,
termination_submitted_at:
2
.
days
.
ago
,
termination_submitted_by:
@volunteer4
.
user
,
period_end_set_by:
@superadmin
,
termination_verified_at:
2
.
days
.
ago
,
termination_verified_by:
@superadmin
login_as
@superadmin
end
...
...
@@ -33,6 +39,7 @@ class GroupAssignmentTerminationIndexTest < ApplicationSystemTestCase
assert
page
.
has_text?
termination_index_table_text
(
@un_submitted
)
assert
page
.
has_text?
termination_index_table_text
(
@submitted
)
refute
page
.
has_text?
termination_index_table_text
(
@not_ended
)
refute
page
.
has_text?
termination_index_table_text
(
@verified
)
end
test
'filtering_submitted_terminations'
do
...
...
@@ -53,6 +60,32 @@ class GroupAssignmentTerminationIndexTest < ApplicationSystemTestCase
refute
page
.
has_text?
termination_index_table_text
(
@submitted
)
end
test
'filtering_for_only_verified'
do
visit
terminated_index_group_assignments_path
(
q:
{
termination_verified_by_id_null:
'true'
})
click_link
'Quittiert: Unquittiert'
click_link
exact_text:
'Quittiert'
visit
current_url
refute
page
.
has_text?
termination_index_table_text
(
@un_submitted
)
refute
page
.
has_text?
termination_index_table_text
(
@submitted
)
assert
page
.
has_text?
termination_index_table_text
(
@verified
)
end
test
'ended_assignment_can_be_verified'
do
visit
group_offers_path
click_link
'Beendete Begleitungen'
assert
page
.
has_text?
termination_index_table_text
(
@un_submitted
)
assert
page
.
has_text?
termination_index_table_text
(
@submitted
)
refute
page
.
has_text?
termination_index_table_text
(
@verified
)
page
.
find_all
(
'a'
,
text:
'Beendigung Quittieren'
).
first
.
click
click_link
'Beendigung Quittieren'
assert
page
.
has_text?
'Beendete Gruppen Begleitungen'
refute
page
.
has_text?
termination_index_table_text
(
@un_submitted
)
refute
page
.
has_text?
termination_index_table_text
(
@submitted
)
refute
page
.
has_text?
termination_index_table_text
(
@verified
)
end
test
'clear_filter_link_is_working_correctly'
do
visit
group_offers_path
click_link
'Beendete Begleitungen'
...
...
@@ -67,6 +100,7 @@ class GroupAssignmentTerminationIndexTest < ApplicationSystemTestCase
assert
page
.
has_text?
termination_index_table_text
(
@un_submitted
)
assert
page
.
has_text?
termination_index_table_text
(
@submitted
)
refute
page
.
has_text?
termination_index_table_text
(
@not_ended
)
refute
page
.
has_text?
termination_index_table_text
(
@verified
)
end
test
'there_is_correct_links_to_the_termination_forms'
do
...
...
@@ -83,26 +117,41 @@ class GroupAssignmentTerminationIndexTest < ApplicationSystemTestCase
href:
new_volunteer_certificate_path
(
@submitted
.
volunteer
.
id
)
end
test
'group_assignment_quittieren_creates_a_group_assignment_log_record_from_group_assignment'
do
visit
terminated_index_group_assignments_path
(
q:
{
termination_verified_by_id_null:
'true'
})
click_link
'Beendigung Quittieren'
,
href:
verify_termination_group_assignment_path
(
@submitted
.
id
)
assert
page
.
has_text?
'Der Gruppeneinsatz wurde erfolgreich quittiert.'
assert_equal
@submitted
,
GroupAssignmentLog
.
find_by
(
group_assignment_id:
@submitted
.
id
).
group_assignment
end
test
'there_is_correct_links_on_email_status_column'
do
create
:email_template_termination
visit
terminated_index_group_assignments_path
(
q:
{
termination_verified_by_id_null:
'true'
})
# Assignment has an end-date, but no reminder mailing was created
#
Group
Assignment has an end-date, but no reminder mailing was created
click_link
'Beendigungs Email erstellen'
,
href:
new_termination_group_assignment_reminder_mailings_path
(
@un_submitted
)
click_button
'Erstellen und Vorschau anzeigen'
# Assignment has an end-date, reminder mailing was created, but not sent
#
Group
Assignment has an end-date, reminder mailing was created, but not sent
visit
terminated_index_group_assignments_path
(
q:
{
termination_verified_by_id_null:
'true'
})
click_link
'Nicht versandt'
,
href:
reminder_mailing_path
(
@un_submitted
.
reminder_mailings
.
termination
.
last
)
click_link
'Nicht versandt'
,
href:
reminder_mailing_path
(
@un_submitted
.
reminder_mailings
.
termination
.
last
)
click_link
'Email versenden'
assert
page
.
has_text?
'Beendigungs-Email wird versendet.'
# Assignment has an end-date, reminder mailing was created and was sent
#
Group
Assignment has an end-date, reminder mailing was created and was sent
visit
terminated_index_group_assignments_path
(
q:
{
termination_verified_by_id_null:
'true'
})
@un_submitted
.
reload
mailing
=
@un_submitted
.
reminder_mailings
.
termination
.
last
assert
page
.
has_link?
"Übermittelt am
#{
I18n
.
l
(
mailing
.
updated_at
.
to_date
)
}
"
,
href:
reminder_mailing_path
(
mailing
)
assert
page
.
has_link?
'Übermittelt am '
,
href:
reminder_mailing_path
(
@un_submitted
.
reminder_mailings
.
termination
.
last
)
click_link
'Beendigung Quittieren'
,
href:
/group_assignments\/
#{
@un_submitted
.
id
}
\/verify_termination/
assert
page
.
has_text?
'Der Gruppeneinsatz wurde erfolgreich quittiert.'
visit
terminated_index_group_assignments_path
(
q:
{
termination_verified_by_id_not_null:
'true'
})
@un_submitted
.
reload
assert
page
.
has_text?
"Quittiert von
#{
@un_submitted
.
termination_verified_by
.
full_name
}
am"
\
"
#{
I18n
.
l
(
@un_submitted
.
termination_verified_at
.
to_date
)
}
"
end
end
test/system/group_offers_test.rb
View file @
3ab62797
...
...
@@ -96,7 +96,7 @@ class GroupOffersTest < ApplicationSystemTestCase
refute
page
.
has_link?
'Download'
end
test
'modifying volunteer dates create
s
log entry'
do
test
'modifying volunteer dates
does not
create
a
log entry'
do
login_as
create
(
:user
)
volunteer
=
create
:volunteer
group_offer
=
create
:group_offer
,
volunteers:
[
volunteer
]
...
...
@@ -105,20 +105,6 @@ class GroupOffersTest < ApplicationSystemTestCase
assert
page
.
has_text?
'Active group offers'
assert
page
.
has_link?
group_offer
.
title
refute
page
.
has_text?
'Group offers log'
group_offer
.
group_assignments
.
last
.
update
(
period_start:
7
.
months
.
ago
,
period_end:
2
.
months
.
ago
)
visit
volunteer_path
(
volunteer
)
assert
page
.
has_text?
'Active group offers'
assert
page
.
has_text?
'Group offers log'
assert
page
.
has_link?
group_offer
.
title
,
count:
2
group_offer
.
group_assignments
.
last
.
update
(
period_end:
3
.
months
.
ago
)
visit
volunteer_path
(
volunteer
)
assert
page
.
has_text?
'Active group offers'
assert
page
.
has_text?
'Group offers log'
assert
page
.
has_link?
group_offer
.
title
,
count:
3
end
test
'deleting group offer creates log and does not crash volunteer show'
do
...
...
test/system/remove_volunteer_group_offers_test.rb
View file @
3ab62797
...
...
@@ -42,12 +42,6 @@ class RemoveVolunteerGroupOffersTest < ApplicationSystemTestCase
assert
page
.
has_link?
'Beendigungsformular an Freiwillige/n'
,
href:
polymorphic_path
([
@ga1
,
ReminderMailing
],
action: :new_termination
)
end
within
'.log-table'
do
assert
page
.
has_text?
"
#{
@ga1
.
volunteer
.
contact
.
full_name
}
"
\
"
#{
@ga1
.
responsible
?
'Responsible'
:
'Member'
}
#{
I18n
.
l
(
@ga1
.
period_start
)
}
"
assert
page
.
has_text?
I18n
.
l
(
@ga1
.
group_assignment_logs
.
first
.
created_at
)
refute
page
.
has_text?
I18n
.
l
(
@ga1
.
period_end
)
end
end
test
'changing_volunteer_to_member_works'
do
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment