-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Unpublished sites are hidden from search engines (#2570)
- Loading branch information
1 parent
82caec5
commit a753297
Showing
7 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file | ||
# | ||
# To ban all spiders from the entire site uncomment the next two lines: | ||
User-agent: * | ||
Disallow: / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file | ||
# | ||
# To ban all spiders from the entire site uncomment the next two lines: | ||
User-agent: * | ||
Disallow: / | ||
Disallow: / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class RobotsIntegrationTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@published_site = create(:site, is_published: true) | ||
@unpublished_site = create(:site, is_published: false) | ||
end | ||
|
||
test 'robots.txt blocks site if site is unpublished' do | ||
get "http://#{@unpublished_site.slug}.lvh.me:3000/robots.txt" | ||
assert_response 200 | ||
assert_equal forbid_string, response.body | ||
end | ||
|
||
test 'robots.txt has default comment if site is published' do | ||
get "http://#{@published_site.slug}.lvh.me:3000/robots.txt" | ||
assert_response 200 | ||
assert_equal '# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file', response.body | ||
end | ||
|
||
private | ||
|
||
def forbid_string | ||
<<~TXT | ||
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file | ||
User-agent: * | ||
Disallow: / | ||
TXT | ||
end | ||
end |