Test forum posts generated by tag alias approval.

This commit is contained in:
evazion
2016-10-16 08:37:17 +00:00
parent e67194c19d
commit 0dcd7e82be
2 changed files with 21 additions and 6 deletions

View File

@@ -87,6 +87,7 @@ class User < ActiveRecord::Base
has_many :note_versions, :foreign_key => "updater_id"
has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id"
has_many :saved_searches
has_many :forum_posts, lambda {order("forum_posts.created_at")}, :foreign_key => "creator_id"
belongs_to :inviter, :class_name => "User"
after_update :create_mod_action
accepts_nested_attributes_for :dmail_filter

View File

@@ -137,25 +137,30 @@ class TagAliasTest < ActiveSupport::TestCase
setup do
@admin = FactoryGirl.create(:admin_user)
@topic = FactoryGirl.create(:forum_topic)
@alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic)
@alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic, :status => "pending")
end
context "and conflicting wiki pages" do
setup do
@wiki1 = FactoryGirl.create(:wiki_page, :title => "aaa")
@wiki2 = FactoryGirl.create(:wiki_page, :title => "bbb")
@alias.approve!(@admin)
@admin.reload # reload to get the forum post the approval created.
end
should "update the topic when processed" do
assert_difference("ForumPost.count") do
@alias.rename_wiki_and_artist
end
should "update the forum topic when approved" do
assert(@topic.posts.last, @admin.forum_posts.last)
assert_match(/The tag alias .* been approved/, @admin.forum_posts.last.body)
end
should "warn about conflicting wiki pages when approved" do
assert_match(/has conflicting wiki pages/, @admin.forum_posts.last.body)
end
end
should "update the topic when processed" do
assert_difference("ForumPost.count") do
@alias.process!
@alias.approve!(@admin)
end
end
@@ -164,6 +169,15 @@ class TagAliasTest < ActiveSupport::TestCase
@alias.reject!
end
end
should "update the topic when failed" do
@alias.stubs(:sleep).returns(true)
@alias.stubs(:update_posts).raises(Exception, "oh no")
@alias.approve!(@admin)
assert_match(/error: oh no/, @alias.status)
assert_match(/The tag alias .* failed during processing/, @admin.forum_posts.last.body)
end
end
end
end