Improved tests.
This commit is contained in:
parent
9084c99d4b
commit
2575abf380
1 changed files with 98 additions and 94 deletions
|
@ -5,18 +5,18 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
test 'ticket create' do
|
test 'ticket create' do
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: "some title\n äöüß",
|
title: "some title\n äöüß",
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer_id: 2,
|
customer_id: 2,
|
||||||
state: Ticket::State.lookup( name: 'new' ),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
priority: Ticket::Priority.lookup( name: '2 normal' ),
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert( ticket, 'ticket created' )
|
assert(ticket, 'ticket created')
|
||||||
|
|
||||||
assert_equal( ticket.title, 'some title äöüß', 'ticket.title verify' )
|
assert_equal(ticket.title, 'some title äöüß', 'ticket.title verify')
|
||||||
assert_equal( ticket.group.name, 'Users', 'ticket.group verify' )
|
assert_equal(ticket.group.name, 'Users', 'ticket.group verify')
|
||||||
assert_equal( ticket.state.name, 'new', 'ticket.state verify' )
|
assert_equal(ticket.state.name, 'new', 'ticket.state verify')
|
||||||
|
|
||||||
# create inbound article #1
|
# create inbound article #1
|
||||||
article_inbound1 = Ticket::Article.create(
|
article_inbound1 = Ticket::Article.create(
|
||||||
|
@ -27,20 +27,20 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
message_id: 'some@id',
|
message_id: 'some@id',
|
||||||
body: 'some message article_inbound1 😍😍😍',
|
body: 'some message article_inbound1 😍😍😍',
|
||||||
internal: false,
|
internal: false,
|
||||||
sender: Ticket::Article::Sender.where(name: 'Customer').first,
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
||||||
type: Ticket::Article::Type.where(name: 'email').first,
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert_equal( article_inbound1.body, 'some message article_inbound1 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound' )
|
assert_equal(article_inbound1.body, 'some message article_inbound1 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound')
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.article_count, 1, 'ticket.article_count verify - inbound' )
|
assert_equal(ticket.article_count, 1, 'ticket.article_count verify - inbound')
|
||||||
assert_equal( ticket.last_contact.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact verify - inbound' )
|
assert_equal(ticket.last_contact.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact verify - inbound')
|
||||||
assert_equal( ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
|
assert_equal(ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
|
||||||
assert_equal( ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound' )
|
assert_equal(ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound')
|
||||||
assert_equal( ticket.first_response, nil, 'ticket.first_response verify - inbound' )
|
assert_equal(ticket.first_response, nil, 'ticket.first_response verify - inbound')
|
||||||
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - inbound' )
|
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - inbound')
|
||||||
|
|
||||||
# create inbound article #2
|
# create inbound article #2
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -52,20 +52,20 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
message_id: 'some@id',
|
message_id: 'some@id',
|
||||||
body: 'some message article_inbound2 😍😍😍',
|
body: 'some message article_inbound2 😍😍😍',
|
||||||
internal: false,
|
internal: false,
|
||||||
sender: Ticket::Article::Sender.where(name: 'Customer').first,
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
||||||
type: Ticket::Article::Type.where(name: 'email').first,
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert_equal( article_inbound2.body, 'some message article_inbound2 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound' )
|
assert_equal(article_inbound2.body, 'some message article_inbound2 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound')
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.article_count, 2, 'ticket.article_count verify - inbound' )
|
assert_equal(ticket.article_count, 2, 'ticket.article_count verify - inbound')
|
||||||
assert_equal( ticket.last_contact.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact verify - inbound' )
|
assert_equal(ticket.last_contact.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact verify - inbound')
|
||||||
assert_equal( ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
|
assert_equal(ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
|
||||||
assert_equal( ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound' )
|
assert_equal(ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound')
|
||||||
assert_equal( ticket.first_response, nil, 'ticket.first_response verify - inbound' )
|
assert_equal(ticket.first_response, nil, 'ticket.first_response verify - inbound')
|
||||||
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - inbound' )
|
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - inbound')
|
||||||
|
|
||||||
# create note article
|
# create note article
|
||||||
article_note = Ticket::Article.create(
|
article_note = Ticket::Article.create(
|
||||||
|
@ -74,21 +74,21 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
subject: "some\nnote",
|
subject: "some\nnote",
|
||||||
body: "some\n message",
|
body: "some\n message",
|
||||||
internal: true,
|
internal: true,
|
||||||
sender: Ticket::Article::Sender.where(name: 'Agent').first,
|
sender: Ticket::Article::Sender.find_by(name: 'Agent'),
|
||||||
type: Ticket::Article::Type.where(name: 'note').first,
|
type: Ticket::Article::Type.find_by(name: 'note'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert_equal( article_note.subject, 'some note', 'article_note.subject verify - inbound' )
|
assert_equal(article_note.subject, 'some note', 'article_note.subject verify - inbound')
|
||||||
assert_equal( article_note.body, "some\n message", 'article_note.body verify - inbound' )
|
assert_equal(article_note.body, "some\n message", 'article_note.body verify - inbound')
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.article_count, 3, 'ticket.article_count verify - note' )
|
assert_equal(ticket.article_count, 3, 'ticket.article_count verify - note')
|
||||||
assert_equal( ticket.last_contact.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact verify - note' )
|
assert_equal(ticket.last_contact.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact verify - note')
|
||||||
assert_equal( ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - note' )
|
assert_equal(ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - note')
|
||||||
assert_equal( ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - note' )
|
assert_equal(ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - note')
|
||||||
assert_equal( ticket.first_response, nil, 'ticket.first_response verify - note' )
|
assert_equal(ticket.first_response, nil, 'ticket.first_response verify - note')
|
||||||
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - note' )
|
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - note')
|
||||||
|
|
||||||
# create outbound article
|
# create outbound article
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -100,19 +100,19 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
message_id: 'some@id2',
|
message_id: 'some@id2',
|
||||||
body: 'some message 2',
|
body: 'some message 2',
|
||||||
internal: false,
|
internal: false,
|
||||||
sender: Ticket::Article::Sender.where(name: 'Agent').first,
|
sender: Ticket::Article::Sender.find_by(name: 'Agent'),
|
||||||
type: Ticket::Article::Type.where(name: 'email').first,
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.article_count, 4, 'ticket.article_count verify - outbound' )
|
assert_equal(ticket.article_count, 4, 'ticket.article_count verify - outbound')
|
||||||
assert_equal( ticket.last_contact.to_s, article_outbound.created_at.to_s, 'ticket.last_contact verify - outbound' )
|
assert_equal(ticket.last_contact.to_s, article_outbound.created_at.to_s, 'ticket.last_contact verify - outbound')
|
||||||
assert_equal( ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - outbound' )
|
assert_equal(ticket.last_contact_customer.to_s, article_inbound1.created_at.to_s, 'ticket.last_contact_customer verify - outbound')
|
||||||
assert_equal( ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound' )
|
assert_equal(ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound')
|
||||||
assert_equal( ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound' )
|
assert_equal(ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound')
|
||||||
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - outbound' )
|
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - outbound')
|
||||||
|
|
||||||
# create inbound article #3
|
# create inbound article #3
|
||||||
article_inbound3 = Ticket::Article.create(
|
article_inbound3 = Ticket::Article.create(
|
||||||
|
@ -123,20 +123,20 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
message_id: 'some@id',
|
message_id: 'some@id',
|
||||||
body: 'some message article_inbound3 😍😍😍',
|
body: 'some message article_inbound3 😍😍😍',
|
||||||
internal: false,
|
internal: false,
|
||||||
sender: Ticket::Article::Sender.where(name: 'Customer').first,
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
||||||
type: Ticket::Article::Type.where(name: 'email').first,
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert_equal( article_inbound3.body, 'some message article_inbound3 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound' )
|
assert_equal(article_inbound3.body, 'some message article_inbound3 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound')
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.article_count, 5, 'ticket.article_count verify - inbound' )
|
assert_equal(ticket.article_count, 5, 'ticket.article_count verify - inbound')
|
||||||
assert_equal( ticket.last_contact.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact verify - inbound' )
|
assert_equal(ticket.last_contact.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact verify - inbound')
|
||||||
assert_equal( ticket.last_contact_customer.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
|
assert_equal(ticket.last_contact_customer.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
|
||||||
assert_equal( ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound' )
|
assert_equal(ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound')
|
||||||
assert_equal( ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound' )
|
assert_equal(ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound')
|
||||||
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - outbound' )
|
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - outbound')
|
||||||
|
|
||||||
# create inbound article #4
|
# create inbound article #4
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -148,115 +148,119 @@ class TicketTest < ActiveSupport::TestCase
|
||||||
message_id: 'some@id',
|
message_id: 'some@id',
|
||||||
body: 'some message article_inbound4 😍😍😍',
|
body: 'some message article_inbound4 😍😍😍',
|
||||||
internal: false,
|
internal: false,
|
||||||
sender: Ticket::Article::Sender.where(name: 'Customer').first,
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
||||||
type: Ticket::Article::Type.where(name: 'email').first,
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert_equal( article_inbound4.body, 'some message article_inbound4 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound' )
|
assert_equal(article_inbound4.body, 'some message article_inbound4 😍😍😍'.utf8_to_3bytesutf8, 'article_inbound.body verify - inbound')
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.article_count, 6, 'ticket.article_count verify - inbound' )
|
assert_equal(ticket.article_count, 6, 'ticket.article_count verify - inbound')
|
||||||
assert_equal( ticket.last_contact.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact verify - inbound' )
|
assert_equal(ticket.last_contact.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact verify - inbound')
|
||||||
assert_equal( ticket.last_contact_customer.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
|
assert_equal(ticket.last_contact_customer.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
|
||||||
assert_equal( ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound' )
|
assert_equal(ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound')
|
||||||
assert_equal( ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound' )
|
assert_equal(ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound')
|
||||||
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - outbound' )
|
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - outbound')
|
||||||
|
|
||||||
ticket.state_id = Ticket::State.where(name: 'closed').first.id
|
ticket.state_id = Ticket::State.where(name: 'closed').first.id
|
||||||
ticket.save
|
ticket.save
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.article_count, 6, 'ticket.article_count verify - state update' )
|
assert_equal(ticket.article_count, 6, 'ticket.article_count verify - state update')
|
||||||
assert_equal( ticket.last_contact.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact verify - state update' )
|
assert_equal(ticket.last_contact.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact verify - state update')
|
||||||
assert_equal( ticket.last_contact_customer.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact_customer verify - state update' )
|
assert_equal(ticket.last_contact_customer.to_s, article_inbound3.created_at.to_s, 'ticket.last_contact_customer verify - state update')
|
||||||
assert_equal( ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - state update' )
|
assert_equal(ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - state update')
|
||||||
assert_equal( ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - state update' )
|
assert_equal(ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - state update')
|
||||||
assert( ticket.close_time, 'ticket.close_time verify - state update' )
|
assert(ticket.close_time, 'ticket.close_time verify - state update')
|
||||||
|
|
||||||
# set pending time
|
# set pending time
|
||||||
ticket.state_id = Ticket::State.where(name: 'pending reminder').first.id
|
ticket.state_id = Ticket::State.find_by(name: 'pending reminder').id
|
||||||
ticket.pending_time = Time.zone.parse('1977-10-27 22:00:00 +0000')
|
ticket.pending_time = Time.zone.parse('1977-10-27 22:00:00 +0000')
|
||||||
ticket.save
|
ticket.save
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.state.name, 'pending reminder', 'state verify' )
|
assert_equal(ticket.state.name, 'pending reminder', 'state verify')
|
||||||
assert_equal( ticket.pending_time, Time.zone.parse('1977-10-27 22:00:00 +0000'), 'pending_time verify' )
|
assert_equal(ticket.pending_time, Time.zone.parse('1977-10-27 22:00:00 +0000'), 'pending_time verify')
|
||||||
|
|
||||||
# reset pending state, should also reset pending time
|
# reset pending state, should also reset pending time
|
||||||
ticket.state_id = Ticket::State.where(name: 'closed').first.id
|
ticket.state_id = Ticket::State.find_by(name: 'closed').id
|
||||||
ticket.save
|
ticket.save
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( ticket.state.name, 'closed', 'state verify' )
|
assert_equal(ticket.state.name, 'closed', 'state verify')
|
||||||
assert_equal( ticket.pending_time, nil )
|
assert_equal(ticket.pending_time, nil )
|
||||||
|
|
||||||
delete = ticket.destroy
|
delete = ticket.destroy
|
||||||
assert( delete, 'ticket destroy' )
|
assert(delete, 'ticket destroy')
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'ticket latest change' do
|
test 'ticket latest change' do
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'latest change 1',
|
title: 'latest change 1',
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer_id: 2,
|
customer_id: 2,
|
||||||
state: Ticket::State.lookup( name: 'new' ),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
priority: Ticket::Priority.lookup( name: '2 normal' ),
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert_equal( Ticket.latest_change.to_s, ticket1.updated_at.to_s )
|
assert_equal(Ticket.latest_change.to_s, ticket1.updated_at.to_s)
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
ticket2 = Ticket.create(
|
ticket2 = Ticket.create(
|
||||||
title: 'latest change 2',
|
title: 'latest change 2',
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer_id: 2,
|
customer_id: 2,
|
||||||
state: Ticket::State.lookup( name: 'new' ),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
priority: Ticket::Priority.lookup( name: '2 normal' ),
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
assert_equal( Ticket.latest_change.to_s, ticket2.updated_at.to_s )
|
assert_equal(Ticket.latest_change.to_s, ticket2.updated_at.to_s)
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
ticket1.title = 'latest change 1 - 1'
|
ticket1.title = 'latest change 1 - 1'
|
||||||
ticket1.save
|
ticket1.save
|
||||||
assert_equal( Ticket.latest_change.to_s, ticket1.updated_at.to_s )
|
assert_equal(Ticket.latest_change.to_s, ticket1.updated_at.to_s)
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
ticket1.touch
|
ticket1.touch
|
||||||
assert_equal( Ticket.latest_change.to_s, ticket1.updated_at.to_s )
|
assert_equal(Ticket.latest_change.to_s, ticket1.updated_at.to_s)
|
||||||
|
|
||||||
ticket1.destroy
|
ticket1.destroy
|
||||||
assert_equal( Ticket.latest_change.to_s, ticket2.updated_at.to_s )
|
assert_equal(Ticket.latest_change.to_s, ticket2.updated_at.to_s)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'ticket process_pending' do
|
test 'ticket process_pending' do
|
||||||
|
|
||||||
|
# close all other pending close tickets first
|
||||||
|
Ticket.where('pending_time IS NOT NULL').each {|ticket|
|
||||||
|
ticket.state = Ticket::State.lookup(name: 'closed')
|
||||||
|
ticket.save!
|
||||||
|
}
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: 'pending close test',
|
title: 'pending close test',
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer_id: 2,
|
customer_id: 2,
|
||||||
state: Ticket::State.lookup( name: 'pending close' ),
|
state: Ticket::State.lookup(name: 'pending close'),
|
||||||
pending_time: Time.zone.now - 60,
|
pending_time: Time.zone.now - 60,
|
||||||
priority: Ticket::Priority.lookup( name: '2 normal' ),
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
lookup_ticket = Ticket.find_by( 'pending_time <= ?', Time.zone.now )
|
lookup_ticket = Ticket.find_by('pending_time <= ?', Time.zone.now)
|
||||||
|
assert_equal(lookup_ticket.id, ticket.id, 'ticket.pending_time verify')
|
||||||
assert_equal( lookup_ticket.id, ticket.id, 'ticket.pending_time verify' )
|
|
||||||
|
|
||||||
Ticket.process_pending
|
Ticket.process_pending
|
||||||
|
|
||||||
lookup_ticket = Ticket.find_by( 'pending_time <= ?', Time.zone.now )
|
lookup_ticket = Ticket.find_by('pending_time <= ?', Time.zone.now)
|
||||||
|
assert_nil(lookup_ticket, 'ticket.pending_time processed verify')
|
||||||
assert_nil( lookup_ticket, 'ticket.pending_time processed verify' )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue