tests: add more tags controller/model tests.

This commit is contained in:
evazion
2017-02-05 16:23:56 -06:00
parent 2b4c722bd1
commit cac5eae3c4
2 changed files with 20 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ class TagsControllerTest < ActionController::TestCase
context "index action" do
setup do
@tag = FactoryGirl.create(:tag, :name => "aaa")
@tag = FactoryGirl.create(:tag, name: "aaa", post_count: 1)
end
should "render" do
@@ -42,6 +42,15 @@ class TagsControllerTest < ActionController::TestCase
end
end
context "autocomplete action" do
should "render" do
FactoryGirl.create(:tag, name: "touhou", post_count: 1)
get :autocomplete, { search: { name_matches: "t" }, format: :json }
assert_response :success
end
end
context "show action" do
setup do
@tag = FactoryGirl.create(:tag)

View File

@@ -208,4 +208,14 @@ class TagTest < ActiveSupport::TestCase
end
end
end
context "A tag with a negative post count" do
should "be fixed" do
tag = FactoryGirl.create(:tag, name: "touhou", post_count: -10)
post = FactoryGirl.create(:post, tag_string: "touhou")
Tag.clean_up_negative_post_counts!
assert_equal(1, tag.reload.post_count)
end
end
end