seo: increase sitemap coverage.
Rework sitemaps to provide more coverage of the site. We want every important page on the site - including every post, tag, and wiki page - to be indexed by Google. We do this by generating sitemaps and sitemap indexes that contain links to every important page on the site.
This commit is contained in:
@@ -135,6 +135,12 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "get the sitemap" do
|
||||
get artists_path(format: :sitemap)
|
||||
assert_response :success
|
||||
assert_equal(Artist.count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
|
||||
context "when searching the index page" do
|
||||
should "find artists by name" do
|
||||
get artists_path(name: "masao", format: "json")
|
||||
|
||||
@@ -114,6 +114,12 @@ class ForumTopicsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render for a sitemap" do
|
||||
get forum_topics_path(format: :sitemap)
|
||||
assert_response :success
|
||||
assert_equal(ForumTopic.count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
|
||||
context "with private topics" do
|
||||
should "not show private topics to unprivileged users" do
|
||||
as(@user) { @topic2.update!(min_level: User::Levels::MODERATOR) }
|
||||
|
||||
@@ -23,6 +23,13 @@ class PoolsControllerTest < ActionDispatch::IntegrationTest
|
||||
get pools_path, params: {:search => {:name_matches => @pool.name}}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render for a sitemap" do
|
||||
get pools_path(format: :sitemap)
|
||||
assert_response :success
|
||||
assert_equal(Pool.count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "show action" do
|
||||
|
||||
@@ -337,6 +337,14 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
context "with the .sitemap format" do
|
||||
should "render" do
|
||||
get posts_path(format: :sitemap)
|
||||
assert_response :success
|
||||
assert_equal(Post.count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
end
|
||||
|
||||
context "with deleted posts" do
|
||||
setup do
|
||||
@post.update!(is_deleted: true)
|
||||
|
||||
@@ -14,11 +14,14 @@ class StaticControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
context "sitemap action" do
|
||||
should "work" do
|
||||
create_list(:post, 3)
|
||||
mock_post_search_rankings(Time.zone.yesterday, [["1girl", 100.0], ["2girls", 50.0]])
|
||||
get sitemap_path, as: :xml
|
||||
assert_response :success
|
||||
[Artist, ForumTopic, Pool, Post, Tag, User, WikiPage].each do |klass|
|
||||
should "work for #{klass.model_name.plural}" do
|
||||
as(create(:user)) { create_list(klass.model_name.singular.to_sym, 3) }
|
||||
get sitemap_path(sitemap: klass.model_name.plural), as: :xml
|
||||
|
||||
assert_response :success
|
||||
assert_equal(1, response.parsed_body.css("sitemap loc").size)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ class TagsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render for a sitemap" do
|
||||
get tags_path(format: :sitemap)
|
||||
assert_response :success
|
||||
assert_equal(Tag.count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
|
||||
context "with blank search parameters" do
|
||||
should "strip the blank parameters with a redirect" do
|
||||
get tags_path, params: { search: { name: "touhou", category: "" } }
|
||||
|
||||
@@ -12,6 +12,12 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render for a sitemap" do
|
||||
get users_path(format: :sitemap)
|
||||
assert_response :success
|
||||
assert_equal(User.count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
|
||||
should "list all users for /users?name=<name>" do
|
||||
get users_path, params: { name: @user.name }
|
||||
assert_redirected_to(@user)
|
||||
|
||||
@@ -23,6 +23,12 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render for a sitemap" do
|
||||
get wiki_pages_path(format: :sitemap)
|
||||
assert_response :success
|
||||
assert_equal(WikiPage.count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
|
||||
should "redirect the legacy title param to the show page" do
|
||||
get wiki_pages_path(title: "tagme")
|
||||
assert_redirected_to wiki_pages_path(search: { title_normalize: "tagme" }, redirect: true)
|
||||
|
||||
Reference in New Issue
Block a user