Commit f8c0fa38 authored by Tugce Nur Tas's avatar Tugce Nur Tas
Browse files

add extra comment policy for volunteer comments

parent ad09c17f
......@@ -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
......@@ -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)
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment