Stop updating the fav_string attribute on posts. The column still exists on the table, but is no longer used or updated. Like the pool_string in7d503f08, the fav_string was used in the past to facilitate `fav:X` searches. Posts had a hidden fav_string column that contained a list of every user who favorited the post. These were treated like fake hidden tags on the post so that a search for `fav:X` was treated like a tag search. The fav_string attribute has been unused for search purposes for a while now. It was only kept because of technicalities that required departitioning the favorites table first (340e1008e) before it could be removed. Basically, removing favorites with `@favorite.destroy` was slow because Rails always deletes object by ID, but we didn't have an index on favorites.id, and we couldn't easily add one until the favorites table was departitioned. Fixes #4652. See https://github.com/danbooru/danbooru/issues/4652#issuecomment-754993802 for more discussion of issues caused by the fav_string (in short: write amplification, post table bloat, and favorite inconsistency problems).
59 lines
1.5 KiB
Ruby
59 lines
1.5 KiB
Ruby
require "test_helper"
|
|
|
|
module Explore
|
|
class PostsControllerTest < ActionDispatch::IntegrationTest
|
|
context "in all cases" do
|
|
setup do
|
|
@post = create(:post)
|
|
end
|
|
|
|
context "#popular" do
|
|
should "render" do
|
|
get popular_explore_posts_path
|
|
assert_response :success
|
|
end
|
|
|
|
should "work with a blank date" do
|
|
get popular_explore_posts_path(date: "")
|
|
assert_response :success
|
|
end
|
|
end
|
|
|
|
context "#curated" do
|
|
should "render" do
|
|
@builder = create(:builder_user)
|
|
Favorite.create!(post: @post, user: @builder)
|
|
get curated_explore_posts_path
|
|
assert_response :success
|
|
end
|
|
end
|
|
|
|
context "#viewed" do
|
|
should "render" do
|
|
mock_post_view_rankings(Date.today, [[@post.id, 100]])
|
|
get viewed_explore_posts_path
|
|
assert_response :success
|
|
end
|
|
end
|
|
|
|
context "#searches" do
|
|
should "render" do
|
|
mock_post_search_rankings(Date.today, [["1girl", 100], ["original", 50]])
|
|
get searches_explore_posts_path
|
|
assert_response :success
|
|
assert_select "tbody tr", count: 2
|
|
end
|
|
end
|
|
|
|
context "#missed_searches" do
|
|
should "render" do
|
|
mock_missed_search_rankings([["1girl", 100], ["original", 50]])
|
|
get missed_searches_explore_posts_path
|
|
assert_response :success
|
|
assert_select "tbody tr", count: 2
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|