Verified Commit 2a318f17 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider
Browse files

rename from set_resigned to set_terminated

parent cc251794
......@@ -3,7 +3,7 @@ class ClientsController < ApplicationController
include NestedAttributes
include ContactAttributes
before_action :set_client, only: [:show, :edit, :update, :set_resigned]
before_action :set_client, only: [:show, :edit, :update, :set_terminated]
before_action :set_social_worker_collection, only: [:new, :edit]
def index
......@@ -67,7 +67,7 @@ class ClientsController < ApplicationController
end
end
def set_resigned
def set_terminated
if @client.update(acceptance: :resigned, resigned_by: current_user)
redirect_back(fallback_location: client_path(@client),
notice: 'Klient/in wurde erfolgreich beendet.')
......
......@@ -16,7 +16,7 @@ class ClientPolicy < ApplicationPolicy
alias_method :edit?, :superadmin_or_record_owner?
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 :set_terminated?, :superadmin_or_department_managers_record?
# suplementary policies
alias_method :superadmin_privileges?, :superadmin?
......
......@@ -26,5 +26,5 @@ tr
= link_to t_action(:show), client_path(client)
- if policy(client).edit?
= link_to t_action(:edit), edit_client_path(client)
- if policy(client).set_resigned?
= link_to 'Beenden', set_resigned_client_path(client), method: :patch, data: { confirm: 'Klient/in wirklich beenden?' }
- if policy(client).set_terminated?
= link_to 'Beenden', set_terminated_client_path(client), method: :patch, data: { confirm: 'Klient/in wirklich beenden?' }
......@@ -47,7 +47,7 @@
fieldset
legend Interne Kriterien
- if policy(@client).set_resigned?
- if policy(@client).set_terminated?
= f.input :acceptance, collection: policy(@client).acceptance_collection, include_blank: false
- if policy(Client).superadmin_privileges?
= f.association :involved_authority, collection: @social_workers
......
......@@ -6,8 +6,8 @@ nav.navbar.section-navigation
- if policy(@client).edit?
li= button_link t_action(:edit), edit_client_path(@client)
li= button_link navigation_glyph(:print), client_path(@client, print: true)
- if !@client.resigned? && policy(@client).set_resigned?
li= link_to 'Beenden', set_resigned_client_path(@client), class: 'btn btn-default', method: :patch, data: { confirm: 'Klient/in wirklich beenden?' }
- if !@client.resigned? && policy(@client).set_terminated?
li= link_to 'Beenden', set_terminated_client_path(@client), class: 'btn btn-default', method: :patch, data: { confirm: 'Klient/in wirklich beenden?' }
li= button_link navigation_glyph(:back), clients_path
- if policy(Journal).index?
ul.list-inline.pull-right
......
......@@ -58,7 +58,7 @@ Rails.application.routes.draw do
resources :clients, except: [:destroy], concerns: :search do
resources :journals, except: [:show]
patch :set_resigned, on: :member
patch :set_terminated, on: :member
end
resources :feedbacks, only: [:new, :create]
......
......@@ -4,19 +4,19 @@ class ClientPolicyTest < PolicyAssertions::Test
test 'superadmin_can_use_all_actions' do
assert_permit(create(:user), Client,
'index?', 'search?', 'new?', 'create?', 'show?', 'edit?', 'update?', 'termination?',
'superadmin_privileges?', 'set_resigned?')
'superadmin_privileges?', 'set_terminated?')
end
test 'department_manager_has_limited_access' do
department_manager = create :department_manager, :with_clients
assert_permit(department_manager, department_manager.clients.first,
'edit?', 'update?', 'termination?', 'set_resigned?')
'edit?', 'update?', 'termination?', 'set_terminated?')
assert_permit(department_manager, Client,
'index?', 'search?', 'new?', 'create?', 'show?')
refute_permit(department_manager, create(:client),
'edit?', 'update?', 'termination?', 'set_resigned?')
'edit?', 'update?', 'termination?', 'set_terminated?')
refute_permit(department_manager, Client,
'superadmin_privileges?', 'set_resigned?')
'superadmin_privileges?', 'set_terminated?')
end
test 'social_worker_has_limited_access' do
......@@ -26,8 +26,8 @@ class ClientPolicyTest < PolicyAssertions::Test
assert_permit(social_worker, social_worker.clients.first,
'edit?', 'update?')
refute_permit(social_worker, create(:client),
'edit?', 'update?', 'set_resigned?')
'edit?', 'update?', 'set_terminated?')
refute_permit(social_worker, Client,
'termination?', 'superadmin_privileges?', 'set_resigned?')
'termination?', 'superadmin_privileges?', 'set_terminated?')
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