Verified Commit e4045bae authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

remove client destroy, and all that counts to it

parent 25d9463d
......@@ -79,11 +79,6 @@ class ClientsController < ApplicationController
end
end
def destroy
@client.destroy
redirect_to clients_url, make_notice
end
private
def default_filter
......
......@@ -17,7 +17,6 @@ class ClientPolicy < ApplicationPolicy
alias_method :update?, :superadmin_or_record_owner?
alias_method :termination?, :superadmin_or_department_managers_record?
alias_method :set_resigned?, :superadmin_or_department_managers_record?
alias_method :destroy?, :superadmin?
# suplementary policies
alias_method :superadmin_privileges?, :superadmin?
......
......@@ -56,7 +56,7 @@ Rails.application.routes.draw do
resources :assignments, concerns: [:update_submitted_at, :search, :termination_actions]
resources :client_notifications, :departments, :performance_reports, :email_templates, :users
resources :clients, concerns: :search do
resources :clients, except: [:destroy], concerns: :search do
resources :journals, except: [:show]
patch :set_resigned, on: :member
end
......
require 'test_helper'
class ClientPolicyTest < PolicyAssertions::Test
def setup
@actions = ['index?', 'search?', 'new?', 'create?', 'show?', 'edit?', 'update?', 'termination?',
'destroy?', 'superadmin_privileges?']
end
test 'superadmin_can_use_all_actions' do
assert_permit(create(:user), Client, *@actions)
assert_permit(create(:user), Client,
'index?', 'search?', 'new?', 'create?', 'show?', 'edit?', 'update?', 'termination?',
'superadmin_privileges?', 'set_resigned?')
end
test 'department_manager_has_limited_access' do
department_manager = create :department_manager, :with_clients
assert_permit(department_manager, Client, *@actions[0..4])
assert_permit(department_manager, Client.first, *@actions[5..7])
refute_permit(department_manager, create(:client), *@actions[5..7])
refute_permit(department_manager, Client, *@actions[-2..-1])
assert_permit(department_manager, department_manager.clients.first,
'edit?', 'update?', 'termination?', 'set_resigned?')
assert_permit(department_manager, Client,
'index?', 'search?', 'new?', 'create?', 'show?')
refute_permit(department_manager, create(:client),
'edit?', 'update?', 'termination?', 'set_resigned?')
refute_permit(department_manager, Client,
'superadmin_privileges?', 'set_resigned?')
end
test 'social_worker_has_limited_access' do
social_worker = create :social_worker, :with_clients
assert_permit(social_worker, Client, *@actions[0..4])
assert_permit(social_worker, Client.first, *@actions[5..6])
refute_permit(social_worker, create(:client), *@actions[5..6])
refute_permit(social_worker, Client, *@actions[-3..-1])
assert_permit(social_worker, Client,
'index?', 'search?', 'new?', 'create?', 'show?')
assert_permit(social_worker, social_worker.clients.first,
'edit?', 'update?')
refute_permit(social_worker, create(:client),
'edit?', 'update?', 'set_resigned?')
refute_permit(social_worker, Client,
'termination?', 'superadmin_privileges?', 'set_resigned?')
end
end
......@@ -142,18 +142,6 @@ class ClientsTest < ApplicationSystemTestCase
refute page.has_text? 'Fluent'
end
test 'superadmin_can_delete_client' do
login_as @superadmin
client = create :client
visit client_path(client)
page.accept_confirm do
first('a', text: 'Löschen').click
end
assert page.has_text? 'Client was successfully deleted.'
end
test 'client_pagination' do
login_as @superadmin
70.times do
......@@ -183,22 +171,6 @@ class ClientsTest < ApplicationSystemTestCase
"#{I18n.l(with_assignment.created_at.to_date)} Angemeldet with_assignment Show Edit"
end
test 'can_delete_a_client_through_edit' do
client = create :client
login_as @superadmin
visit clients_path
assert page.has_text? client
visit edit_client_path(client)
page.accept_confirm do
click_link 'Löschen'
end
assert page.has_text? 'Client was successfully deleted.'
refute page.has_text? client
end
test 'all_needed_actions_are_available_in_the_index' do
client = create :client
social_worker = create :social_worker
......@@ -209,7 +181,6 @@ class ClientsTest < ApplicationSystemTestCase
visit clients_path
assert page.has_link? 'Show', count: 3
assert page.has_link? 'Edit', count: 3
refute page.has_link? 'Löschen'
login_as @department_manager
visit clients_path
......
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