refactor forum notifications for tag changes

This commit is contained in:
r888888888
2017-03-31 17:42:14 -07:00
parent 441022960a
commit 19b8d41d09
17 changed files with 422 additions and 317 deletions

View File

@@ -64,17 +64,21 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
context "with an associated forum topic" do
setup do
@topic = FactoryGirl.create(:forum_topic)
@req = FactoryGirl.create(:bulk_update_request, :script => "create alias AAA -> BBB", :forum_topic => @topic)
@topic = FactoryGirl.create(:forum_topic, :title => "[bulk] hoge")
@post = FactoryGirl.create(:forum_post, :topic_id => @topic.id)
@req = FactoryGirl.create(:bulk_update_request, :script => "create alias AAA -> BBB", :forum_topic_id => @topic.id, :forum_post_id => @post.id, :title => "[bulk] hoge")
end
should "handle errors gracefully" do
@req.stubs(:update_forum_topic_for_approve).raises(RuntimeError.new("blah"))
assert_difference("Dmail.count", 1) do
@req.stubs(:update).raises(RuntimeError.new("blah"))
assert_difference("ForumPost.count", 1) do
@req.approve!(@admin)
end
assert_match(/Exception: RuntimeError/, Dmail.last.body)
assert_match(/Message: blah/, Dmail.last.body)
@topic.reload
@post.reload
assert_match(/\[FAILED\]/, @topic.title)
assert_match(/UPDATE/, @post.body)
end
should "downcase the text" do
@@ -85,6 +89,11 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
assert_difference("ForumPost.count") do
@req.approve!(@admin)
end
@topic.reload
@post.reload
assert_match(/\[APPROVED\]/, @topic.title)
assert_match(/UPDATE/, @post.body)
end
should "update the topic when rejected" do
@@ -93,6 +102,11 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
assert_difference("ForumPost.count") do
@req.reject!
end
@topic.reload
@post.reload
assert_match(/\[REJECTED\]/, @topic.title)
assert_match(/UPDATE/, @post.body)
end
end
end