Fixes issue #2789: not possible to search or link KB-answer within ticket.
This commit is contained in:
parent
f17c181427
commit
d4afb0e867
4 changed files with 63 additions and 4 deletions
|
@ -85,7 +85,7 @@ class KnowledgeBase::SearchController < ApplicationController
|
|||
end
|
||||
|
||||
{
|
||||
id: object.id,
|
||||
id: object.id.to_s,
|
||||
type: object.class.name,
|
||||
icon: 'knowledge-base-answer',
|
||||
date: object.updated_at,
|
||||
|
@ -108,7 +108,7 @@ class KnowledgeBase::SearchController < ApplicationController
|
|||
end
|
||||
|
||||
{
|
||||
id: object.id,
|
||||
id: object.id.to_s,
|
||||
type: object.class.name,
|
||||
fontName: object.category.knowledge_base.iconset,
|
||||
date: object.updated_at,
|
||||
|
@ -130,7 +130,7 @@ class KnowledgeBase::SearchController < ApplicationController
|
|||
end
|
||||
|
||||
{
|
||||
id: object.id,
|
||||
id: object.id.to_s,
|
||||
type: object.class.name,
|
||||
icon: 'knowledge-base',
|
||||
date: object.updated_at,
|
||||
|
|
|
@ -121,7 +121,7 @@ class KnowledgeBase < ApplicationModel
|
|||
.active
|
||||
.joins(:kb_locales)
|
||||
.group('knowledge_bases.id')
|
||||
.pluck('COUNT(knowledge_base_locales.id) as locales_count')
|
||||
.pluck(Arel.sql('COUNT(knowledge_base_locales.id) as locales_count'))
|
||||
.any? { |e| e > 1 }
|
||||
end
|
||||
|
||||
|
|
33
spec/requests/knowledge_base/search_with_details_spec.rb
Normal file
33
spec/requests/knowledge_base/search_with_details_spec.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Knowledge Base search with details', type: :request, searchindex: true do
|
||||
include_context 'basic Knowledge Base'
|
||||
|
||||
before do
|
||||
configure_elasticsearch(required: true, rebuild: true) do
|
||||
published_answer
|
||||
end
|
||||
end
|
||||
|
||||
let(:endpoint) { '/api/v1/knowledge_bases/search' }
|
||||
|
||||
context 'ensure details ID type matches ES ID type' do
|
||||
it 'for answers' do
|
||||
post endpoint, params: { query: published_answer.translations.first.title }
|
||||
|
||||
expect(json_response['details'][0]['id']).to be_a_kind_of String
|
||||
end
|
||||
|
||||
it 'for categories' do
|
||||
post endpoint, params: { query: category.translations.first.title }
|
||||
|
||||
expect(json_response['details'][0]['id']).to be_a_kind_of String
|
||||
end
|
||||
|
||||
it 'for knowledge base' do
|
||||
post endpoint, params: { query: knowledge_base.translations.first.title }
|
||||
|
||||
expect(json_response['details'][0]['id']).to be_a_kind_of String
|
||||
end
|
||||
end
|
||||
end
|
26
spec/system/ticket/linking_knowledge_base_answer_spec.rb
Normal file
26
spec/system/ticket/linking_knowledge_base_answer_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'linking Knowledge Base answer', type: :system, authenticated: true, searchindex: true do
|
||||
include_context 'basic Knowledge Base'
|
||||
|
||||
before do
|
||||
configure_elasticsearch(required: true, rebuild: true) do
|
||||
published_answer
|
||||
end
|
||||
end
|
||||
|
||||
it do
|
||||
ticket = create :ticket, group: Group.find_by(name: 'Users')
|
||||
visit "#ticket/zoom/#{ticket.id}"
|
||||
|
||||
find(:css, '.active .link_kb_answers .js-add').click
|
||||
|
||||
target_translation = published_answer.translations.first
|
||||
|
||||
find(:css, '.active .link_kb_answers .js-input').send_keys target_translation.title
|
||||
|
||||
find(:css, %(.active .link_kb_answers li[data-value="#{target_translation.id}"])).click
|
||||
|
||||
expect(find(:css, '.active .link_kb_answers ol')).to have_text target_translation.title
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue