From 470d9418fdedeb566c49ee99d8bba9673fe96f13 Mon Sep 17 00:00:00 2001 From: Kane York Date: Mon, 22 Jun 2015 16:02:45 -0700 Subject: [PATCH] Add tests for X-Robots-Tag --- spec/controllers/topics_controller_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb index 19281aebe..72ae0e2eb 100644 --- a/spec/controllers/topics_controller_spec.rb +++ b/spec/controllers/topics_controller_spec.rb @@ -1018,4 +1018,19 @@ describe TopicsController do expect(json["banner_count"]).to eq(1) end end + + describe "x-robots-tag" do + it "is included for unlisted topics" do + topic = Fabricate(:topic, visible: false) + get :show, topic_id: topic.id, slug: topic.slug + + expect(response.headers['X-Robots-Tag']).to eq('noindex') + end + it "is not included for normal topics" do + topic = Fabricate(:topic, visible: true) + get :show, topic_id: topic.id, slug: topic.slug + + expect(response.headers['X-Robots-Tag']).to eq(nil) + end + end end