When processing an alias, rename, implication, mass update, or nuke, update the posts in parallel. This means that if we alias foo to bar, for example, then we use four processes at once to retag the posts from foo to bar. This doesn't mean that if we have two aliases in a BUR, we process both aliases in parallel. It simply means that when processing an alias, we update the posts in parallel for that alias.
49 lines
1.5 KiB
Ruby
49 lines
1.5 KiB
Ruby
require 'test_helper'
|
|
|
|
class ApplicationRecordTest < ActiveSupport::TestCase
|
|
setup do
|
|
@tags = FactoryBot.create_list(:tag, 3, post_count: 1)
|
|
end
|
|
|
|
context "ApplicationRecord#search" do
|
|
should "support the id param" do
|
|
assert_equal([@tags.first], Tag.search(id: @tags.first.id))
|
|
end
|
|
|
|
should "support ranges in the id param" do
|
|
assert_equal(@tags.reverse, Tag.search(id: ">=1"))
|
|
assert_equal(@tags.reverse, Tag.search(id: "#{@tags[0].id}..#{@tags[2].id}"))
|
|
assert_equal(@tags.reverse, Tag.search(id: @tags.map(&:id).join(",")))
|
|
end
|
|
|
|
should "support the created_at and updated_at params" do
|
|
assert_equal(@tags.reverse, Tag.search(created_at: ">=#{@tags.first.created_at}"))
|
|
assert_equal(@tags.reverse, Tag.search(updated_at: ">=#{@tags.first.updated_at}"))
|
|
end
|
|
end
|
|
|
|
context "ApplicationRecord#parallel_each" do
|
|
context "in threaded mode" do
|
|
should "set CurrentUser correctly" do
|
|
@user1 = create(:user)
|
|
@user2 = create(:user)
|
|
|
|
CurrentUser.scoped(@user1, "1.1.1.1") do
|
|
Tag.parallel_each do |tag|
|
|
assert_equal(@user1, CurrentUser.user)
|
|
assert_equal("1.1.1.1", CurrentUser.ip_addr)
|
|
|
|
CurrentUser.scoped(@user2, "2.2.2.2") do
|
|
assert_equal(@user2, CurrentUser.user)
|
|
assert_equal("2.2.2.2", CurrentUser.ip_addr)
|
|
end
|
|
|
|
assert_equal(@user1, CurrentUser.user)
|
|
assert_equal("1.1.1.1", CurrentUser.ip_addr)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|