Moved to init prepare/setup method for tests.
This commit is contained in:
parent
1e2f1da0aa
commit
3c523b4f7d
12 changed files with 793 additions and 725 deletions
|
@ -2,27 +2,32 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ActivityStreamTest < ActiveSupport::TestCase
|
class ActivityStreamTest < ActiveSupport::TestCase
|
||||||
role = Role.lookup(name: 'Admin')
|
admin_user = nil
|
||||||
group = Group.lookup(name: 'Users')
|
current_user = nil
|
||||||
admin_user = User.create_or_update(
|
activity_record_delay = nil
|
||||||
login: 'admin',
|
test 'aaa - setup' do
|
||||||
firstname: 'Bob',
|
role = Role.lookup(name: 'Admin')
|
||||||
lastname: 'Smith',
|
group = Group.lookup(name: 'Users')
|
||||||
email: 'bob@example.com',
|
admin_user = User.create_or_update(
|
||||||
password: 'some_pass',
|
login: 'admin',
|
||||||
active: true,
|
firstname: 'Bob',
|
||||||
role_ids: [role.id],
|
lastname: 'Smith',
|
||||||
group_ids: [group.id],
|
email: 'bob@example.com',
|
||||||
updated_by_id: 1,
|
password: 'some_pass',
|
||||||
created_by_id: 1
|
active: true,
|
||||||
)
|
role_ids: [role.id],
|
||||||
current_user = User.lookup(email: 'nicole.braun@zammad.org')
|
group_ids: [group.id],
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1
|
||||||
|
)
|
||||||
|
current_user = User.lookup(email: 'nicole.braun@zammad.org')
|
||||||
|
|
||||||
activity_record_delay = if ENV['ZAMMAD_ACTIVITY_RECORD_DELAY']
|
activity_record_delay = if ENV['ZAMMAD_ACTIVITY_RECORD_DELAY']
|
||||||
ENV['ZAMMAD_ACTIVITY_RECORD_DELAY'].to_i.seconds
|
ENV['ZAMMAD_ACTIVITY_RECORD_DELAY'].to_i.seconds
|
||||||
else
|
else
|
||||||
90.seconds
|
90.seconds
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test 'ticket+user' do
|
test 'ticket+user' do
|
||||||
tests = [
|
tests = [
|
||||||
|
|
|
@ -155,8 +155,8 @@ class AutoWizardTest < ActiveSupport::TestCase
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
channel_id: 1,
|
channel_id: 1,
|
||||||
realname: 'some realname',
|
realname: 'Zammad',
|
||||||
email: 'helpdesk@example.com',
|
email: 'zammad@localhost',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,36 +2,40 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ChatTest < ActiveSupport::TestCase
|
class ChatTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
|
agent2 = nil
|
||||||
|
test 'aaa - setup' do
|
||||||
|
|
||||||
# create base
|
# create base
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
roles = Role.where( name: %w(Agent Chat) )
|
roles = Role.where( name: %w(Agent Chat) )
|
||||||
agent1 = User.create_or_update(
|
agent1 = User.create_or_update(
|
||||||
login: 'ticket-chat-agent1@example.com',
|
login: 'ticket-chat-agent1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'ticket-chat-agent1@example.com',
|
email: 'ticket-chat-agent1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
agent2 = User.create_or_update(
|
agent2 = User.create_or_update(
|
||||||
login: 'ticket-chat-agent2@example.com',
|
login: 'ticket-chat-agent2@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent2',
|
lastname: 'Agent2',
|
||||||
email: 'ticket-chat-agent2@example.com',
|
email: 'ticket-chat-agent2@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_at: '2015-02-05 16:38:00',
|
updated_at: '2015-02-05 16:38:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
test 'default test' do
|
test 'default test' do
|
||||||
|
|
||||||
|
|
|
@ -2,33 +2,43 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class OnlineNotificationTest < ActiveSupport::TestCase
|
class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
role = Role.lookup(name: 'Agent')
|
group = nil
|
||||||
group = Group.lookup(name: 'Users')
|
agent_user1 = nil
|
||||||
agent_user1 = User.create_or_update(
|
agent_user2 = nil
|
||||||
login: 'agent_online_notify1',
|
customer_user = nil
|
||||||
firstname: 'Bob',
|
test 'aaa - setup' do
|
||||||
lastname: 'Smith',
|
role = Role.lookup(name: 'Agent')
|
||||||
email: 'agent_online_notify1@example.com',
|
group = Group.create_or_update(
|
||||||
password: 'some_pass',
|
name: 'OnlineNotificationTest',
|
||||||
active: true,
|
updated_by_id: 1,
|
||||||
role_ids: [role.id],
|
created_by_id: 1
|
||||||
group_ids: [group.id],
|
)
|
||||||
updated_by_id: 1,
|
agent_user1 = User.create_or_update(
|
||||||
created_by_id: 1
|
login: 'agent_online_notify1',
|
||||||
)
|
firstname: 'Bob',
|
||||||
agent_user2 = User.create_or_update(
|
lastname: 'Smith',
|
||||||
login: 'agent_online_notify2',
|
email: 'agent_online_notify1@example.com',
|
||||||
firstname: 'Bob',
|
password: 'some_pass',
|
||||||
lastname: 'Smith',
|
active: true,
|
||||||
email: 'agent_online_notify2@example.com',
|
role_ids: [role.id],
|
||||||
password: 'some_pass',
|
group_ids: [group.id],
|
||||||
active: true,
|
updated_by_id: 1,
|
||||||
role_ids: [role.id],
|
created_by_id: 1
|
||||||
group_ids: [group.id],
|
)
|
||||||
updated_by_id: 1,
|
agent_user2 = User.create_or_update(
|
||||||
created_by_id: 1
|
login: 'agent_online_notify2',
|
||||||
)
|
firstname: 'Bob',
|
||||||
customer_user = User.lookup(email: 'nicole.braun@zammad.org')
|
lastname: 'Smith',
|
||||||
|
email: 'agent_online_notify2@example.com',
|
||||||
|
password: 'some_pass',
|
||||||
|
active: true,
|
||||||
|
role_ids: [role.id],
|
||||||
|
group_ids: [group.id],
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1
|
||||||
|
)
|
||||||
|
customer_user = User.lookup(email: 'nicole.braun@zammad.org')
|
||||||
|
end
|
||||||
|
|
||||||
test 'ticket notification' do
|
test 'ticket notification' do
|
||||||
|
|
||||||
|
@ -36,7 +46,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# case #1
|
# case #1
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
group_id: Group.lookup(name: 'Users').id,
|
group: group,
|
||||||
customer_id: customer_user.id,
|
customer_id: customer_user.id,
|
||||||
owner_id: User.lookup(login: '-').id,
|
owner_id: User.lookup(login: '-').id,
|
||||||
title: 'Unit Test 1 (äöüß)!',
|
title: 'Unit Test 1 (äöüß)!',
|
||||||
|
@ -91,7 +101,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# case #2
|
# case #2
|
||||||
ticket2 = Ticket.create(
|
ticket2 = Ticket.create(
|
||||||
group_id: Group.lookup(name: 'Users').id,
|
group: group,
|
||||||
customer_id: customer_user.id,
|
customer_id: customer_user.id,
|
||||||
owner_id: agent_user1.id,
|
owner_id: agent_user1.id,
|
||||||
title: 'Unit Test 1 (äöüß)!',
|
title: 'Unit Test 1 (äöüß)!',
|
||||||
|
@ -146,7 +156,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# case #3
|
# case #3
|
||||||
ticket3 = Ticket.create(
|
ticket3 = Ticket.create(
|
||||||
group_id: Group.lookup(name: 'Users').id,
|
group: group,
|
||||||
customer_id: customer_user.id,
|
customer_id: customer_user.id,
|
||||||
owner_id: User.lookup(login: '-').id,
|
owner_id: User.lookup(login: '-').id,
|
||||||
title: 'Unit Test 2 (äöüß)!',
|
title: 'Unit Test 2 (äöüß)!',
|
||||||
|
@ -226,7 +236,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# case #4
|
# case #4
|
||||||
ticket4 = Ticket.create(
|
ticket4 = Ticket.create(
|
||||||
group_id: Group.lookup(name: 'Users').id,
|
group: group,
|
||||||
customer_id: customer_user.id,
|
customer_id: customer_user.id,
|
||||||
owner_id: agent_user1.id,
|
owner_id: agent_user1.id,
|
||||||
title: 'Unit Test 3 (äöüß)!',
|
title: 'Unit Test 3 (äöüß)!',
|
||||||
|
@ -280,7 +290,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# case #5
|
# case #5
|
||||||
ticket5 = Ticket.create(
|
ticket5 = Ticket.create(
|
||||||
group_id: Group.lookup(name: 'Users').id,
|
group: group,
|
||||||
customer_id: customer_user.id,
|
customer_id: customer_user.id,
|
||||||
owner_id: User.lookup(login: '-').id,
|
owner_id: User.lookup(login: '-').id,
|
||||||
title: 'Unit Test 4 (äöüß)!',
|
title: 'Unit Test 4 (äöüß)!',
|
||||||
|
@ -364,7 +374,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
test 'ticket notification item check' do
|
test 'ticket notification item check' do
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some title',
|
title: 'some title',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: group,
|
||||||
customer_id: customer_user.id,
|
customer_id: customer_user.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'),
|
||||||
|
|
|
@ -2,78 +2,84 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class OrganizationRefObjectTouchTest < ActiveSupport::TestCase
|
class OrganizationRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
|
organization1 = nil
|
||||||
|
customer1 = nil
|
||||||
|
customer2 = nil
|
||||||
|
test 'aaa - setup' do
|
||||||
|
|
||||||
# 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: 'organization-ref-object-update-agent1@example.com',
|
login: 'organization-ref-object-update-agent1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'organization-ref-object-update-agent1@example.com',
|
email: 'organization-ref-object-update-agent1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
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 1',
|
name: 'Ref Object Update Org 1',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
organization2 = Organization.create_if_not_exists(
|
organization2 = Organization.create_if_not_exists(
|
||||||
name: 'Ref Object Update Org 2',
|
name: 'Ref Object Update Org 2',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer1 = User.create_or_update(
|
customer1 = User.create_or_update(
|
||||||
login: 'organization-ref-object-update-customer1@example.com',
|
login: 'organization-ref-object-update-customer1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'organization-ref-object-update-customer1@example.com',
|
email: 'organization-ref-object-update-customer1@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization1.id,
|
organization_id: organization1.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer2 = User.create_or_update(
|
customer2 = User.create_or_update(
|
||||||
login: 'organization-ref-object-update-customer2@example.com',
|
login: 'organization-ref-object-update-customer2@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent2',
|
lastname: 'Agent2',
|
||||||
email: 'organization-ref-object-update-customer2@example.com',
|
email: 'organization-ref-object-update-customer2@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization2.id,
|
organization_id: organization2.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
test 'a - check if ticket and customer has been updated' do
|
test 'b - check if ticket and customer has been updated' do
|
||||||
|
|
||||||
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 4
|
sleep 4
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class SessionBasicTest < ActiveSupport::TestCase
|
class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
test 'aaa - setup' do
|
||||||
|
user = User.lookup(id: 1)
|
||||||
|
roles = Role.where(name: %w(Agent Admin))
|
||||||
|
user.roles = roles
|
||||||
|
user.save
|
||||||
|
end
|
||||||
|
|
||||||
user = User.lookup(id: 1)
|
test 'b cache' do
|
||||||
roles = Role.where(name: %w(Agent Admin))
|
|
||||||
user.roles = roles
|
|
||||||
user.save
|
|
||||||
|
|
||||||
test 'a cache' do
|
|
||||||
Sessions::CacheIn.set('last_run_test', true, { expires_in: 1.second })
|
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')
|
||||||
|
|
|
@ -2,59 +2,64 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TicketCustomerOrganizationUpdateTest < ActiveSupport::TestCase
|
class TicketCustomerOrganizationUpdateTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
|
organization1 = nil
|
||||||
|
customer1 = nil
|
||||||
|
test 'aaa - setup' do
|
||||||
|
|
||||||
# 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: 'ticket-customer-organization-update-agent1@example.com',
|
login: 'ticket-customer-organization-update-agent1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'ticket-customer-organization-update-agent1@example.com',
|
email: 'ticket-customer-organization-update-agent1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
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: 'Customer Organization Update',
|
name: 'Customer Organization Update',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer1 = User.create_or_update(
|
customer1 = User.create_or_update(
|
||||||
login: 'ticket-customer-organization-update-customer1@example.com',
|
login: 'ticket-customer-organization-update-customer1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
email: 'ticket-customer-organization-update-customer1@example.com',
|
email: 'ticket-customer-organization-update-customer1@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization1.id,
|
organization_id: organization1.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
test 'create ticket, update customers organization later' do
|
test 'create ticket, update customers organization later' do
|
||||||
|
|
||||||
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( customer1.id, ticket.customer.id )
|
assert_equal(customer1.id, ticket.customer.id)
|
||||||
assert_equal( organization1.id, ticket.organization.id )
|
assert_equal(organization1.id, ticket.organization.id)
|
||||||
|
|
||||||
# update customer organization
|
# update customer organization
|
||||||
customer1.organization_id = nil
|
customer1.organization_id = nil
|
||||||
|
@ -62,7 +67,7 @@ class TicketCustomerOrganizationUpdateTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# verify ticket
|
# verify ticket
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( nil, ticket.organization_id )
|
assert_equal(nil, ticket.organization_id)
|
||||||
|
|
||||||
# update customer organization
|
# update customer organization
|
||||||
customer1.organization_id = organization1.id
|
customer1.organization_id = organization1.id
|
||||||
|
@ -70,7 +75,7 @@ class TicketCustomerOrganizationUpdateTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# verify ticket
|
# verify ticket
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
assert_equal( organization1.id, ticket.organization_id )
|
assert_equal(organization1.id, ticket.organization_id)
|
||||||
|
|
||||||
ticket.destroy
|
ticket.destroy
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,107 +2,116 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TicketNotificationTest < ActiveSupport::TestCase
|
class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
Trigger.create_or_update(
|
agent2 = nil
|
||||||
name: 'auto reply - new ticket',
|
customer = nil
|
||||||
condition: {
|
test 'aaa - setup' do
|
||||||
'ticket.action' => {
|
Trigger.create_or_update(
|
||||||
'operator' => 'is',
|
name: 'auto reply - new ticket',
|
||||||
'value' => 'create',
|
condition: {
|
||||||
|
'ticket.action' => {
|
||||||
|
'operator' => 'is',
|
||||||
|
'value' => 'create',
|
||||||
|
},
|
||||||
|
'ticket.state_id' => {
|
||||||
|
'operator' => 'is not',
|
||||||
|
'value' => Ticket::State.lookup(name: 'closed').id,
|
||||||
|
},
|
||||||
|
'article.type_id' => {
|
||||||
|
'operator' => 'is',
|
||||||
|
'value' => [
|
||||||
|
Ticket::Article::Type.lookup(name: 'email').id,
|
||||||
|
Ticket::Article::Type.lookup(name: 'phone').id,
|
||||||
|
Ticket::Article::Type.lookup(name: 'web').id,
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'ticket.state_id' => {
|
perform: {
|
||||||
'operator' => 'is not',
|
'notification.email' => {
|
||||||
'value' => Ticket::State.lookup(name: 'closed').id,
|
'body' => '<p>Your request (Ticket##{ticket.number}) has been received and will be reviewed by our support staff.<p>
|
||||||
},
|
|
||||||
'article.type_id' => {
|
|
||||||
'operator' => 'is',
|
|
||||||
'value' => [
|
|
||||||
Ticket::Article::Type.lookup(name: 'email').id,
|
|
||||||
Ticket::Article::Type.lookup(name: 'phone').id,
|
|
||||||
Ticket::Article::Type.lookup(name: 'web').id,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
perform: {
|
|
||||||
'notification.email' => {
|
|
||||||
'body' => '<p>Your request (Ticket##{ticket.number}) has been received and will be reviewed by our support staff.<p>
|
|
||||||
<br/>
|
<br/>
|
||||||
<p>To provide additional information, please reply to this email or click on the following link:
|
<p>To provide additional information, please reply to this email or click on the following link:
|
||||||
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
|
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
|
||||||
</p>
|
</p>
|
||||||
<br/>
|
<br/>
|
||||||
<p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
|
<p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
|
||||||
'recipient' => 'ticket_customer',
|
'recipient' => 'ticket_customer',
|
||||||
'subject' => 'Thanks for your inquiry (#{ticket.title})',
|
'subject' => 'Thanks for your inquiry (#{ticket.title})',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
disable_notification: true,
|
||||||
disable_notification: true,
|
active: true,
|
||||||
active: true,
|
created_by_id: 1,
|
||||||
created_by_id: 1,
|
updated_by_id: 1,
|
||||||
updated_by_id: 1,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# create agent1 & agent2
|
# create agent1 & agent2
|
||||||
groups = Group.where(name: 'Users')
|
Group.create_or_update(
|
||||||
roles = Role.where(name: 'Agent')
|
name: 'TicketNotificationTest',
|
||||||
agent1 = User.create_or_update(
|
updated_by_id: 1,
|
||||||
login: 'ticket-notification-agent1@example.com',
|
created_by_id: 1
|
||||||
firstname: 'Notification',
|
)
|
||||||
lastname: 'Agent1',
|
groups = Group.where(name: 'TicketNotificationTest')
|
||||||
email: 'ticket-notification-agent1@example.com',
|
roles = Role.where(name: 'Agent')
|
||||||
password: 'agentpw',
|
agent1 = User.create_or_update(
|
||||||
active: true,
|
login: 'ticket-notification-agent1@example.com',
|
||||||
roles: roles,
|
firstname: 'Notification',
|
||||||
groups: groups,
|
lastname: 'Agent1',
|
||||||
preferences: {
|
email: 'ticket-notification-agent1@example.com',
|
||||||
locale: 'de-de',
|
password: 'agentpw',
|
||||||
},
|
active: true,
|
||||||
updated_by_id: 1,
|
roles: roles,
|
||||||
created_by_id: 1,
|
groups: groups,
|
||||||
)
|
preferences: {
|
||||||
agent2 = User.create_or_update(
|
locale: 'de-de',
|
||||||
login: 'ticket-notification-agent2@example.com',
|
},
|
||||||
firstname: 'Notification',
|
updated_by_id: 1,
|
||||||
lastname: 'Agent2',
|
created_by_id: 1,
|
||||||
email: 'ticket-notification-agent2@example.com',
|
)
|
||||||
password: 'agentpw',
|
agent2 = User.create_or_update(
|
||||||
active: true,
|
login: 'ticket-notification-agent2@example.com',
|
||||||
roles: roles,
|
firstname: 'Notification',
|
||||||
groups: groups,
|
lastname: 'Agent2',
|
||||||
preferences: {
|
email: 'ticket-notification-agent2@example.com',
|
||||||
locale: 'en-ca',
|
password: 'agentpw',
|
||||||
},
|
active: true,
|
||||||
updated_by_id: 1,
|
roles: roles,
|
||||||
created_by_id: 1,
|
groups: groups,
|
||||||
)
|
preferences: {
|
||||||
Group.create_if_not_exists(
|
locale: 'en-ca',
|
||||||
name: 'WithoutAccess',
|
},
|
||||||
note: 'Test for notification check.',
|
updated_by_id: 1,
|
||||||
updated_by_id: 1,
|
created_by_id: 1,
|
||||||
created_by_id: 1
|
)
|
||||||
)
|
Group.create_if_not_exists(
|
||||||
|
name: 'WithoutAccess',
|
||||||
|
note: 'Test for notification check.',
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1
|
||||||
|
)
|
||||||
|
|
||||||
# create customer
|
# create customer
|
||||||
roles = Role.where(name: 'Customer')
|
roles = Role.where(name: 'Customer')
|
||||||
customer = User.create_or_update(
|
customer = User.create_or_update(
|
||||||
login: 'ticket-notification-customer@example.com',
|
login: 'ticket-notification-customer@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Customer',
|
lastname: 'Customer',
|
||||||
email: 'ticket-notification-customer@example.com',
|
email: 'ticket-notification-customer@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
test 'ticket notification - to all agents / to explicit agents' do
|
test 'ticket notification - to all agents / to explicit agents' do
|
||||||
|
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some notification test 1',
|
title: 'some notification test 1',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -135,8 +144,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some notification test 1',
|
title: 'some notification test 2',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -172,8 +181,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some notification test 1',
|
title: 'some notification test 3',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -264,8 +273,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create ticket with agent1 as owner
|
# create ticket with agent1 as owner
|
||||||
ticket2 = Ticket.create(
|
ticket2 = Ticket.create(
|
||||||
title: 'some notification test 2',
|
title: 'some notification test 4',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer_id: 2,
|
customer_id: 2,
|
||||||
owner_id: agent1.id,
|
owner_id: agent1.id,
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
|
@ -326,8 +335,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create ticket with agent2 and agent1 as owner
|
# create ticket with agent2 and agent1 as owner
|
||||||
ticket3 = Ticket.create(
|
ticket3 = Ticket.create(
|
||||||
title: 'some notification test 3',
|
title: 'some notification test 5',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer_id: 2,
|
customer_id: 2,
|
||||||
owner_id: agent1.id,
|
owner_id: agent1.id,
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
|
@ -414,7 +423,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some notification test 1 - no notification',
|
title: 'some notification test 1 - no notification',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -467,7 +476,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some notification test - z preferences tests 1',
|
title: 'some notification test - z preferences tests 1',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -513,7 +522,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket2 = Ticket.create(
|
ticket2 = Ticket.create(
|
||||||
title: 'some notification test - z preferences tests 2',
|
title: 'some notification test - z preferences tests 2',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
owner: agent1,
|
owner: agent1,
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
|
@ -559,7 +568,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket3 = Ticket.create(
|
ticket3 = Ticket.create(
|
||||||
title: 'some notification test - z preferences tests 3',
|
title: 'some notification test - z preferences tests 3',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
owner: agent2,
|
owner: agent2,
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
|
@ -608,7 +617,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
||||||
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
||||||
agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
||||||
agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'Users').id.to_s]
|
agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'TicketNotificationTest').id.to_s]
|
||||||
agent1.save
|
agent1.save
|
||||||
|
|
||||||
agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
|
agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
|
||||||
|
@ -623,7 +632,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket4 = Ticket.create(
|
ticket4 = Ticket.create(
|
||||||
title: 'some notification test - z preferences tests 4',
|
title: 'some notification test - z preferences tests 4',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -672,7 +681,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
||||||
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
||||||
agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
||||||
agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'Users').id.to_s]
|
agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'TicketNotificationTest').id.to_s]
|
||||||
agent1.save
|
agent1.save
|
||||||
|
|
||||||
agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
|
agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
|
||||||
|
@ -687,7 +696,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket5 = Ticket.create(
|
ticket5 = Ticket.create(
|
||||||
title: 'some notification test - z preferences tests 5',
|
title: 'some notification test - z preferences tests 5',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -751,7 +760,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket6 = Ticket.create(
|
ticket6 = Ticket.create(
|
||||||
title: 'some notification test - z preferences tests 6',
|
title: 'some notification test - z preferences tests 6',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
owner: agent1,
|
owner: agent1,
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
|
@ -828,7 +837,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket7 = Ticket.create(
|
ticket7 = Ticket.create(
|
||||||
title: 'some notification test - z preferences tests 7',
|
title: 'some notification test - z preferences tests 7',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
owner: agent1,
|
owner: agent1,
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
state: Ticket::State.lookup(name: 'new'),
|
||||||
|
@ -883,7 +892,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some notification event test 1',
|
title: 'some notification event test 1',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
@ -943,7 +952,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
title: 'some notification template test 1 Bobs\'s resumé',
|
title: 'some notification template test 1 Bobs\'s resumé',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
||||||
customer: customer,
|
customer: customer,
|
||||||
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'),
|
||||||
|
|
|
@ -2,277 +2,285 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TicketOverviewTest < ActiveSupport::TestCase
|
class TicketOverviewTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
|
agent2 = nil
|
||||||
|
organization_id = nil
|
||||||
|
customer1 = nil
|
||||||
|
customer2 = nil
|
||||||
|
customer3 = nil
|
||||||
|
test 'aaa - setup' do
|
||||||
|
|
||||||
# create base
|
# create base
|
||||||
group = Group.create_or_update(
|
group = Group.create_or_update(
|
||||||
name: 'OverviewTest',
|
name: 'OverviewTest',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
roles = Role.where(name: 'Agent')
|
roles = Role.where(name: 'Agent')
|
||||||
agent1 = User.create_or_update(
|
agent1 = User.create_or_update(
|
||||||
login: 'ticket-overview-agent1@example.com',
|
login: 'ticket-overview-agent1@example.com',
|
||||||
firstname: 'Overview',
|
firstname: 'Overview',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'ticket-overview-agent1@example.com',
|
email: 'ticket-overview-agent1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: [group],
|
groups: [group],
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
agent2 = User.create_or_update(
|
agent2 = User.create_or_update(
|
||||||
login: 'ticket-overview-agent2@example.com',
|
login: 'ticket-overview-agent2@example.com',
|
||||||
firstname: 'Overview',
|
firstname: 'Overview',
|
||||||
lastname: 'Agent2',
|
lastname: 'Agent2',
|
||||||
email: 'ticket-overview-agent2@example.com',
|
email: 'ticket-overview-agent2@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
#groups: groups,
|
#groups: groups,
|
||||||
updated_at: '2015-02-05 16:38:00',
|
updated_at: '2015-02-05 16:38:00',
|
||||||
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_or_update(
|
organization1 = Organization.create_or_update(
|
||||||
name: 'Overview Org',
|
name: 'Overview Org',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer1 = User.create_or_update(
|
customer1 = User.create_or_update(
|
||||||
login: 'ticket-overview-customer1@example.com',
|
login: 'ticket-overview-customer1@example.com',
|
||||||
firstname: 'Overview',
|
firstname: 'Overview',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
email: 'ticket-overview-customer1@example.com',
|
email: 'ticket-overview-customer1@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization1.id,
|
organization_id: organization1.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer2 = User.create_or_update(
|
customer2 = User.create_or_update(
|
||||||
login: 'ticket-overview-customer2@example.com',
|
login: 'ticket-overview-customer2@example.com',
|
||||||
firstname: 'Overview',
|
firstname: 'Overview',
|
||||||
lastname: 'Customer2',
|
lastname: 'Customer2',
|
||||||
email: 'ticket-overview-customer2@example.com',
|
email: 'ticket-overview-customer2@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization1.id,
|
organization_id: organization1.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer3 = User.create_or_update(
|
customer3 = User.create_or_update(
|
||||||
login: 'ticket-overview-customer3@example.com',
|
login: 'ticket-overview-customer3@example.com',
|
||||||
firstname: 'Overview',
|
firstname: 'Overview',
|
||||||
lastname: 'Customer3',
|
lastname: 'Customer3',
|
||||||
email: 'ticket-overview-customer3@example.com',
|
email: 'ticket-overview-customer3@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: nil,
|
organization_id: nil,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
Overview.destroy_all
|
Overview.destroy_all
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
overview_role = Role.find_by(name: 'Agent')
|
overview_role = Role.find_by(name: 'Agent')
|
||||||
Overview.create_or_update(
|
Overview.create_or_update(
|
||||||
name: 'My assigned Tickets',
|
name: 'My assigned Tickets',
|
||||||
link: 'my_assigned',
|
link: 'my_assigned',
|
||||||
prio: 1000,
|
prio: 1000,
|
||||||
role_id: overview_role.id,
|
role_id: overview_role.id,
|
||||||
condition: {
|
condition: {
|
||||||
'ticket.state_id' => {
|
'ticket.state_id' => {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
value: [ 1, 2, 3, 7 ],
|
value: [ 1, 2, 3, 7 ],
|
||||||
|
},
|
||||||
|
'ticket.owner_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
pre_condition: 'current_user.id',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'ticket.owner_id' => {
|
order: {
|
||||||
operator: 'is',
|
by: 'created_at',
|
||||||
pre_condition: 'current_user.id',
|
direction: 'ASC',
|
||||||
},
|
},
|
||||||
},
|
view: {
|
||||||
order: {
|
d: %w(title customer group created_at),
|
||||||
by: 'created_at',
|
s: %w(title customer group created_at),
|
||||||
direction: 'ASC',
|
m: %w(number title customer group created_at),
|
||||||
},
|
view_mode_default: 's',
|
||||||
view: {
|
},
|
||||||
d: %w(title customer group created_at),
|
)
|
||||||
s: %w(title customer group created_at),
|
|
||||||
m: %w(number title customer group created_at),
|
|
||||||
view_mode_default: 's',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
Overview.create_or_update(
|
Overview.create_or_update(
|
||||||
name: 'Unassigned & Open',
|
name: 'Unassigned & Open',
|
||||||
link: 'all_unassigned',
|
link: 'all_unassigned',
|
||||||
prio: 1010,
|
prio: 1010,
|
||||||
role_id: overview_role.id,
|
role_id: overview_role.id,
|
||||||
condition: {
|
condition: {
|
||||||
'ticket.state_id' => {
|
'ticket.state_id' => {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
value: [1, 2, 3],
|
value: [1, 2, 3],
|
||||||
|
},
|
||||||
|
'ticket.owner_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'ticket.owner_id' => {
|
order: {
|
||||||
operator: 'is',
|
by: 'created_at',
|
||||||
value: 1,
|
direction: 'ASC',
|
||||||
},
|
},
|
||||||
},
|
view: {
|
||||||
order: {
|
d: %w(title customer group created_at),
|
||||||
by: 'created_at',
|
s: %w(title customer group created_at),
|
||||||
direction: 'ASC',
|
m: %w(number title customer group created_at),
|
||||||
},
|
view_mode_default: 's',
|
||||||
view: {
|
|
||||||
d: %w(title customer group created_at),
|
|
||||||
s: %w(title customer group created_at),
|
|
||||||
m: %w(number title customer group created_at),
|
|
||||||
view_mode_default: 's',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
Overview.create_or_update(
|
|
||||||
name: 'My Tickets 2',
|
|
||||||
link: 'my_tickets_2',
|
|
||||||
prio: 1020,
|
|
||||||
role_id: overview_role.id,
|
|
||||||
user_ids: [agent2.id],
|
|
||||||
condition: {
|
|
||||||
'ticket.state_id' => {
|
|
||||||
operator: 'is',
|
|
||||||
value: [ 1, 2, 3, 7 ],
|
|
||||||
},
|
},
|
||||||
'ticket.owner_id' => {
|
)
|
||||||
operator: 'is',
|
Overview.create_or_update(
|
||||||
pre_condition: 'current_user.id',
|
name: 'My Tickets 2',
|
||||||
|
link: 'my_tickets_2',
|
||||||
|
prio: 1020,
|
||||||
|
role_id: overview_role.id,
|
||||||
|
user_ids: [agent2.id],
|
||||||
|
condition: {
|
||||||
|
'ticket.state_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
value: [ 1, 2, 3, 7 ],
|
||||||
|
},
|
||||||
|
'ticket.owner_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
pre_condition: 'current_user.id',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
order: {
|
||||||
order: {
|
by: 'created_at',
|
||||||
by: 'created_at',
|
direction: 'ASC',
|
||||||
direction: 'ASC',
|
},
|
||||||
},
|
view: {
|
||||||
view: {
|
d: %w(title customer group created_at),
|
||||||
d: %w(title customer group created_at),
|
s: %w(title customer group created_at),
|
||||||
s: %w(title customer group created_at),
|
m: %w(number title customer group created_at),
|
||||||
m: %w(number title customer group created_at),
|
view_mode_default: 's',
|
||||||
view_mode_default: 's',
|
},
|
||||||
},
|
)
|
||||||
)
|
|
||||||
|
|
||||||
overview_role = Role.find_by(name: 'Customer')
|
overview_role = Role.find_by(name: 'Customer')
|
||||||
Overview.create_or_update(
|
Overview.create_or_update(
|
||||||
name: 'My Tickets',
|
name: 'My Tickets',
|
||||||
link: 'my_tickets',
|
link: 'my_tickets',
|
||||||
prio: 1100,
|
prio: 1100,
|
||||||
role_id: overview_role.id,
|
role_id: overview_role.id,
|
||||||
condition: {
|
condition: {
|
||||||
'ticket.state_id' => {
|
'ticket.state_id' => {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
value: [ 1, 2, 3, 4, 6, 7 ],
|
value: [ 1, 2, 3, 4, 6, 7 ],
|
||||||
|
},
|
||||||
|
'ticket.customer_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
pre_condition: 'current_user.id',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'ticket.customer_id' => {
|
order: {
|
||||||
operator: 'is',
|
by: 'created_at',
|
||||||
pre_condition: 'current_user.id',
|
direction: 'DESC',
|
||||||
},
|
},
|
||||||
},
|
view: {
|
||||||
order: {
|
d: %w(title customer state created_at),
|
||||||
by: 'created_at',
|
s: %w(number title state created_at),
|
||||||
direction: 'DESC',
|
m: %w(number title state created_at),
|
||||||
},
|
view_mode_default: 's',
|
||||||
view: {
|
|
||||||
d: %w(title customer state created_at),
|
|
||||||
s: %w(number title state created_at),
|
|
||||||
m: %w(number title state created_at),
|
|
||||||
view_mode_default: 's',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
Overview.create_or_update(
|
|
||||||
name: 'My Organization Tickets',
|
|
||||||
link: 'my_organization_tickets',
|
|
||||||
prio: 1200,
|
|
||||||
role_id: overview_role.id,
|
|
||||||
organization_shared: true,
|
|
||||||
condition: {
|
|
||||||
'ticket.state_id' => {
|
|
||||||
operator: 'is',
|
|
||||||
value: [ 1, 2, 3, 4, 6, 7 ],
|
|
||||||
},
|
},
|
||||||
'ticket.organization_id' => {
|
)
|
||||||
operator: 'is',
|
Overview.create_or_update(
|
||||||
pre_condition: 'current_user.organization_id',
|
name: 'My Organization Tickets',
|
||||||
|
link: 'my_organization_tickets',
|
||||||
|
prio: 1200,
|
||||||
|
role_id: overview_role.id,
|
||||||
|
organization_shared: true,
|
||||||
|
condition: {
|
||||||
|
'ticket.state_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
value: [ 1, 2, 3, 4, 6, 7 ],
|
||||||
|
},
|
||||||
|
'ticket.organization_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
pre_condition: 'current_user.organization_id',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
order: {
|
||||||
order: {
|
by: 'created_at',
|
||||||
by: 'created_at',
|
direction: 'DESC',
|
||||||
direction: 'DESC',
|
|
||||||
},
|
|
||||||
view: {
|
|
||||||
d: %w(title customer state created_at),
|
|
||||||
s: %w(number title customer state created_at),
|
|
||||||
m: %w(number title customer state created_at),
|
|
||||||
view_mode_default: 's',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
Overview.create_or_update(
|
|
||||||
name: 'My Organization Tickets (open)',
|
|
||||||
link: 'my_organization_tickets_open',
|
|
||||||
prio: 1200,
|
|
||||||
role_id: overview_role.id,
|
|
||||||
user_ids: [customer2.id],
|
|
||||||
organization_shared: true,
|
|
||||||
condition: {
|
|
||||||
'ticket.state_id' => {
|
|
||||||
operator: 'is',
|
|
||||||
value: [ 1, 2, 3 ],
|
|
||||||
},
|
},
|
||||||
'ticket.organization_id' => {
|
view: {
|
||||||
operator: 'is',
|
d: %w(title customer state created_at),
|
||||||
pre_condition: 'current_user.organization_id',
|
s: %w(number title customer state created_at),
|
||||||
|
m: %w(number title customer state created_at),
|
||||||
|
view_mode_default: 's',
|
||||||
},
|
},
|
||||||
},
|
)
|
||||||
order: {
|
Overview.create_or_update(
|
||||||
by: 'created_at',
|
name: 'My Organization Tickets (open)',
|
||||||
direction: 'DESC',
|
link: 'my_organization_tickets_open',
|
||||||
},
|
prio: 1200,
|
||||||
view: {
|
role_id: overview_role.id,
|
||||||
d: %w(title customer state created_at),
|
user_ids: [customer2.id],
|
||||||
s: %w(number title customer state created_at),
|
organization_shared: true,
|
||||||
m: %w(number title customer state created_at),
|
condition: {
|
||||||
view_mode_default: 's',
|
'ticket.state_id' => {
|
||||||
},
|
operator: 'is',
|
||||||
)
|
value: [ 1, 2, 3 ],
|
||||||
|
},
|
||||||
|
'ticket.organization_id' => {
|
||||||
|
operator: 'is',
|
||||||
|
pre_condition: 'current_user.organization_id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
by: 'created_at',
|
||||||
|
direction: 'DESC',
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
d: %w(title customer state created_at),
|
||||||
|
s: %w(number title customer state created_at),
|
||||||
|
m: %w(number title customer state created_at),
|
||||||
|
view_mode_default: 's',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
overview_role = Role.find_by(name: 'Admin')
|
overview_role = Role.find_by(name: 'Admin')
|
||||||
Overview.create_or_update(
|
Overview.create_or_update(
|
||||||
name: 'Not Shown Admin',
|
name: 'Not Shown Admin',
|
||||||
link: 'not_shown_admin',
|
link: 'not_shown_admin',
|
||||||
prio: 9900,
|
prio: 9900,
|
||||||
role_id: overview_role.id,
|
role_id: overview_role.id,
|
||||||
condition: {
|
condition: {
|
||||||
'ticket.state_id' => {
|
'ticket.state_id' => {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
value: [ 1, 2, 3 ],
|
value: [ 1, 2, 3 ],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
order: {
|
||||||
order: {
|
by: 'created_at',
|
||||||
by: 'created_at',
|
direction: 'DESC',
|
||||||
direction: 'DESC',
|
},
|
||||||
},
|
view: {
|
||||||
view: {
|
d: %w(title customer state created_at),
|
||||||
d: %w(title customer state created_at),
|
s: %w(number title customer state created_at),
|
||||||
s: %w(number title customer state created_at),
|
m: %w(number title customer state created_at),
|
||||||
m: %w(number title customer state created_at),
|
view_mode_default: 's',
|
||||||
view_mode_default: 's',
|
},
|
||||||
},
|
)
|
||||||
)
|
end
|
||||||
|
|
||||||
test 'ticket create' do
|
test 'ticket create' do
|
||||||
|
|
||||||
|
|
|
@ -2,58 +2,64 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TicketRefObjectTouchTest < ActiveSupport::TestCase
|
class TicketRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
|
organization1 = nil
|
||||||
|
customer1 = nil
|
||||||
|
customer2 = nil
|
||||||
|
test 'aaa - setup' do
|
||||||
|
|
||||||
# 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: 'ticket-ref-object-update-agent1@example.com',
|
login: 'ticket-ref-object-update-agent1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'ticket-ref-object-update-agent1@example.com',
|
email: 'ticket-ref-object-update-agent1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
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',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer1 = User.create_or_update(
|
customer1 = User.create_or_update(
|
||||||
login: 'ticket-ref-object-update-customer1@example.com',
|
login: 'ticket-ref-object-update-customer1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
email: 'ticket-ref-object-update-customer1@example.com',
|
email: 'ticket-ref-object-update-customer1@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization1.id,
|
organization_id: organization1.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer2 = User.create_or_update(
|
customer2 = User.create_or_update(
|
||||||
login: 'ticket-ref-object-update-customer2@example.com',
|
login: 'ticket-ref-object-update-customer2@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Customer2',
|
lastname: 'Customer2',
|
||||||
email: 'ticket-ref-object-update-customer2@example.com',
|
email: 'ticket-ref-object-update-customer2@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: nil,
|
organization_id: nil,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
test 'a - check if customer and organization has been updated' do
|
test 'b - check if customer and organization has been updated' do
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: "some title1\n äöüß",
|
title: "some title1\n äöüß",
|
||||||
|
@ -66,8 +72,8 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
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)
|
||||||
|
@ -105,7 +111,7 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'b - check if customer (not organization) has been updated' do
|
test 'c - check if customer (not organization) has been updated' do
|
||||||
|
|
||||||
sleep 6
|
sleep 6
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
|
|
|
@ -2,76 +2,84 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TicketSelectorTest < ActiveSupport::TestCase
|
class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
|
agent2 = nil
|
||||||
|
group = nil
|
||||||
|
organization1 = nil
|
||||||
|
customer1 = nil
|
||||||
|
customer2 = nil
|
||||||
|
test 'aaa - setup' do
|
||||||
|
|
||||||
# create base
|
# create base
|
||||||
group = Group.create_or_update(
|
group = Group.create_or_update(
|
||||||
name: 'SelectorTest',
|
name: 'SelectorTest',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
roles = Role.where(name: 'Agent')
|
roles = Role.where(name: 'Agent')
|
||||||
agent1 = User.create_or_update(
|
agent1 = User.create_or_update(
|
||||||
login: 'ticket-selector-agent1@example.com',
|
login: 'ticket-selector-agent1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'ticket-selector-agent1@example.com',
|
email: 'ticket-selector-agent1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: [group],
|
groups: [group],
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
agent2 = User.create_or_update(
|
agent2 = User.create_or_update(
|
||||||
login: 'ticket-selector-agent2@example.com',
|
login: 'ticket-selector-agent2@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent2',
|
lastname: 'Agent2',
|
||||||
email: 'ticket-selector-agent2@example.com',
|
email: 'ticket-selector-agent2@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
#groups: groups,
|
#groups: groups,
|
||||||
updated_at: '2015-02-05 16:38:00',
|
updated_at: '2015-02-05 16:38:00',
|
||||||
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: 'Selector Org',
|
name: 'Selector Org',
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer1 = User.create_or_update(
|
customer1 = User.create_or_update(
|
||||||
login: 'ticket-selector-customer1@example.com',
|
login: 'ticket-selector-customer1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
email: 'ticket-selector-customer1@example.com',
|
email: 'ticket-selector-customer1@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization1.id,
|
organization_id: organization1.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer2 = User.create_or_update(
|
customer2 = User.create_or_update(
|
||||||
login: 'ticket-selector-customer2@example.com',
|
login: 'ticket-selector-customer2@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Customer2',
|
lastname: 'Customer2',
|
||||||
email: 'ticket-selector-customer2@example.com',
|
email: 'ticket-selector-customer2@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: nil,
|
organization_id: nil,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
Ticket.where(group_id: group.id).destroy_all
|
Ticket.where(group_id: group.id).destroy_all
|
||||||
|
end
|
||||||
|
|
||||||
test 'ticket create' do
|
test 'ticket create' do
|
||||||
|
|
||||||
|
|
|
@ -2,58 +2,64 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class UserRefObjectTouchTest < ActiveSupport::TestCase
|
class UserRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
|
agent1 = nil
|
||||||
|
organization1 = nil
|
||||||
|
customer1 = nil
|
||||||
|
customer2 = nil
|
||||||
|
test 'aaa - setup' do
|
||||||
|
|
||||||
# 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',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'user-ref-object-update-agent1@example.com',
|
email: 'user-ref-object-update-agent1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
groups: groups,
|
groups: groups,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
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',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer1 = User.create_or_update(
|
customer1 = User.create_or_update(
|
||||||
login: 'user-ref-object-update-customer1@example.com',
|
login: 'user-ref-object-update-customer1@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent1',
|
lastname: 'Agent1',
|
||||||
email: 'user-ref-object-update-customer1@example.com',
|
email: 'user-ref-object-update-customer1@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: organization1.id,
|
organization_id: organization1.id,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
customer2 = User.create_or_update(
|
customer2 = User.create_or_update(
|
||||||
login: 'user-ref-object-update-customer2@example.com',
|
login: 'user-ref-object-update-customer2@example.com',
|
||||||
firstname: 'Notification',
|
firstname: 'Notification',
|
||||||
lastname: 'Agent2',
|
lastname: 'Agent2',
|
||||||
email: 'user-ref-object-update-customer2@example.com',
|
email: 'user-ref-object-update-customer2@example.com',
|
||||||
password: 'customerpw',
|
password: 'customerpw',
|
||||||
active: true,
|
active: true,
|
||||||
organization_id: nil,
|
organization_id: nil,
|
||||||
roles: roles,
|
roles: roles,
|
||||||
updated_at: '2015-02-05 16:37:00',
|
updated_at: '2015-02-05 16:37:00',
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
test 'a - check if ticket and organization has been updated' do
|
test 'b - check if ticket and organization has been updated' do
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: "some title1\n äöüß",
|
title: "some title1\n äöüß",
|
||||||
|
|
Loading…
Reference in a new issue