From e0988638641878bf4c23116dec8581892ca6b149 Mon Sep 17 00:00:00 2001 From: albert Date: Wed, 6 Mar 2013 18:19:38 -0500 Subject: [PATCH] add test case for tag category changing, immediately update cache for tag category changes in local server --- app/models/tag.rb | 4 +++- test/unit/post_test.rb | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index 917f339c4..68fe723ad 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 4618f07df..139a71937 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -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