Moved to taggable concern.
This commit is contained in:
parent
55a31084bc
commit
7dfa5e546f
9 changed files with 185 additions and 190 deletions
|
@ -128,12 +128,7 @@ class TicketsController < ApplicationController
|
|||
if params[:tags] && !params[:tags].empty?
|
||||
tags = params[:tags].split(/,/)
|
||||
tags.each { |tag|
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket.id,
|
||||
item: tag,
|
||||
created_by_id: current_user.id,
|
||||
)
|
||||
ticket.tag_add(tag)
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -615,10 +610,7 @@ class TicketsController < ApplicationController
|
|||
}
|
||||
|
||||
# get tags
|
||||
tags = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket.id,
|
||||
)
|
||||
tags = ticket.tag_list
|
||||
|
||||
# return result
|
||||
{
|
||||
|
|
78
app/models/concerns/taggable.rb
Normal file
78
app/models/concerns/taggable.rb
Normal file
|
@ -0,0 +1,78 @@
|
|||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
||||
module Taggable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_destroy :tag_destroy
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
add an tag to model
|
||||
|
||||
model = Model.find(123)
|
||||
model.tag_add(name)
|
||||
|
||||
=end
|
||||
|
||||
def tag_add(name, current_user_id = nil)
|
||||
Tag.tag_add(
|
||||
object: self.class.to_s,
|
||||
o_id: id,
|
||||
item: name,
|
||||
created_by_id: current_user_id,
|
||||
)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
remove an tag of model
|
||||
|
||||
model = Model.find(123)
|
||||
model.tag_remove(name)
|
||||
|
||||
=end
|
||||
|
||||
def tag_remove(name, current_user_id = nil)
|
||||
Tag.tag_remove(
|
||||
object: self.class.to_s,
|
||||
o_id: id,
|
||||
item: name,
|
||||
created_by_id: current_user_id,
|
||||
)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
tag list of model
|
||||
|
||||
model = Model.find(123)
|
||||
tags = model.tag_list
|
||||
|
||||
=end
|
||||
|
||||
def tag_list
|
||||
Tag.tag_list(
|
||||
object: self.class.to_s,
|
||||
o_id: id,
|
||||
)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
destroy all tags of an object
|
||||
|
||||
model = Model.find(123)
|
||||
model.tag_destroy
|
||||
|
||||
=end
|
||||
|
||||
def tag_destroy(current_user_id = nil)
|
||||
Tag.tag_destroy(
|
||||
object: self.class.to_s,
|
||||
o_id: id,
|
||||
created_by_id: current_user_id,
|
||||
)
|
||||
end
|
||||
|
||||
end
|
|
@ -95,6 +95,36 @@ or by ids
|
|||
|
||||
=begin
|
||||
|
||||
remove all tags of certain object
|
||||
|
||||
Tag.tag_destroy(
|
||||
object: 'Ticket',
|
||||
o_id: ticket.id,
|
||||
created_by_id: current_user.id,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def self.tag_destroy(data)
|
||||
|
||||
# lookups
|
||||
if data[:object]
|
||||
data[:tag_object_id] = Tag::Object.lookup_by_name_and_create(data[:object]).id
|
||||
else
|
||||
data[:object] = Tag::Object.lookup(id: data[:tag_object_id]).name
|
||||
end
|
||||
|
||||
# create history
|
||||
result = Tag.where(
|
||||
tag_object_id: data[:tag_object_id],
|
||||
o_id: data[:o_id],
|
||||
)
|
||||
result.each(&:destroy)
|
||||
true
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
tag list for certain object
|
||||
|
||||
tags = Tag.tag_list(
|
||||
|
|
|
@ -5,6 +5,7 @@ class Ticket < ApplicationModel
|
|||
include NotifiesClients
|
||||
include LatestChangeObserved
|
||||
include Historisable
|
||||
include Taggable
|
||||
include SearchIndexed
|
||||
|
||||
include Ticket::Escalation
|
||||
|
@ -771,23 +772,15 @@ perform changes on ticket
|
|||
|
||||
# update tags
|
||||
if key == 'ticket.tags'
|
||||
next if value['value'].empty?
|
||||
next if value['value'].blank?
|
||||
tags = value['value'].split(/,/)
|
||||
if value['operator'] == 'add'
|
||||
tags.each { |tag|
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: id,
|
||||
item: tag,
|
||||
)
|
||||
tag_add(tag)
|
||||
}
|
||||
elsif value['operator'] == 'remove'
|
||||
tags.each { |tag|
|
||||
Tag.tag_remove(
|
||||
object: 'Ticket',
|
||||
o_id: id,
|
||||
item: tag,
|
||||
)
|
||||
tag_remove(tag)
|
||||
}
|
||||
else
|
||||
logger.error "Unknown #{attribute} operator #{value['operator']}"
|
||||
|
|
|
@ -20,7 +20,7 @@ returns
|
|||
|
||||
# collect article data
|
||||
# add tags
|
||||
tags = Tag.tag_list(object: 'Ticket', o_id: id)
|
||||
tags = tag_list
|
||||
if tags.present?
|
||||
attributes[:tag] = tags
|
||||
end
|
||||
|
|
|
@ -241,12 +241,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
|
|||
preferences: {},
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'someTagA',
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket1.tag_add('someTagA', 1)
|
||||
sleep 1
|
||||
|
||||
ticket2 = Ticket.create(
|
||||
|
@ -272,12 +267,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
|
|||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
item: 'someTagB',
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket2.tag_add('someTagB', 1)
|
||||
sleep 1
|
||||
|
||||
ticket3 = Ticket.create(
|
||||
|
|
|
@ -323,19 +323,9 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
assert_equal(5 + 10, Karma.score_by_user(agent2))
|
||||
assert_equal(0, Karma.score_by_user(customer1))
|
||||
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'Tag1',
|
||||
created_by_id: agent1.id,
|
||||
)
|
||||
ticket1.tag_add('Tag1', agent1.id)
|
||||
#travel 5.seconds
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'Tag2',
|
||||
created_by_id: agent1.id,
|
||||
)
|
||||
ticket1.tag_add('Tag2', agent1.id)
|
||||
|
||||
# execute object transaction
|
||||
Observer::Transaction.commit
|
||||
|
@ -345,18 +335,8 @@ class KarmaTest < ActiveSupport::TestCase
|
|||
assert_equal(5 + 10, Karma.score_by_user(agent2))
|
||||
assert_equal(0, Karma.score_by_user(customer1))
|
||||
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'Tag3',
|
||||
created_by_id: agent1.id,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'Tag4',
|
||||
created_by_id: agent2.id,
|
||||
)
|
||||
ticket1.tag_add('Tag3', agent1.id)
|
||||
ticket1.tag_add('Tag4', agent2.id)
|
||||
|
||||
# execute object transaction
|
||||
Observer::Transaction.commit
|
||||
|
|
|
@ -185,81 +185,32 @@ class TagTest < ActiveSupport::TestCase
|
|||
created_by_id: 1,
|
||||
)
|
||||
travel 2.seconds
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'some tag1',
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'some tag2 ',
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: ' some tag3',
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'some TAG4',
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: ' some tag4',
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
item: 'some tag3',
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
item: 'some TAG4',
|
||||
created_by_id: 1,
|
||||
)
|
||||
Tag.tag_add(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
item: 'some tag4 ',
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
Tag.tag_remove(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
item: 'some tag1',
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket1.tag_add('some tag1', 1)
|
||||
ticket1.tag_add('some tag2 ', 1)
|
||||
ticket1.tag_add(' some tag3', 1)
|
||||
ticket1.tag_add('some TAG4', 1)
|
||||
ticket1.tag_add(' some tag4', 1)
|
||||
|
||||
ticket2.tag_add('some tag3', 1)
|
||||
ticket2.tag_add('some TAG4', 1)
|
||||
ticket2.tag_add('some tag4 ', 1)
|
||||
|
||||
ticket1.tag_remove('some tag1', 1)
|
||||
|
||||
ticket1_lookup1 = Ticket.lookup(id: ticket1.id)
|
||||
assert_not_equal(ticket1.updated_at.to_s, ticket1_lookup1.updated_at.to_s)
|
||||
ticket2_lookup1 = Ticket.lookup(id: ticket2.id)
|
||||
assert_not_equal(ticket2.updated_at.to_s, ticket2_lookup1.updated_at.to_s)
|
||||
|
||||
tags_ticket1 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
)
|
||||
tags_ticket1 = ticket1.tag_list
|
||||
assert_equal(4, tags_ticket1.count)
|
||||
assert(tags_ticket1.include?('some tag2'))
|
||||
assert(tags_ticket1.include?('some tag3'))
|
||||
assert(tags_ticket1.include?('some TAG4'))
|
||||
assert(tags_ticket1.include?('some tag4'))
|
||||
|
||||
tags_ticket2 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
)
|
||||
tags_ticket2 = ticket2.tag_list
|
||||
assert_equal(3, tags_ticket2.count)
|
||||
assert(tags_ticket2.include?('some tag3'))
|
||||
assert(tags_ticket2.include?('some TAG4'))
|
||||
|
@ -279,21 +230,14 @@ class TagTest < ActiveSupport::TestCase
|
|||
ticket2_lookup2 = Ticket.lookup(id: ticket2.id)
|
||||
assert_not_equal(ticket2_lookup2.updated_at.to_s, ticket2_lookup1.updated_at.to_s)
|
||||
|
||||
tags_ticket1 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
)
|
||||
|
||||
tags_ticket1 = ticket1.tag_list
|
||||
assert_equal(4, tags_ticket1.count)
|
||||
assert(tags_ticket1.include?('some tag2'))
|
||||
assert(tags_ticket1.include?('some tag33'))
|
||||
assert(tags_ticket1.include?('some TAG4'))
|
||||
assert(tags_ticket1.include?('some tag4'))
|
||||
|
||||
tags_ticket2 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
)
|
||||
tags_ticket2 = ticket2.tag_list
|
||||
assert_equal(3, tags_ticket2.count)
|
||||
assert(tags_ticket2.include?('some tag33'))
|
||||
assert(tags_ticket2.include?('some TAG4'))
|
||||
|
@ -312,19 +256,13 @@ class TagTest < ActiveSupport::TestCase
|
|||
ticket2_lookup3 = Ticket.lookup(id: ticket2.id)
|
||||
assert_not_equal(ticket2_lookup3.updated_at.to_s, ticket2_lookup2.updated_at.to_s)
|
||||
|
||||
tags_ticket1 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
)
|
||||
tags_ticket1 = ticket1.tag_list
|
||||
assert_equal(3, tags_ticket1.count)
|
||||
assert(tags_ticket1.include?('some tag2'))
|
||||
assert(tags_ticket1.include?('some TAG4'))
|
||||
assert(tags_ticket1.include?('some tag4'))
|
||||
|
||||
tags_ticket2 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
)
|
||||
tags_ticket2 = ticket2.tag_list
|
||||
assert_equal(3, tags_ticket2.count)
|
||||
assert(tags_ticket2.include?('some tag2'))
|
||||
assert(tags_ticket2.include?('some TAG4'))
|
||||
|
@ -337,18 +275,12 @@ class TagTest < ActiveSupport::TestCase
|
|||
tag_item4 = Tag::Item.find_by(name: 'some TAG4')
|
||||
Tag::Item.remove(tag_item4.id)
|
||||
|
||||
tags_ticket1 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket1.id,
|
||||
)
|
||||
tags_ticket1 = ticket1.tag_list
|
||||
assert_equal(2, tags_ticket1.count)
|
||||
assert(tags_ticket1.include?('some tag2'))
|
||||
assert(tags_ticket1.include?('some tag4'))
|
||||
|
||||
tags_ticket2 = Tag.tag_list(
|
||||
object: 'Ticket',
|
||||
o_id: ticket2.id,
|
||||
)
|
||||
tags_ticket2 = ticket2.tag_list
|
||||
assert_equal(2, tags_ticket2.count)
|
||||
assert(tags_ticket2.include?('some tag2'))
|
||||
assert(tags_ticket2.include?('some tag4'))
|
||||
|
|
|
@ -179,7 +179,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
Observer::Transaction.commit
|
||||
|
||||
|
@ -189,7 +189,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal(%w(aa kk abc), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal(%w(aa kk abc), ticket1.tag_list)
|
||||
article1 = ticket1.articles.last
|
||||
assert_match('Zammad <zammad@localhost>', article1.from)
|
||||
assert_match('nicole.braun@zammad.org', article1.to)
|
||||
|
@ -208,7 +208,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal(%w(aa kk abc), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal(%w(aa kk abc), ticket1.tag_list)
|
||||
|
||||
ticket1.state = Ticket::State.lookup(name: 'open')
|
||||
ticket1.save!
|
||||
|
@ -221,7 +221,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('open', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal(%w(aa kk abc), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal(%w(aa kk abc), ticket1.tag_list)
|
||||
|
||||
ticket1.state = Ticket::State.lookup(name: 'new')
|
||||
ticket1.save!
|
||||
|
@ -234,7 +234,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal(%w(aa abc), Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal(%w(aa abc), ticket1.tag_list)
|
||||
|
||||
ticket2 = Ticket.create(
|
||||
title: "some title\n äöüß",
|
||||
|
@ -252,7 +252,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('open', ticket2.state.name, 'ticket2.state verify')
|
||||
assert_equal('2 normal', ticket2.priority.name, 'ticket2.priority verify')
|
||||
assert_equal(0, ticket2.articles.count, 'ticket2.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket2.id))
|
||||
assert_equal([], ticket2.tag_list)
|
||||
|
||||
Observer::Transaction.commit
|
||||
|
||||
|
@ -262,7 +262,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('open', ticket2.state.name, 'ticket2.state verify')
|
||||
assert_equal('2 normal', ticket2.priority.name, 'ticket2.priority verify')
|
||||
assert_equal(0, ticket2.articles.count, 'ticket2.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket2.id))
|
||||
assert_equal([], ticket2.tag_list)
|
||||
|
||||
ticket3 = Ticket.create(
|
||||
title: "some <b>title</b>\n äöüß3",
|
||||
|
@ -293,7 +293,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket3.state.name, 'ticket3.state verify')
|
||||
assert_equal('2 normal', ticket3.priority.name, 'ticket3.priority verify')
|
||||
assert_equal(1, ticket3.articles.count, 'ticket3.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket3.id))
|
||||
assert_equal([], ticket3.tag_list)
|
||||
|
||||
Observer::Transaction.commit
|
||||
|
||||
|
@ -303,7 +303,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket3.state.name, 'ticket3.state verify')
|
||||
assert_equal('3 high', ticket3.priority.name, 'ticket3.priority verify')
|
||||
assert_equal(3, ticket3.articles.count, 'ticket3.articles verify')
|
||||
assert_equal(%w(aa kk abc article_create_trigger), Tag.tag_list(object: 'Ticket', o_id: ticket3.id))
|
||||
assert_equal(%w(aa kk abc article_create_trigger), ticket3.tag_list)
|
||||
article3 = ticket3.articles[1]
|
||||
assert_match('Zammad <zammad@localhost>', article3.from)
|
||||
assert_match('nicole.braun@zammad.org', article3.to)
|
||||
|
@ -341,7 +341,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket3.state.name, 'ticket3.state verify')
|
||||
assert_equal('3 high', ticket3.priority.name, 'ticket3.priority verify')
|
||||
assert_equal(4, ticket3.articles.count, 'ticket3.articles verify')
|
||||
assert_equal(%w(aa abc article_create_trigger), Tag.tag_list(object: 'Ticket', o_id: ticket3.id))
|
||||
assert_equal(%w(aa abc article_create_trigger), ticket3.tag_list)
|
||||
|
||||
Ticket::Article.create(
|
||||
ticket_id: ticket3.id,
|
||||
|
@ -366,7 +366,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket3.state.name, 'ticket3.state verify')
|
||||
assert_equal('3 high', ticket3.priority.name, 'ticket3.priority verify')
|
||||
assert_equal(5, ticket3.articles.count, 'ticket3.articles verify')
|
||||
assert_equal(%w(aa abc article_create_trigger), Tag.tag_list(object: 'Ticket', o_id: ticket3.id))
|
||||
assert_equal(%w(aa abc article_create_trigger), ticket3.tag_list)
|
||||
|
||||
Ticket::Article.create(
|
||||
ticket_id: ticket3.id,
|
||||
|
@ -391,7 +391,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket3.state.name, 'ticket3.state verify')
|
||||
assert_equal('3 high', ticket3.priority.name, 'ticket3.priority verify')
|
||||
assert_equal(7, ticket3.articles.count, 'ticket3.articles verify')
|
||||
assert_equal(%w(aa abc article_create_trigger), Tag.tag_list(object: 'Ticket', o_id: ticket3.id))
|
||||
assert_equal(%w(aa abc article_create_trigger), ticket3.tag_list)
|
||||
end
|
||||
|
||||
test '2 actions - create' do
|
||||
|
@ -1234,7 +1234,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
Observer::Transaction.commit
|
||||
|
||||
|
@ -1371,7 +1371,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
Ticket::Article.create(
|
||||
|
@ -1396,7 +1396,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
ticket1.owner_id = 1
|
||||
|
@ -1410,7 +1410,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
end
|
||||
|
||||
|
@ -1498,7 +1498,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
Ticket::Article.create(
|
||||
|
@ -1523,7 +1523,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
ticket1.owner_id = 1
|
||||
|
@ -1537,7 +1537,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
Ticket::Article.create(
|
||||
|
@ -1562,7 +1562,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(3, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent2.id
|
||||
ticket1.owner_id = agent2.id
|
||||
|
@ -1576,7 +1576,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(3, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
Ticket::Article.create(
|
||||
|
@ -1601,7 +1601,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(4, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
end
|
||||
|
||||
test '8 owner auto assignment' do
|
||||
|
@ -1679,7 +1679,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
Ticket::Article.create(
|
||||
|
@ -1704,7 +1704,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
ticket1.priority = Ticket::Priority.find_by(name: '1 low')
|
||||
|
@ -1719,7 +1719,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('1 low', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
ticket1.owner_id = 1
|
||||
|
@ -1734,7 +1734,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('1 low', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
ticket1.owner_id = agent.id
|
||||
|
@ -1749,7 +1749,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('1 low', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
end
|
||||
|
||||
test '9 vip priority set' do
|
||||
|
@ -1826,7 +1826,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
Observer::Transaction.commit
|
||||
|
||||
|
@ -1838,7 +1838,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
customer.vip = false
|
||||
customer.save!
|
||||
|
@ -1872,7 +1872,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket2.state.name, 'ticket2.state verify')
|
||||
assert_equal('2 normal', ticket2.priority.name, 'ticket2.priority verify')
|
||||
assert_equal(1, ticket2.articles.count, 'ticket2.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket2.id))
|
||||
assert_equal([], ticket2.tag_list)
|
||||
|
||||
Observer::Transaction.commit
|
||||
|
||||
|
@ -1884,7 +1884,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket2.state.name, 'ticket2.state verify')
|
||||
assert_equal('2 normal', ticket2.priority.name, 'ticket2.priority verify')
|
||||
assert_equal(1, ticket2.articles.count, 'ticket2.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket2.id))
|
||||
assert_equal([], ticket2.tag_list)
|
||||
|
||||
end
|
||||
|
||||
|
@ -1963,7 +1963,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
ticket1.owner_id = agent1.id
|
||||
|
@ -1978,7 +1978,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
ticket1.owner_id = agent1.id
|
||||
|
@ -1993,7 +1993,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
ticket1.owner_id = agent2.id
|
||||
|
@ -2008,7 +2008,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(3, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
end
|
||||
|
||||
|
@ -2101,7 +2101,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
Ticket::Article.create(
|
||||
ticket_id: ticket1.id,
|
||||
|
@ -2126,7 +2126,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(3, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
Ticket::Article.create(
|
||||
ticket_id: ticket1.id,
|
||||
|
@ -2151,7 +2151,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(5, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
ticket1.priority = Ticket::Priority.find_by(name: '3 high')
|
||||
ticket1.save!
|
||||
|
@ -2178,7 +2178,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(6, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
article.internal = false
|
||||
article.save!
|
||||
|
@ -2192,7 +2192,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(6, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
Ticket::Article.create(
|
||||
ticket_id: ticket1.id,
|
||||
|
@ -2217,7 +2217,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(7, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
end
|
||||
|
||||
test '12 notify on owner change' do
|
||||
|
@ -2384,7 +2384,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
ticket1.owner_id = agent.id
|
||||
|
@ -2400,7 +2400,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(3, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
Ticket::Article.create(
|
||||
ticket_id: ticket1.id,
|
||||
|
@ -2426,7 +2426,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(5, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
UserInfo.current_user_id = agent.id
|
||||
ticket1.owner_id = 1
|
||||
|
@ -2442,7 +2442,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
|||
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
||||
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
||||
assert_equal(6, ticket1.articles.count, 'ticket1.articles verify')
|
||||
assert_equal([], Tag.tag_list(object: 'Ticket', o_id: ticket1.id))
|
||||
assert_equal([], ticket1.tag_list)
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue