Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
aoz-003
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
aoz-003
Commits
c64cd677
Commit
c64cd677
authored
Nov 29, 2019
by
Jiri Strojil
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat/cancellation of clients
parent
1767d558
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
1 deletion
+58
-1
app/models/client.rb
app/models/client.rb
+1
-1
app/models/concerns/termination_scopes.rb
app/models/concerns/termination_scopes.rb
+1
-0
app/views/assignments/terminated_index.html.slim
app/views/assignments/terminated_index.html.slim
+1
-0
test/system/assignment_termination_index_test.rb
test/system/assignment_termination_index_test.rb
+34
-0
test/system/clients_test.rb
test/system/clients_test.rb
+21
-0
No files found.
app/models/client.rb
View file @
c64cd677
...
...
@@ -81,7 +81,7 @@ class Client < ApplicationRecord
}
def
terminatable?
assignments
.
unterminated
.
none?
assignments
.
active_or_not_yet_active
.
none?
end
def
self
.
acceptences_restricted
...
...
app/models/concerns/termination_scopes.rb
View file @
c64cd677
...
...
@@ -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
)
})
...
...
app/views/assignments/terminated_index.html.slim
View file @
c64cd677
...
...
@@ -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
)
test/system/assignment_termination_index_test.rb
View file @
c64cd677
...
...
@@ -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'
...
...
test/system/clients_test.rb
View file @
c64cd677
...
...
@@ -145,6 +145,27 @@ class ClientsTest < ApplicationSystemTestCase
I18n
.
l
(
with_assignment
.
created_at
.
to_date
)
end
test
'client cannot be terminated if has active missions'
do
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?
login_as
@superadmin
visit
client_path
(
client
)
find_all
(
"a[href='
#{
set_terminated_client_path
(
client
)
}
']"
).
first
.
click
page
.
driver
.
browser
.
switch_to
.
alert
.
accept
assert_text
'Klient/in kann nicht beendet werden, solange noch ein laufendes Tandem existiert.'
assignment2
.
update
(
period_end:
1
.
day
.
ago
)
find_all
(
"a[href='
#{
set_terminated_client_path
(
client
)
}
']"
).
last
.
click
page
.
driver
.
browser
.
switch_to
.
alert
.
accept
assert_text
'Klient/in wurde erfolgreich beendet.'
assert
client
.
reload
.
resigned?
end
test
'all_needed_actions_are_available_in_the_index'
do
use_rack_driver
client
=
create
:client
...
...
Write
Preview
Markdown
is supported
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