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
f8c0fa38
Commit
f8c0fa38
authored
May 14, 2018
by
Tugce Nur Tas
Browse files
add extra comment policy for volunteer comments
parent
ad09c17f
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/policies/volunteer_policy.rb
View file @
f8c0fa38
...
...
@@ -26,5 +26,6 @@ class VolunteerPolicy < ApplicationPolicy
# supplementary policies
alias_method
:superadmin_privileges?
,
:superadmin?
alias_method
:show_acceptance?
,
:superadmin_or_department_manager?
alias_method
:show_comments?
,
:superadmin_or_department_manager?
alias_method
:update_acceptance?
,
:superadmin_or_department_managers_registration?
end
app/views/volunteers/_columns.html.slim
View file @
f8c0fa38
...
...
@@ -21,7 +21,7 @@
th
=
t_attr
(
:profession
,
Volunteer
)
th
=
sort_link
@q
,
:working_percent
th
=
t_attr
(
:interests
,
Volunteer
)
-
if
policy
(
Volunteer
).
show_
acceptance
?
-
if
policy
(
Volunteer
).
show_
comments
?
th
=
t_attr
(
:comments
)
th
=
sort_link
@q
,
:external
th
=
t_attr
(
:created_by
,
Volunteer
)
...
...
app/views/volunteers/_form.html.slim
View file @
f8c0fa38
...
...
@@ -120,7 +120,7 @@ fieldset
=
f
.
input
:strengths
=
f
.
input
:interests
-
if
policy
(
Volunteer
).
show_
acceptance
?
-
if
policy
(
Volunteer
).
show_
comments
?
.col-xs-12.col-md-6
=
f
.
input
:comments
=
f
.
input
:additional_comments
app/views/volunteers/_volunteer.html.slim
View file @
f8c0fa38
...
...
@@ -44,7 +44,7 @@ tr
td
=
volunteer
.
profession
td
=
"
#{
volunteer
.
working_percent
}
%"
if
volunteer
.
working_percent
.
present?
td
=
volunteer
.
interests
-
if
policy
(
Volunteer
).
show_
acceptance
?
-
if
policy
(
Volunteer
).
show_
comments
?
=
td_truncate_content_modal
(
volunteer
.
comments
,
'Bemerkungen'
)
td
=
volunteer
.
external?
?
t_attr
(
:external
,
Volunteer
)
:
t_attr
(
:internal
,
Volunteer
)
td
...
...
app/views/volunteers/show.html.slim
View file @
f8c0fa38
...
...
@@ -100,7 +100,7 @@ h2.small Persönlicher Hintergrund
=
t
(
'volunteer_self_applicant'
)
-
else
=
link_to
@volunteer
.
registrar
.
full_name
,
profile_link
(
@volunteer
.
registrar
)
-
if
policy
(
Volunteer
).
show_
acceptance
?
-
if
policy
(
Volunteer
).
show_
comments
?
tr
td
=
t_attr
(
:comments
)
td
=
@volunteer
.
comments
...
...
test/policies/volunteer_policy_test.rb
View file @
f8c0fa38
...
...
@@ -2,26 +2,27 @@ require 'test_helper'
class
VolunteerPolicyTest
<
PolicyAssertions
::
Test
test
'superadmin_can_use_all_actions'
do
assert_permit
(
create
(
:user
),
Volunteer
,
'superadmin_privileges?'
,
*
actions_list
)
assert_permit
(
create
(
:user
),
Volunteer
,
'superadmin_privileges?'
'show_comments?'
,
*
actions_list
)
end
test
'department_manager_has_limited_access'
do
department_manager
=
create
:department_manager
department_manager_volunteer
=
create
:volunteer_with_user
department_manager_volunteer
.
registrar
=
department_manager
assert_permit
(
department_manager
,
Volunteer
,
'show_acceptance?'
,
assert_permit
(
department_manager
,
Volunteer
,
'show_acceptance?'
,
'show_comments?'
,
*
actions_list
(
:index
,
:search
,
:new
,
:create
,
:seeking_clients
))
assert_permit
(
department_manager
,
department_manager_volunteer
,
*
actions_list
(
:terminate
,
:show
,
:edit
,
:update
))
refute_permit
(
department_manager
,
create
(
:volunteer
),
*
actions_list
(
:terminate
,
:show
,
:edit
,
:update
))
refute_permit
(
department_manager
,
Volunteer
,
'superadmin_privileges?'
,
'update_acceptance?'
)
assert_permit
(
department_manager
,
Volunteer
,
'show_acceptance?'
)
assert_permit
(
department_manager
,
department_manager_volunteer
,
'update_acceptance?'
)
assert_permit
(
department_manager
,
Volunteer
,
'show_acceptance?'
,
'show_comments?'
)
assert_permit
(
department_manager
,
department_manager_volunteer
,
'update_acceptance?'
,
'show_comments?'
)
end
test
'social_worker_has_no_access'
do
refute_permit
(
create
(
:social_worker
),
Volunteer
,
*
actions_list
)
refute_permit
(
create
(
:social_worker
),
Volunteer
,
*
actions_list
,
'show_comments?'
)
end
test
'volunteer_has_limited_access'
do
...
...
@@ -29,9 +30,11 @@ class VolunteerPolicyTest < PolicyAssertions::Test
volunteer_two
=
create
:volunteer_with_user
assert_permit
(
volunteer_one
.
user
,
volunteer_one
,
*
actions_list
(
:show
,
:edit
,
:update
))
refute_permit
(
volunteer_one
.
user
,
volunteer_two
,
*
actions_list
(
:show
,
:edit
,
:update
))
refute_permit
(
volunteer_one
.
user
,
Volunteer
,
'superadmin_privileges?'
,
'show_acceptance?'
,
refute_permit
(
volunteer_one
.
user
,
Volunteer
,
'superadmin_privileges?'
,
'show_acceptance?'
,
'show_comments?'
,
*
actions_list
(
:index
,
:search
,
:new
,
:create
,
:seeking_clients
,
:terminate
))
refute_permit
(
volunteer_two
.
user
,
Volunteer
,
'superadmin_privileges?'
,
'show_acceptance?'
,
refute_permit
(
volunteer_two
.
user
,
Volunteer
,
'superadmin_privileges?'
,
'show_acceptance?'
,
'show_comments?'
,
*
actions_list
(
:index
,
:search
,
:new
,
:create
,
:seeking_clients
,
:terminate
))
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