Fixes #3065 - Updating KB answers throws error 500 for agents without edit rights

This commit is contained in:
Mantas Masalskis 2020-05-26 16:35:54 +02:00 committed by Thorsten Eckel
parent 95de420a35
commit ea395db5c6
2 changed files with 29 additions and 1 deletions

View file

@ -2,6 +2,6 @@ class Controllers::KnowledgeBase::CategoriesControllerPolicy < Controllers::Know
def show?
return if user.permissions?('knowledge_base.editor')
record.klass.find(params[:id]).internal_content?
record.klass.find(record.params[:id]).internal_content?
end
end

View file

@ -0,0 +1,28 @@
require 'rails_helper'
describe Controllers::KnowledgeBase::CategoriesControllerPolicy do
include_context 'basic Knowledge Base'
subject { described_class.new(user, record) }
let(:record_class) { KnowledgeBase::CategoriesController }
let(:record) do
rec = record_class.new
rec.action_name = action_name
rec.params = params
rec
end
describe '#show?' do
let(:action_name) { :show }
let(:params) { { id: internal_answer.category.id } }
context 'with knowledge_base.reader permissions' do
let(:user) { create(:agent) }
it { is_expected.to permit_action(action_name) }
end
end
end