diff --git a/app/models/post.rb b/app/models/post.rb index 6cf017458..7d22dac16 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -3,7 +3,7 @@ class Post < ActiveRecord::Base class DisapprovalError < Exception ; end class SearchError < Exception ; end - attr_accessor :old_tag_string, :old_parent_id, :has_constraints + attr_accessor :old_tag_string, :old_parent_id, :has_constraints, :disable_versioning after_destroy :delete_files after_destroy :delete_remote_files after_save :create_version @@ -868,6 +868,8 @@ class Post < ActiveRecord::Base module VersionMethods def create_version + return if disable_versioning + if created_at == updated_at CurrentUser.increment!(:post_update_count) versions.create( diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index 019afcbd3..40b7695a6 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -130,6 +130,7 @@ class TagAlias < ActiveRecord::Base escaped_antecedent_name = Regexp.escape(antecedent_name) fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip CurrentUser.scoped(creator, creator_ip_addr) do + post.disable_versioning = true post.update_attributes( :tag_string => fixed_tags ) diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index f47e47084..726c3dc74 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -125,6 +125,7 @@ class TagImplication < ActiveRecord::Base escaped_antecedent_name = Regexp.escape(antecedent_name) fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{antecedent_name} #{descendant_names} ").strip CurrentUser.scoped(creator, creator_ip_addr) do + post.disable_versioning = true post.update_attributes( :tag_string => fixed_tags ) diff --git a/test/unit/tag_alias_test.rb b/test/unit/tag_alias_test.rb index aab84adad..786b8fcaa 100644 --- a/test/unit/tag_alias_test.rb +++ b/test/unit/tag_alias_test.rb @@ -62,18 +62,6 @@ class TagAliasTest < ActiveSupport::TestCase end end - should "record the alias's creator in the tag history" do - uploader = FactoryGirl.create(:user) - post = nil - CurrentUser.scoped(uploader, "127.0.0.1") do - post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - end - tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "xxx") - post.reload - assert_not_equal(tag_alias.creator_id, post.uploader_id) - assert_equal(tag_alias.creator_id, post.versions.last.updater_id) - end - should "push the antecedent's category to the consequent" do tag1 = FactoryGirl.create(:tag, :name => "aaa", :category => 1) tag2 = FactoryGirl.create(:tag, :name => "bbb") diff --git a/test/unit/tag_implication_test.rb b/test/unit/tag_implication_test.rb index 19f52e640..e8ac6670b 100644 --- a/test/unit/tag_implication_test.rb +++ b/test/unit/tag_implication_test.rb @@ -107,17 +107,5 @@ class TagImplicationTest < ActiveSupport::TestCase p1.reload assert_equal("aaa bbb ccc xxx yyy", p1.tag_string) end - - should "record the implication's creator in the tag history" do - user = FactoryGirl.create(:user) - p1 = nil - CurrentUser.scoped(user, "127.0.0.1") do - p1 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - end - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") - p1.reload - assert_not_equal(ti1.creator_id, p1.uploader_id) - assert_equal(ti1.creator_id, p1.versions.last.updater_id) - end end end