potential fix for #3783

This commit is contained in:
Albert Yi
2018-07-26 15:28:34 -07:00
parent 2b3352469d
commit 9082ddf455
2 changed files with 20 additions and 1 deletions

View File

@@ -1603,6 +1603,16 @@ class PostTest < ActiveSupport::TestCase
end
context "Updating:" do
context "an existing post" do
setup { @post = FactoryBot.create(:post) }
should "call Tag.increment_post_counts with the correct params" do
@post.reload
Tag.expects(:increment_post_counts).once.with(["abc"])
@post.update(tag_string: "tag1 abc")
end
end
context "A rating unlocked post" do
setup { @post = FactoryBot.create(:post) }
subject { @post }
@@ -1823,6 +1833,15 @@ class PostTest < ActiveSupport::TestCase
assert_equal(user2.name, post.uploader_name)
end
context "tag post counts" do
setup { @post = FactoryBot.build(:post) }
should "call Tag.increment_post_counts with the correct params" do
Tag.expects(:increment_post_counts).once.with(["tag1", "tag2"])
@post.save
end
end
should "increment the uploaders post_upload_count" do
assert_difference(-> { CurrentUser.user.post_upload_count }) do
post = FactoryBot.create(:post, uploader: CurrentUser.user)