fixes #2378
This commit is contained in:
@@ -198,11 +198,15 @@ class TagAlias < ActiveRecord::Base
|
|||||||
|
|
||||||
def rename_wiki_and_artist
|
def rename_wiki_and_artist
|
||||||
antecedent_wiki = WikiPage.titled(antecedent_name).first
|
antecedent_wiki = WikiPage.titled(antecedent_name).first
|
||||||
if antecedent_wiki.present? && WikiPage.titled(consequent_name).blank?
|
if antecedent_wiki.present?
|
||||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
if WikiPage.titled(consequent_name).blank?
|
||||||
antecedent_wiki.update_attributes(
|
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||||
:title => consequent_name
|
antecedent_wiki.update_attributes(
|
||||||
)
|
:title => consequent_name
|
||||||
|
)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
update_forum_topic_for_wiki_conflict
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -249,6 +253,16 @@ class TagAlias < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
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!
|
def reject!
|
||||||
update_column(:status, "deleted")
|
update_column(:status, "deleted")
|
||||||
clear_all_cache
|
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)
|
@alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic)
|
||||||
end
|
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
|
should "update the topic when processed" do
|
||||||
assert_difference("ForumPost.count") do
|
assert_difference("ForumPost.count") do
|
||||||
@alias.process!
|
@alias.process!
|
||||||
|
|||||||
Reference in New Issue
Block a user