Fixes #3065 - Updating KB answers throws error 500 for agents without edit rights
This commit is contained in:
parent
95de420a35
commit
ea395db5c6
2 changed files with 29 additions and 1 deletions
|
@ -2,6 +2,6 @@ class Controllers::KnowledgeBase::CategoriesControllerPolicy < Controllers::Know
|
||||||
def show?
|
def show?
|
||||||
return if user.permissions?('knowledge_base.editor')
|
return if user.permissions?('knowledge_base.editor')
|
||||||
|
|
||||||
record.klass.find(params[:id]).internal_content?
|
record.klass.find(record.params[:id]).internal_content?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
Loading…
Reference in a new issue