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
ce993e14
Commit
ce993e14
authored
Oct 18, 2017
by
Kaspar Vollenweider
👻
Committed by
Kaspar
Oct 20, 2017
Browse files
system tests and some fixes to get things up
parent
d6a60e68
Changes
9
Hide whitespace changes
Inline
Side-by-side
app/controllers/feedbacks_controller.rb
View file @
ce993e14
...
...
@@ -7,8 +7,13 @@ class FeedbacksController < ApplicationController
@feedbacks
=
policy_scope
(
Feedback
)
if
params
[
:group_offer_id
]
@feedbacks
=
@feedbacks
.
where
(
feedbackable_id:
params
[
:group_offer_id
])
@volunteer
=
current_user
.
volunteer
||
@feedbacks
.
first
.
volunteer
elsif
params
[
:assignment_id
]
@feedbacks
=
@feedbacks
.
where
(
feedbackable_id:
params
[
:assignment_id
])
@volunteer
=
Assignment
.
find
(
params
[
:assignment_id
]).
volunteer
elsif
params
[
:volunteer_id
]
@feedbacks
=
@feedbacks
.
where
(
volunteer_id:
params
[
:volunteer_id
])
@volunteer
=
Volunteer
.
find
(
params
[
:volunteer_id
])
end
end
...
...
app/controllers/volunteers_controller.rb
View file @
ce993e14
...
...
@@ -56,7 +56,7 @@ class VolunteersController < ApplicationController
def
seeking_clients
authorize
Volunteer
@q
=
specific_
policy_scope
(
:
seeking_clients
)
.
ransack
(
params
[
:q
])
@q
=
policy_scope
(
Volunteer
).
seeking_clients
.
ransack
(
params
[
:q
])
@seeking_clients
=
@q
.
result
.
paginate
(
page:
params
[
:page
])
end
...
...
app/views/assignments/_volunteer_index.html.slim
View file @
ce993e14
table
.table.table-striped
table
.table.table-striped
.assignments-table
thead
tr
th
=
t_model
(
Client
)
...
...
app/views/feedbacks/edit.html.slim
View file @
ce993e14
...
...
@@ -2,4 +2,4 @@ h1= t_title(:edit)
=
render
'form'
=
bootstrap_row_col
{
button_link
t
(
'back'
),
volunteer
_feedback_path
(
@volunteer
,
@feedback
)
}
=
bootstrap_row_col
{
button_link
t
(
'back'
),
@
volunteer
}
app/views/feedbacks/index.html.slim
View file @
ce993e14
...
...
@@ -31,4 +31,4 @@ table.table.table-striped
td
=
link_to
t_action
(
:destroy
),
url_for
([
record
.
feedbackable
,
record
]),
confirm_deleting
(
record
)
=
form_navigation_btn
:new
=
bootstrap_row_col
{
button_link
t
(
'back'
),
:back
}
=
bootstrap_row_col
{
button_link
t
(
'back'
),
@volunteer
||
:back
}
app/views/feedbacks/show.html.slim
View file @
ce993e14
...
...
@@ -26,4 +26,4 @@ h1= t_title(:show)
td
=
t
(
@feedback
.
conversation
)
=
form_navigation_btn
:edit
=
bootstrap_row_col
{
button_link
t
(
'back'
),
:back
}
=
bootstrap_row_col
{
button_link
t
(
'back'
),
@volunteer
}
app/views/volunteers/_group_assignments.html.slim
View file @
ce993e14
table
.table.table-striped
table
.table.table-striped
.group-assignments-table
thead
tr
th
=
t_attr
(
:title
,
GroupOffer
)
th
=
t_attr
(
:role
,
GroupAssignment
)
th
=
t_attr
(
:period_start
,
GroupAssignment
)
th
=
t_attr
(
:period_end
,
GroupAssignment
)
th
colspan
=
(
editable
=
=
'yes'
?
'6'
:
'2'
)
-
if
editable
th
colspan
=
'4'
-
if
policy
(
GroupOffer
).
edit?
th
=
' '
-
if
policy
(
GroupOffer
).
destroy?
th
=
' '
-
if
policy
(
GroupOffer
).
change_active_state?
th
=
' '
tbody
-
group_assignments
.
each
do
|
group_assignment
|
tr
...
...
@@ -18,7 +25,7 @@ table.table.table-striped
td
=
l
(
group_assignment
.
period_end
)
if
group_assignment
.
period_end
td
=
link_to
t_action
(
:show
),
group_offer_path
(
group_assignment
.
group_offer
)
td
=
link_to
t
(
'download'
),
group_offer_path
(
group_assignment
.
group_offer
,
format: :pdf
)
-
if
editable
==
'yes'
-
if
editable
-
if
policy
(
GroupOffer
).
edit?
td
=
link_to
t_action
(
:edit
),
edit_group_offer_path
(
group_assignment
.
group_offer
)
-
if
policy
(
GroupOffer
).
destroy?
...
...
@@ -26,3 +33,5 @@ table.table.table-striped
-
if
policy
(
GroupOffer
).
change_active_state?
td
=
link_to
"
#{
group_assignment
.
group_offer
.
active?
?
t
(
'.deactivate'
)
:
t
(
'.activate'
)
}
"
,
change_active_state_group_offer_path
(group_assignment
.group_offer
),
method:
:put,
remote:
:true
td
=
link_to
t_title
(
:new
,
Feedback
),
new_group_offer_feedback_path
(
group_assignment
.
group_offer
)
td
=
link_to
t_title
(
:index
,
Feedback
),
group_offer_feedbacks_path
(
group_assignment
.
group_offer
)
app/views/volunteers/show.html.slim
View file @
ce993e14
...
...
@@ -173,11 +173,11 @@ h3= t('.availability')
-
if
@volunteer
.
group_assignments
.
any?
h3
#assignments
=
t
(
'.group_assignments'
)
=
render
'group_assignments'
,
group_assignments:
@volunteer
.
group_assignments
,
editable:
'yes'
=
render
'group_assignments'
,
group_assignments:
@volunteer
.
group_assignments
,
editable:
true
-
if
@volunteer
.
group_assignment_logs
.
any?
h3
=
t
(
'.old_group_assignments'
)
=
render
'group_assignments'
,
group_assignments:
@volunteer
.
group_assignment_logs
,
editable:
'no'
=
render
'group_assignments'
,
group_assignments:
@volunteer
.
group_assignment_logs
,
editable:
false
nav
.navbar.section-navigation
ul
.list-inline
...
...
test/system/feedbacks_test.rb
View file @
ce993e14
...
...
@@ -10,27 +10,33 @@ class FeedbacksTest < ApplicationSystemTestCase
volunteer:
@volunteer
,
author:
@superadmin
,
comments:
'author superadmin'
login_as
@user_volunteer
@other_volunteer
=
create
:volunteer
,
user:
create
(
:user_volunteer
)
@group_offer
=
create
:group_offer
,
necessary_volunteers:
2
,
title:
'some_group_offer'
,
volunteers:
[
@volunteer
,
@other_volunteer
]
create
:feedback
,
feedbackable:
@group_offer
,
author:
@user_volunteer
,
volunteer:
@volunteer
,
comments:
'some_group_offer_feedback'
create
:feedback
,
feedbackable:
@group_offer
,
author:
@superadmin
,
volunteer:
@volunteer
,
comments:
'some_group_offer_superadmin_feedback'
create
:feedback
,
volunteer:
@other_volunteer
,
feedbackable:
@group_offer
,
author:
@superadmin
,
comments:
'other_volunteers_group_offer_feedback'
end
test
'volunteer can
create an
feedback'
do
test
'volunteer can
see assignment
feedback
s index
'
do
visit
root_url
click_link
'volunteer@example.com'
click_link
'Show profile'
click_link
'New Feedback'
fill_in
'Which were the most important goals during the last months?'
,
with:
'asdf'
fill_in
'What could have been achieved during the last months?'
,
with:
'asdf'
fill_in
'Should the assignment continue? If yes, with which goals?'
,
with:
'asdf'
fill_in
'Comments'
,
with:
'asdf'
page
.
check
(
'feedback_conversation'
)
click_button
'Create Feedback'
assert
page
.
has_text?
'Feedback was successfully created.'
within
'.assignments-table'
do
click_link
'Feedback index'
end
refute
page
.
has_text?
'author superadmin'
end
test
'volunteer can see
only h
er feedbacks'
do
test
'volunteer can see
group off
er feedbacks
index
'
do
visit
root_url
click_link
'volunteer@example.com'
click_link
'Show profile'
click_link
'Feedback index'
within
'.group-assignments-table'
do
click_link
'Feedback index'
end
refute
page
.
has_text?
'author superadmin'
end
...
...
@@ -46,23 +52,67 @@ class FeedbacksTest < ApplicationSystemTestCase
end
test
'group offer feedbacks index contains only the feedbacks related to that group offer'
do
group_offer
=
create
:group_offer
,
necessary_volunteers:
2
,
title:
'some_group_offer'
,
volunteers:
[
@volunteer
,
@other_volunteer
]
some_feedback
=
create
:feedback
,
feedbackable:
group_offer
,
author:
@user_volunteer
,
volunteer:
@volunteer
,
comments:
'some_feedback'
some_superadmin_feedback
=
create
:feedback
,
feedbackable:
group_offer
,
author:
@superadmin
,
volunteer:
@volunteer
,
comments:
'some_superadmin_feedback'
other_group_offer
=
create
:group_offer
,
necessary_volunteers:
2
,
title:
'some_other_group_offer'
,
volunteers:
[
@volunteer
,
@other_volunteer
]
other_feedback
=
create
:feedback
,
volunteer:
@volunteer
,
feedbackable:
other_group_offer
,
other_group_offer
=
create
:group_offer
,
title:
'some_other_group_offer'
,
volunteers:
[
@volunteer
,
@other_volunteer
],
necessary_volunteers:
2
create
:feedback
,
volunteer:
@volunteer
,
feedbackable:
other_group_offer
,
author:
@user_volunteer
,
comments:
'other_feedback'
login_as
@user_volunteer
visit
group_offer_feedbacks_path
(
@group_offer
)
assert
page
.
has_text?
'some_group_offer_feedback'
refute
page
.
has_text?
'some_group_offer_superadmin_feedback'
refute
page
.
has_text?
'other_volunteers_group_offer_feedback'
login_as
@superadmin
visit
group_offer_feedbacks_path
(
@group_offer
)
assert
page
.
has_text?
'some_group_offer_feedback'
assert
page
.
has_text?
'some_group_offer_superadmin_feedback'
assert
page
.
has_text?
'other_volunteers_group_offer_feedback'
end
test
'assignment feedbacks index contains only the feedbacks related to that assignment'
do
create
:feedback
,
volunteer:
@volunteer
,
author:
@user_volunteer
,
feedbackable:
@assignment
,
comments:
'some_feedback'
create
:feedback
,
volunteer:
@volunteer
,
author:
@superadmin
,
feedbackable:
@assignment
,
comments:
'some_superadmin_feedback'
other_assignment
=
create
:assignment
,
volunteer:
@volunteer
create
:feedback
,
feedbackable:
other_assignment
,
volunteer:
@volunteer
,
author:
@user_volunteer
,
comments:
'other_feedback'
login_as
@user_volunteer
visit
group_offer
_feedbacks_path
(
group_offer
)
visit
assignment
_feedbacks_path
(
@assignment
)
assert
page
.
has_text?
'some_feedback'
refute
page
.
has_text?
'some_superadmin_feedback'
refute
page
.
has_text?
'other_feedback'
login_as
@superadmin
visit
group_offer_feedbacks_path
(
group_offer
)
visit
assignment_feedbacks_path
(
@assignment
)
assert
page
.
has_text?
'some_feedback'
assert
page
.
has_text?
'some_superadmin_feedback'
refute
page
.
has_text?
'other_feedback'
end
test
'volunteer feedbacks index contains only the feedbacks related to that group offer'
do
create
:feedback
,
volunteer:
@volunteer
,
author:
@user_volunteer
,
feedbackable:
@assignment
,
comments:
'some_assignment_feedback'
create
:feedback
,
volunteer:
@volunteer
,
author:
@superadmin
,
feedbackable:
@assignment
,
comments:
'some_assignment_superadmin_feedback'
other_assignment
=
create
:assignment
,
volunteer:
@volunteer
create
:feedback
,
feedbackable:
other_assignment
,
volunteer:
@volunteer
,
author:
@user_volunteer
,
comments:
'other_assignment_feedback'
login_as
@user_volunteer
visit
volunteer_feedbacks_path
(
@assignment
)
assert
page
.
has_text?
'some_assignment_feedback'
refute
page
.
has_text?
'some_assignment_superadmin_feedback'
assert
page
.
has_text?
'other_assignment_feedback'
assert
page
.
has_text?
'some_group_offer_feedback'
refute
page
.
has_text?
'some_group_offer_superadmin_feedback'
refute
page
.
has_text?
'other_volunteers_group_offer_feedback'
login_as
@superadmin
visit
volunteer_feedbacks_path
(
@assignment
)
assert
page
.
has_text?
'some_assignment_feedback'
assert
page
.
has_text?
'some_assignment_superadmin_feedback'
assert
page
.
has_text?
'other_assignment_feedback'
assert
page
.
has_text?
'some_group_offer_feedback'
assert
page
.
has_text?
'some_group_offer_superadmin_feedback'
refute
page
.
has_text?
'other_volunteers_group_offer_feedback'
end
test
'volunteer can create only their feedbacks'
do
...
...
@@ -70,4 +120,48 @@ class FeedbacksTest < ApplicationSystemTestCase
visit
new_assignment_feedback_path
(
assignment
)
assert
page
.
has_text?
'You are not authorized to perform this action.'
end
test
'create new assignment feedback'
do
login_as
@user_volunteer
visit
volunteer_path
(
@volunteer
)
within
'.assignments-table'
do
click_link
'New Feedback'
end
fill_in
'Which were the most important goals during the last months?'
,
with:
'important_goals_answer_given'
fill_in
'What could have been achieved during the last months?'
,
with:
'achievment_answer_given'
fill_in
'Should the assignment continue? If yes, with which goals?'
,
with:
'continue_answer_given'
fill_in
'Comments'
,
with:
'comments_given'
page
.
check
(
'feedback_conversation'
)
click_button
'Create Feedback'
assert
page
.
has_text?
'Feedback was successfully created.'
assert
page
.
has_text?
'important_goals_answer_given'
assert
page
.
has_text?
'achievment_answer_given'
assert
page
.
has_text?
'continue_answer_given'
assert
page
.
has_text?
'comments_given'
end
test
'create new group_offer feedback'
do
login_as
@user_volunteer
visit
volunteer_path
(
@volunteer
)
within
'.group-assignments-table'
do
click_link
'New Feedback'
end
fill_in
'Which were the most important goals during the last months?'
,
with:
'important_goals_answer_given'
fill_in
'What could have been achieved during the last months?'
,
with:
'achievment_answer_given'
fill_in
'Should the assignment continue? If yes, with which goals?'
,
with:
'continue_answer_given'
fill_in
'Comments'
,
with:
'new_comments_given'
page
.
check
(
'feedback_conversation'
)
click_button
'Create Feedback'
assert
page
.
has_text?
'Feedback was successfully created.'
assert
page
.
has_text?
'important_goals_answer_given'
assert
page
.
has_text?
'achievment_answer_given'
assert
page
.
has_text?
'continue_answer_given'
assert
page
.
has_text?
'new_comments_given'
end
end
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