From b9d170f1e4ba02a4858fa180b3337a1891e18260 Mon Sep 17 00:00:00 2001 From: Mantas Date: Wed, 2 Jun 2021 12:06:18 +0300 Subject: [PATCH] Follow up - 9e4fae - Fixes #3164 - Robots.txt should allow indexing Knowledge Base on custom URLs --- spec/requests/robots_txt_spec.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/spec/requests/robots_txt_spec.rb b/spec/requests/robots_txt_spec.rb index f4f0a7707..286f6b7d1 100644 --- a/spec/requests/robots_txt_spec.rb +++ b/spec/requests/robots_txt_spec.rb @@ -3,6 +3,11 @@ require 'rails_helper' RSpec.describe 'RobotsTxt', type: :request do + shared_examples 'returns default robot instructions' do + it 'returns default robot instructions' do + expect(response.body).to match(%r{^Allow: /help/$}).and match(%r{^Disallow: /$}) + end + end context 'when no Knowledge Base exists' do @@ -15,12 +20,10 @@ RSpec.describe 'RobotsTxt', type: :request do end it 'returns text' do - expect(response.content_type).to eq('text/plain') + expect(response.content_type).to start_with('text/plain') end - it 'returns robot instructions' do - expect(response.body).to include('Allow:').and(include('Disallow:')) - end + include_examples 'returns default robot instructions' end context 'when Knowledge Base exists' do @@ -33,9 +36,7 @@ RSpec.describe 'RobotsTxt', type: :request do get '/robots.txt', headers: { SERVER_NAME: server_name } end - it 'returns robot instructions' do - expect(response.body).to include('Allow:').and(include('Disallow:')) - end + include_examples 'returns default robot instructions' context 'when custom path is configured' do let(:custom_address) { '/knowledge_base' } @@ -49,10 +50,7 @@ RSpec.describe 'RobotsTxt', type: :request do let(:custom_address) { 'kb.com/knowledge_base' } context 'when requesting main domain' do - - it 'returns default rules' do - expect(response.body).to include('Allow:').and(include('Disallow:')) - end + include_examples 'returns default robot instructions' end context 'when requesting KB domain' do