fixes #2378
This commit is contained in:
@@ -198,11 +198,15 @@ class TagAlias < ActiveRecord::Base
|
||||
|
||||
def rename_wiki_and_artist
|
||||
antecedent_wiki = WikiPage.titled(antecedent_name).first
|
||||
if antecedent_wiki.present? && WikiPage.titled(consequent_name).blank?
|
||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||
antecedent_wiki.update_attributes(
|
||||
:title => consequent_name
|
||||
)
|
||||
if antecedent_wiki.present?
|
||||
if WikiPage.titled(consequent_name).blank?
|
||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||
antecedent_wiki.update_attributes(
|
||||
:title => consequent_name
|
||||
)
|
||||
end
|
||||
else
|
||||
update_forum_topic_for_wiki_conflict
|
||||
end
|
||||
end
|
||||
|
||||
@@ -249,6 +253,16 @@ class TagAlias < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def update_forum_topic_for_wiki_conflict
|
||||
if forum_topic
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
forum_topic.posts.create(
|
||||
:body => "The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reject!
|
||||
update_column(:status, "deleted")
|
||||
clear_all_cache
|
||||
|
||||
@@ -99,6 +99,19 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
@alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic)
|
||||
end
|
||||
|
||||
context "and conflicting wiki pages" do
|
||||
setup do
|
||||
@wiki1 = FactoryGirl.create(:wiki_page, :title => "aaa")
|
||||
@wiki2 = FactoryGirl.create(:wiki_page, :title => "bbb")
|
||||
end
|
||||
|
||||
should "update the topic when processed" do
|
||||
assert_difference("ForumPost.count") do
|
||||
@alias.rename_wiki_and_artist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
should "update the topic when processed" do
|
||||
assert_difference("ForumPost.count") do
|
||||
@alias.process!
|
||||
|
||||
Reference in New Issue
Block a user