add test case for tag category changing, immediately update cache for tag category changes in local server

This commit is contained in:
albert
2013-03-06 18:19:38 -05:00
parent 31927b54d7
commit e098863864
2 changed files with 25 additions and 1 deletions

View File

@@ -86,7 +86,9 @@ class Tag < ActiveRecord::Base
def update_category_cache_for_all
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
end
end

View File

@@ -353,6 +353,28 @@ class PostTest < ActiveSupport::TestCase
@post = FactoryGirl.create(:post)
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 "for a parent" do
setup do