diff --git a/app/models/user.rb b/app/models/user.rb index f3bddb175..15be1e2ad 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/test/unit/tag_alias_test.rb b/test/unit/tag_alias_test.rb index 16bce66c9..a8ff2abf4 100644 --- a/test/unit/tag_alias_test.rb +++ b/test/unit/tag_alias_test.rb @@ -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