Improved timings.
This commit is contained in:
parent
927cc759d3
commit
34c4b7bd1b
6 changed files with 101 additions and 101 deletions
|
@ -9,7 +9,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
user.save
|
user.save
|
||||||
|
|
||||||
test 'a cache' do
|
test 'a cache' do
|
||||||
Sessions::CacheIn.set('last_run_test', true, { expires_in: 2.seconds })
|
Sessions::CacheIn.set('last_run_test', true, { expires_in: 1.second })
|
||||||
result = Sessions::CacheIn.get('last_run_test')
|
result = Sessions::CacheIn.get('last_run_test')
|
||||||
assert_equal(true, result, 'check 1')
|
assert_equal(true, result, 'check 1')
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
assert_equal(false, result, 'check 1 - expired')
|
assert_equal(false, result, 'check 1 - expired')
|
||||||
|
|
||||||
# should be expired
|
# should be expired
|
||||||
sleep 3
|
sleep 2
|
||||||
result = Sessions::CacheIn.expired('last_run_test')
|
result = Sessions::CacheIn.expired('last_run_test')
|
||||||
assert_equal(true, result, 'check 1 - expired')
|
assert_equal(true, result, 'check 1 - expired')
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
assert_equal(false, result, 'check 1 - expired')
|
assert_equal(false, result, 'check 1 - expired')
|
||||||
|
|
||||||
# ignore expired
|
# ignore expired
|
||||||
sleep 3
|
sleep 2
|
||||||
result = Sessions::CacheIn.get('last_run_test', ignore_expire: true)
|
result = Sessions::CacheIn.get('last_run_test', ignore_expire: true)
|
||||||
assert_equal(true, result, 'check 1 - ignore_expire')
|
assert_equal(true, result, 'check 1 - ignore_expire')
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
user = User.lookup(id: 1)
|
user = User.lookup(id: 1)
|
||||||
collection_client1 = Sessions::Backend::Collections::Group.new(user, {}, false, '123-1', 3)
|
collection_client1 = Sessions::Backend::Collections::Group.new(user, {}, false, '123-1', 2)
|
||||||
collection_client2 = Sessions::Backend::Collections::Group.new(user, {}, false, '234-2', 3)
|
collection_client2 = Sessions::Backend::Collections::Group.new(user, {}, false, '234-2', 2)
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
|
@ -130,7 +130,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
# change collection
|
# change collection
|
||||||
group = Group.first
|
group = Group.first
|
||||||
group.touch
|
group.touch
|
||||||
sleep 4
|
sleep 3
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
|
@ -148,7 +148,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
group = Group.create(name: 'SomeGroup::' + rand(999_999).to_s, active: true)
|
group = Group.create(name: 'SomeGroup::' + rand(999_999).to_s, active: true)
|
||||||
sleep 4
|
sleep 3
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
|
@ -158,7 +158,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
assert_equal(result1, result2, 'check collections')
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# check again after create
|
# check again after create
|
||||||
sleep 4
|
sleep 3
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert(!result1, 'check collections - after create - recall')
|
assert(!result1, 'check collections - after create - recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
|
@ -167,7 +167,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
group.destroy
|
group.destroy
|
||||||
sleep 4
|
sleep 3
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
|
@ -177,7 +177,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
assert_equal(result1, result2, 'check collections')
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# check again after destroy
|
# check again after destroy
|
||||||
sleep 4
|
sleep 3
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert(!result1, 'check collections - after destroy - recall')
|
assert(!result1, 'check collections - after destroy - recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
|
@ -193,7 +193,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
#puts "RSS1: #{result1.inspect}"
|
#puts "RSS1: #{result1.inspect}"
|
||||||
assert(!result1.empty?, 'check rss')
|
assert(!result1.empty?, 'check rss')
|
||||||
sleep 1
|
sleep 0.5
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
|
@ -221,7 +221,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
agent1.roles = roles
|
agent1.roles = roles
|
||||||
assert(agent1.save, 'create/update agent1')
|
assert(agent1.save, 'create/update agent1')
|
||||||
|
|
||||||
as_client1 = Sessions::Backend::ActivityStream.new(agent1, {}, false, '123-1', 3)
|
as_client1 = Sessions::Backend::ActivityStream.new(agent1, {}, false, '123-1', 2)
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = as_client1.push
|
result1 = as_client1.push
|
||||||
|
@ -233,14 +233,14 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
assert(!result1, 'check as agent1 - recall')
|
assert(!result1, 'check as agent1 - recall')
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
sleep 4
|
sleep 3
|
||||||
result1 = as_client1.push
|
result1 = as_client1.push
|
||||||
assert(!result1, 'check as agent1 - recall 2')
|
assert(!result1, 'check as agent1 - recall 2')
|
||||||
|
|
||||||
agent1.update_attribute(:email, 'activity-stream-agent11@example.com')
|
agent1.update_attribute(:email, 'activity-stream-agent11@example.com')
|
||||||
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
||||||
|
|
||||||
sleep 4
|
sleep 3
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = as_client1.push
|
result1 = as_client1.push
|
||||||
|
@ -251,7 +251,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
user = User.lookup(id: 1)
|
user = User.lookup(id: 1)
|
||||||
ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, {}, false, '123-1', 3)
|
ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, {}, false, '123-1', 2)
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = ticket_create_client1.push
|
result1 = ticket_create_client1.push
|
||||||
|
@ -269,7 +269,7 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
Group.create(name: 'SomeTicketCreateGroup::' + rand(999_999).to_s, active: true)
|
Group.create(name: 'SomeTicketCreateGroup::' + rand(999_999).to_s, active: true)
|
||||||
|
|
||||||
sleep 4
|
sleep 3
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = ticket_create_client1.push
|
result1 = ticket_create_client1.push
|
||||||
|
|
|
@ -28,7 +28,7 @@ class SessionBasicTicketTest < ActiveSupport::TestCase
|
||||||
Ticket.create(title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
Ticket.create(title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
||||||
|
|
||||||
user = User.lookup(id: agent1.id)
|
user = User.lookup(id: agent1.id)
|
||||||
client1 = Sessions::Backend::TicketOverviewList.new(user, {}, false, '123-1', 5)
|
client1 = Sessions::Backend::TicketOverviewList.new(user, {}, false, '123-1', 2)
|
||||||
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert(result1, 'check ticket_overview_List')
|
assert(result1, 'check ticket_overview_List')
|
||||||
|
@ -38,17 +38,17 @@ class SessionBasicTicketTest < ActiveSupport::TestCase
|
||||||
assert(!result1, 'check ticket_overview_index - recall')
|
assert(!result1, 'check ticket_overview_index - recall')
|
||||||
|
|
||||||
# next check should be empty / no changes
|
# next check should be empty / no changes
|
||||||
sleep 6
|
sleep 3
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert(!result1, 'check ticket_overview_index - recall 2')
|
assert(!result1, 'check ticket_overview_index - recall 2')
|
||||||
|
|
||||||
# create ticket
|
# create ticket
|
||||||
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
||||||
sleep 6
|
sleep 3
|
||||||
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert(result1, 'check ticket_overview_index - recall 3')
|
assert(result1, 'check ticket_overview_index - recall 3')
|
||||||
sleep 6
|
sleep 3
|
||||||
|
|
||||||
# chnage overview
|
# chnage overview
|
||||||
overviews = Ticket::Overviews.all(
|
overviews = Ticket::Overviews.all(
|
||||||
|
|
|
@ -56,9 +56,9 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
customer1.roles = roles
|
customer1.roles = roles
|
||||||
customer1.save
|
customer1.save
|
||||||
|
|
||||||
collection_client1 = Sessions::Backend::Collections.new(agent1, {}, nil, 'aaa-1', 3)
|
collection_client1 = Sessions::Backend::Collections.new(agent1, {}, nil, 'aaa-1', 2)
|
||||||
collection_client2 = Sessions::Backend::Collections.new(agent2, {}, nil, 'bbb-2', 3)
|
collection_client2 = Sessions::Backend::Collections.new(agent2, {}, nil, 'bbb-2', 2)
|
||||||
collection_client3 = Sessions::Backend::Collections.new(customer1, {}, nil, 'ccc-2', 3)
|
collection_client2 = Sessions::Backend::Collections.new(customer1, {}, nil, 'ccc-2', 2)
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
|
@ -95,7 +95,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
# change collection
|
# change collection
|
||||||
group = Group.first
|
group = Group.first
|
||||||
group.touch
|
group.touch
|
||||||
sleep 4
|
sleep 3
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
|
@ -110,7 +110,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
assert(check_if_collection_exists(result3, :Group), 'check collections - after touch')
|
assert(check_if_collection_exists(result3, :Group), 'check collections - after touch')
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
sleep 1
|
sleep 0.5
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert(result1.empty?, 'check collections - recall')
|
assert(result1.empty?, 'check collections - recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
|
|
|
@ -64,17 +64,17 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# check if session still exists after idle cleanup
|
# check if session still exists after idle cleanup
|
||||||
sleep 1
|
sleep 1
|
||||||
Sessions.destory_idle_sessions(5)
|
Sessions.destory_idle_sessions(3)
|
||||||
assert(Sessions.session_exists?(client_id1), 'check if session exists after 1 sec')
|
assert(Sessions.session_exists?(client_id1), 'check if session exists after 1 sec')
|
||||||
assert(Sessions.session_exists?(client_id2), 'check if session exists after 1 sec')
|
assert(Sessions.session_exists?(client_id2), 'check if session exists after 1 sec')
|
||||||
assert(Sessions.session_exists?(client_id3), 'check if session exists after 1 sec')
|
assert(Sessions.session_exists?(client_id3), 'check if session exists after 1 sec')
|
||||||
|
|
||||||
# check if session still exists after idle cleanup with touched sessions
|
# check if session still exists after idle cleanup with touched sessions
|
||||||
sleep 6
|
sleep 4
|
||||||
Sessions.touch(client_id1)
|
Sessions.touch(client_id1)
|
||||||
Sessions.touch(client_id2)
|
Sessions.touch(client_id2)
|
||||||
Sessions.touch(client_id3)
|
Sessions.touch(client_id3)
|
||||||
Sessions.destory_idle_sessions(5)
|
Sessions.destory_idle_sessions(3)
|
||||||
assert(Sessions.session_exists?(client_id1), 'check if session exists after touch')
|
assert(Sessions.session_exists?(client_id1), 'check if session exists after touch')
|
||||||
assert(Sessions.session_exists?(client_id2), 'check if session exists after touch')
|
assert(Sessions.session_exists?(client_id2), 'check if session exists after touch')
|
||||||
assert(Sessions.session_exists?(client_id3), 'check if session exists after touch')
|
assert(Sessions.session_exists?(client_id3), 'check if session exists after touch')
|
||||||
|
@ -145,7 +145,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
jobs = Thread.new {
|
jobs = Thread.new {
|
||||||
Sessions.jobs
|
Sessions.jobs
|
||||||
}
|
}
|
||||||
sleep 5
|
sleep 3
|
||||||
#jobs.join
|
#jobs.join
|
||||||
|
|
||||||
# check client threads
|
# check client threads
|
||||||
|
@ -154,15 +154,15 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
assert(Sessions.thread_client_exists?(client_id3), 'check if client is running')
|
assert(Sessions.thread_client_exists?(client_id3), 'check if client is running')
|
||||||
|
|
||||||
# check if session still exists after idle cleanup
|
# check if session still exists after idle cleanup
|
||||||
sleep 8
|
sleep 4
|
||||||
client_ids = Sessions.destory_idle_sessions(5)
|
client_ids = Sessions.destory_idle_sessions(3)
|
||||||
|
|
||||||
# check client sessions
|
# check client sessions
|
||||||
assert(!Sessions.session_exists?(client_id1), 'check if session is removed')
|
assert(!Sessions.session_exists?(client_id1), 'check if session is removed')
|
||||||
assert(!Sessions.session_exists?(client_id2), 'check if session is removed')
|
assert(!Sessions.session_exists?(client_id2), 'check if session is removed')
|
||||||
assert(!Sessions.session_exists?(client_id3), 'check if session is removed')
|
assert(!Sessions.session_exists?(client_id3), 'check if session is removed')
|
||||||
|
|
||||||
sleep 10
|
sleep 6
|
||||||
|
|
||||||
# check client threads
|
# check client threads
|
||||||
assert(!Sessions.thread_client_exists?(client_id1), 'check if client is running')
|
assert(!Sessions.thread_client_exists?(client_id1), 'check if client is running')
|
||||||
|
@ -235,7 +235,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
assert(Sessions.session_exists?(client_id1_0), 'check if session exists')
|
assert(Sessions.session_exists?(client_id1_0), 'check if session exists')
|
||||||
assert(Sessions.session_exists?(client_id1_1), 'check if session exists')
|
assert(Sessions.session_exists?(client_id1_1), 'check if session exists')
|
||||||
assert(Sessions.session_exists?(client_id2), 'check if session exists')
|
assert(Sessions.session_exists?(client_id2), 'check if session exists')
|
||||||
sleep 11
|
sleep 8
|
||||||
|
|
||||||
# check collections
|
# check collections
|
||||||
collections = {
|
collections = {
|
||||||
|
@ -254,7 +254,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
check_if_collection_reset_message_exists(client_id1_1, collections, 'init2')
|
check_if_collection_reset_message_exists(client_id1_1, collections, 'init2')
|
||||||
check_if_collection_reset_message_exists(client_id2, collections, 'init2')
|
check_if_collection_reset_message_exists(client_id2, collections, 'init2')
|
||||||
|
|
||||||
sleep 11
|
sleep 8
|
||||||
|
|
||||||
collections = {
|
collections = {
|
||||||
'Group' => nil,
|
'Group' => nil,
|
||||||
|
@ -268,7 +268,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
group = Group.first
|
group = Group.first
|
||||||
group.touch
|
group.touch
|
||||||
|
|
||||||
sleep 11
|
sleep 8
|
||||||
|
|
||||||
# check collections
|
# check collections
|
||||||
collections = {
|
collections = {
|
||||||
|
@ -280,8 +280,8 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
check_if_collection_reset_message_exists(client_id2, collections, 'update')
|
check_if_collection_reset_message_exists(client_id2, collections, 'update')
|
||||||
|
|
||||||
# check if session still exists after idle cleanup
|
# check if session still exists after idle cleanup
|
||||||
sleep 6
|
sleep 4
|
||||||
client_ids = Sessions.destory_idle_sessions(5)
|
client_ids = Sessions.destory_idle_sessions(3)
|
||||||
|
|
||||||
# check client sessions
|
# check client sessions
|
||||||
assert(!Sessions.session_exists?(client_id1_0), 'check if session is removed')
|
assert(!Sessions.session_exists?(client_id1_0), 'check if session is removed')
|
||||||
|
|
|
@ -57,51 +57,51 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: "some title1\n äöüß",
|
title: "some title1\n äöüß",
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer_id: customer1.id,
|
customer_id: customer1.id,
|
||||||
owner_id: agent1.id,
|
owner_id: agent1.id,
|
||||||
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.customer.id, customer1.id )
|
assert_equal(ticket.customer.id, customer1.id )
|
||||||
assert_equal( ticket.organization.id, organization1.id )
|
assert_equal(ticket.organization.id, organization1.id )
|
||||||
|
|
||||||
# check if customer and organization has been touched
|
# check if customer and organization has been touched
|
||||||
customer1 = User.find(customer1.id)
|
customer1 = User.find(customer1.id)
|
||||||
if customer1.updated_at > 4.seconds.ago
|
if customer1.updated_at > 3.seconds.ago
|
||||||
assert( true, 'customer1.updated_at has been updated' )
|
assert(true, 'customer1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'customer1.updated_at has not been updated' )
|
assert(false, 'customer1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 4.seconds.ago
|
if organization1.updated_at > 3.seconds.ago
|
||||||
assert( true, 'organization1.updated_at has been updated' )
|
assert(true, 'organization1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'organization1.updated_at has not been updated' )
|
assert(false, 'organization1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep 6
|
sleep 4
|
||||||
|
|
||||||
delete = ticket.destroy
|
delete = ticket.destroy
|
||||||
assert( delete, 'ticket destroy' )
|
assert(delete, 'ticket destroy')
|
||||||
|
|
||||||
# check if customer and organization has been touched
|
# check if customer and organization has been touched
|
||||||
customer1 = User.find(customer1.id)
|
customer1 = User.find(customer1.id)
|
||||||
if customer1.updated_at > 4.seconds.ago
|
if customer1.updated_at > 3.seconds.ago
|
||||||
assert( true, 'customer1.updated_at has been updated' )
|
assert(true, 'customer1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'customer1.updated_at has not been updated' )
|
assert(false, 'customer1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 4.seconds.ago
|
if organization1.updated_at > 3.seconds.ago
|
||||||
assert( true, 'organization1.updated_at has been updated' )
|
assert(true, 'organization1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'organization1.updated_at has not been updated' )
|
assert(false, 'organization1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -110,51 +110,51 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
sleep 6
|
sleep 6
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: "some title2\n äöüß",
|
title: "some title2\n äöüß",
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer_id: customer2.id,
|
customer_id: customer2.id,
|
||||||
owner_id: agent1.id,
|
owner_id: agent1.id,
|
||||||
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.customer.id, customer2.id )
|
assert_equal(ticket.customer.id, customer2.id)
|
||||||
assert_equal( ticket.organization, nil )
|
assert_equal(ticket.organization, nil)
|
||||||
|
|
||||||
# check if customer and organization has been touched
|
# check if customer and organization has been touched
|
||||||
customer2 = User.find(customer2.id)
|
customer2 = User.find(customer2.id)
|
||||||
if customer2.updated_at > 4.seconds.ago
|
if customer2.updated_at > 3.seconds.ago
|
||||||
assert( true, 'customer2.updated_at has been updated' )
|
assert(true, 'customer2.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'customer2.updated_at has not been updated' )
|
assert(false, 'customer2.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 4.seconds.ago
|
if organization1.updated_at > 3.seconds.ago
|
||||||
assert( false, 'organization1.updated_at has been updated' )
|
assert(false, 'organization1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( true, 'organization1.updated_at has not been updated' )
|
assert(true, 'organization1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep 6
|
sleep 4
|
||||||
|
|
||||||
delete = ticket.destroy
|
delete = ticket.destroy
|
||||||
assert( delete, 'ticket destroy' )
|
assert(delete, 'ticket destroy')
|
||||||
|
|
||||||
# check if customer and organization has been touched
|
# check if customer and organization has been touched
|
||||||
customer2 = User.find(customer2.id)
|
customer2 = User.find(customer2.id)
|
||||||
if customer2.updated_at > 4.seconds.ago
|
if customer2.updated_at > 3.seconds.ago
|
||||||
assert( true, 'customer2.updated_at has been updated' )
|
assert(true, 'customer2.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'customer2.updated_at has not been updated' )
|
assert(false, 'customer2.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 4.seconds.ago
|
if organization1.updated_at > 3.seconds.ago
|
||||||
assert( false, 'organization1.updated_at has been updated' )
|
assert(false, 'organization1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( true, 'organization1.updated_at has not been updated' )
|
assert(true, 'organization1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,8 +4,8 @@ require 'test_helper'
|
||||||
class UserRefObjectTouchTest < ActiveSupport::TestCase
|
class UserRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create base
|
# create base
|
||||||
groups = Group.where( name: 'Users' )
|
groups = Group.where(name: 'Users')
|
||||||
roles = Role.where( name: 'Agent' )
|
roles = Role.where(name: 'Agent')
|
||||||
agent1 = User.create_or_update(
|
agent1 = User.create_or_update(
|
||||||
login: 'user-ref-object-update-agent1@example.com',
|
login: 'user-ref-object-update-agent1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
|
@ -19,7 +19,7 @@ class UserRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
roles = Role.where( name: 'Customer' )
|
roles = Role.where(name: 'Customer')
|
||||||
organization1 = Organization.create_if_not_exists(
|
organization1 = Organization.create_if_not_exists(
|
||||||
name: 'Ref Object Update Org',
|
name: 'Ref Object Update Org',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
|
@ -57,59 +57,59 @@ class UserRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: "some title1\n äöüß",
|
title: "some title1\n äöüß",
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer_id: customer1.id,
|
customer_id: customer1.id,
|
||||||
owner_id: agent1.id,
|
owner_id: agent1.id,
|
||||||
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.customer.id, customer1.id )
|
assert_equal(ticket.customer.id, customer1.id)
|
||||||
assert_equal( ticket.organization.id, organization1.id )
|
assert_equal(ticket.organization.id, organization1.id)
|
||||||
|
|
||||||
sleep 6
|
sleep 4
|
||||||
|
|
||||||
customer1.firstname = 'firstname customer1'
|
customer1.firstname = 'firstname customer1'
|
||||||
customer1.save
|
customer1.save
|
||||||
|
|
||||||
# check if organization has been touched
|
# check if organization has been touched
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 4.seconds.ago
|
if organization1.updated_at > 3.seconds.ago
|
||||||
assert( true, 'organization1.updated_at has been updated' )
|
assert(true, 'organization1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'organization1.updated_at has not been updated' )
|
assert(false, 'organization1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep 6
|
sleep 4
|
||||||
|
|
||||||
ticket.customer_id = customer2.id
|
ticket.customer_id = customer2.id
|
||||||
ticket.save
|
ticket.save
|
||||||
|
|
||||||
# check if customer1, customer2 and organization has been touched
|
# check if customer1, customer2 and organization has been touched
|
||||||
customer1 = User.find(customer1.id)
|
customer1 = User.find(customer1.id)
|
||||||
if customer1.updated_at > 4.seconds.ago
|
if customer1.updated_at > 3.seconds.ago
|
||||||
assert( true, 'customer1.updated_at has been updated' )
|
assert(true, 'customer1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'customer1.updated_at has not been updated' )
|
assert(false, 'customer1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
customer2 = User.find(customer2.id)
|
customer2 = User.find(customer2.id)
|
||||||
if customer2.updated_at > 4.seconds.ago
|
if customer2.updated_at > 3.seconds.ago
|
||||||
assert( true, 'customer2.updated_at has been updated' )
|
assert(true, 'customer2.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'customer2.updated_at has not been updated' )
|
assert(false, 'customer2.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 4.seconds.ago
|
if organization1.updated_at > 3.seconds.ago
|
||||||
assert( true, 'organization1.updated_at has been updated' )
|
assert(true, 'organization1.updated_at has been updated')
|
||||||
else
|
else
|
||||||
assert( false, 'organization1.updated_at has not been updated' )
|
assert(false, 'organization1.updated_at has not been updated')
|
||||||
end
|
end
|
||||||
|
|
||||||
delete = ticket.destroy
|
delete = ticket.destroy
|
||||||
assert( delete, 'ticket destroy' )
|
assert(delete, 'ticket destroy')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue