Fixes #3915 - No longer public KB answers do not return http 404

This commit is contained in:
Mantas 2022-03-03 09:19:14 +02:00 committed by Mantas Masalskis
parent cc9977460e
commit 4acf9cac67
2 changed files with 39 additions and 1 deletions

View file

@ -105,6 +105,6 @@ class KnowledgeBase::Public::BaseController < ApplicationController
end end
@page_title_error = :not_found @page_title_error = :not_found
render 'knowledge_base/public/not_found' render 'knowledge_base/public/not_found', status: :not_found
end end
end end

View file

@ -0,0 +1,38 @@
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'KnowledgeBase public answers', type: :request do
include_context 'basic Knowledge Base'
describe '#show' do
context 'when visitor is a guest' do
it 'returns OK for published answer' do
get help_answer_path(locale_name, category, published_answer)
expect(response).to have_http_status :ok
end
it 'returns NOT FOUND for draft answer' do
get help_answer_path(locale_name, category, draft_answer)
expect(response).to have_http_status :not_found
end
end
context 'when visitor is an editor' do
before do
published_answer && draft_answer
authenticated_as(create(:admin), via: :browser)
end
it 'returns OK for published answer' do
get help_answer_path(locale_name, category, published_answer)
expect(response).to have_http_status :ok
end
it 'returns OK for draft answer' do
get help_answer_path(locale_name, category, draft_answer)
expect(response).to have_http_status :ok
end
end
end
end