Commit fe1acf42 authored by Zsolt Benke's avatar Zsolt Benke
Browse files

Added policy tests for clients#destroy

parent 09c949fb
Pipeline #21498 passed with stage
in 33 minutes and 38 seconds
......@@ -22,6 +22,7 @@ class ClientPolicy < ApplicationPolicy
alias_method :new?, :superadmin_or_department_manager_or_social_worker?
alias_method :create?, :superadmin_or_department_manager_or_social_worker?
alias_method :show?, :superadmin_or_department_manager_or_social_worker?
alias_method :destroy?, :superadmin_or_department_manager_or_social_worker?
alias_method :edit?, :superadmin_or_client_responsible?
alias_method :update?, :superadmin_or_client_responsible?
alias_method :set_terminated?, :superadmin_or_department_managers_record?
......
......@@ -57,7 +57,7 @@ Rails.application.routes.draw do
end
resources :client_notifications, :departments, :performance_reports, :email_templates, :users
resources :clients, except: [:destroy], concerns: :search do
resources :clients, concerns: :search do
resources :journals, except: [:show]
patch :set_terminated, on: :member
end
......
require 'test_helper'
class CliensControllerTest < ActionDispatch::IntegrationTest
setup do
@superadmin = create :user, :with_clients,
:with_department, role: 'superadmin'
@social_worker = create :user, :with_clients,
:with_department, role: 'social_worker'
@department_manager = create :department_manager
end
end
......@@ -21,7 +21,7 @@ class ClientPolicyTest < PolicyAssertions::Test
assert_permit(@department_manager, @manager_client,
*actions_list(:edit, :update, :set_terminated), 'show_comments?')
assert_permit(@department_manager, Client,
*actions_list(:index, :search, :new, :create, :show), 'show_comments?')
*actions_list(:index, :search, :new, :create, :show, :destroy), 'show_comments?')
refute_permit(@department_manager, create(:client),
*actions_list(:edit, :update, :set_terminated))
refute_permit(@department_manager, Client, 'superadmin_privileges?',
......@@ -30,7 +30,7 @@ class ClientPolicyTest < PolicyAssertions::Test
test 'social_worker_has_limited_access' do
assert_permit(@social_worker, Client,
*actions_list(:index, :search, :new, :create, :show), 'show_comments?')
*actions_list(:index, :search, :new, :create, :show, :destroy), 'show_comments?')
assert_permit(@social_worker, @social_client, *actions_list(:edit, :update), 'show_comments?')
assert_permit(@social_worker, @social_involved, *actions_list(:edit, :update), 'show_comments?')
refute_permit(@social_worker, create(:client), *actions_list(:edit, :update, :set_terminated))
......
Supports Markdown
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