add test case for tag category changing, immediately update cache for tag category changes in local server
This commit is contained in:
@@ -86,7 +86,9 @@ class Tag < ActiveRecord::Base
|
|||||||
|
|
||||||
def update_category_cache_for_all
|
def update_category_cache_for_all
|
||||||
if category_changed?
|
if category_changed?
|
||||||
Danbooru.config.all_server_hosts.each do |host|
|
update_category_cache
|
||||||
|
|
||||||
|
Danbooru.config.other_server_hosts.each do |host|
|
||||||
delay(:queue => host).update_category_cache
|
delay(:queue => host).update_category_cache
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -353,6 +353,28 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
@post = FactoryGirl.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with an artist tag that is then changed to copyright" do
|
||||||
|
setup do
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
|
@post = Post.find(@post.id)
|
||||||
|
@post.update_attribute(:tag_string, "art:abc")
|
||||||
|
@post = Post.find(@post.id)
|
||||||
|
@post.update_attribute(:tag_string, "copy:abc")
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
Delayed::Worker.delay_jobs = true
|
||||||
|
end
|
||||||
|
|
||||||
|
should "update the category of the tag" do
|
||||||
|
assert_equal(Tag.categories.copyright, Tag.find_by_name("abc").category)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "update the category cache of the tag" do
|
||||||
|
assert_equal(Tag.categories.copyright, Cache.get("tc:abc"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "tagged with a metatag" do
|
context "tagged with a metatag" do
|
||||||
context "for a parent" do
|
context "for a parent" do
|
||||||
setup do
|
setup do
|
||||||
|
|||||||
Reference in New Issue
Block a user