From 4de56f007f43a92baed0d13f34ba57a6ef43ef2f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 10 May 2015 17:43:38 +0200 Subject: [PATCH] Added logging to find race condition. --- test/unit/session_basic_ticket_test.rb | 54 ++++++++++++++++---------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/test/unit/session_basic_ticket_test.rb b/test/unit/session_basic_ticket_test.rb index 5bbf0ceef..6836cf2a2 100644 --- a/test/unit/session_basic_ticket_test.rb +++ b/test/unit/session_basic_ticket_test.rb @@ -3,33 +3,30 @@ require 'test_helper' class SessionBasicTicketTest < ActiveSupport::TestCase - UserInfo.current_user_id = 1 - - # create users - roles = Role.where( name: [ 'Agent' ] ) - groups = Group.all - - agent1 = User.create_or_update( - login: 'session-basic-ticket-agent-1', - firstname: 'Session', - lastname: 'session basic ' + rand(99_999).to_s, - email: 'session-basic-ticket-agent-1@example.com', - password: 'agentpw', - active: true, - roles: roles, - groups: groups, - ) - - # create ticket - ticket = Ticket.create( title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 ) - sleep 6 test 'b ticket_overview_index' do UserInfo.current_user_id = 1 + # create users + roles = Role.where( name: [ 'Agent' ] ) + groups = Group.all + + agent1 = User.create_or_update( + login: 'session-basic-ticket-agent-1', + firstname: 'Session', + lastname: 'session basic ' + rand(99_999).to_s, + email: 'session-basic-ticket-agent-1@example.com', + password: 'agentpw', + active: true, + roles: roles, + groups: groups, + ) + agent1.roles = roles assert( agent1.save, 'create/update agent1' ) + Ticket.create( title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 ) + user = User.lookup( id: agent1.id ) client1 = Sessions::Backend::TicketOverviewIndex.new(user, false, '123-1', 5) @@ -61,9 +58,26 @@ class SessionBasicTicketTest < ActiveSupport::TestCase test 'b ticket_overview_list' do UserInfo.current_user_id = 1 + # create users + roles = Role.where( name: [ 'Agent' ] ) + groups = Group.all + + agent1 = User.create_or_update( + login: 'session-basic-ticket-agent-1', + firstname: 'Session', + lastname: 'session basic ' + rand(99_999).to_s, + email: 'session-basic-ticket-agent-1@example.com', + password: 'agentpw', + active: true, + roles: roles, + groups: groups, + ) + agent1.roles = roles assert( agent1.save, 'create/update agent1' ) + Ticket.create( title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 ) + user = User.lookup( id: agent1.id ) client1 = Sessions::Backend::TicketOverviewList.new(user, false, '123-1', 5)