fix tests
This commit is contained in:
@@ -1,23 +1,20 @@
|
||||
module Moderator
|
||||
class TagBatchChange
|
||||
class TagBatchChange < Struct.new(:antecedent, :consequent, :updater_id, :updater_ip_addr)
|
||||
class Error < Exception ; end
|
||||
|
||||
attr_reader :predicate, :consequent
|
||||
|
||||
def initialize(predicate, consequent)
|
||||
@predicate = predicate
|
||||
@consequent = consequent
|
||||
end
|
||||
|
||||
def execute
|
||||
raise Error.new("Predicate is missing") if predicate.blank?
|
||||
def perform
|
||||
raise Error.new("antecedent is missing") if antecedent.blank?
|
||||
|
||||
normalized_predicate = TagAlias.to_aliased(::Tag.scan_tags(predicate))
|
||||
normalized_antecedent = TagAlias.to_aliased(::Tag.scan_tags(antecedent))
|
||||
normalized_consequent = TagAlias.to_aliased(::Tag.scan_tags(consequent))
|
||||
|
||||
::Post.tag_match(predicate).each do |post|
|
||||
tags = (post.tag_array - normalized_predicate + normalized_consequent).join(" ")
|
||||
post.update_attributes(:tag_string => tags)
|
||||
|
||||
updater = User.find(updater_id)
|
||||
|
||||
CurrentUser.scoped(updater, updater_ip_addr) do
|
||||
::Post.tag_match(antecedent).each do |post|
|
||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
||||
post.update_attributes(:tag_string => tags)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user