Moved to init prepare/setup method for tests.

This commit is contained in:
Martin Edenhofer 2016-06-20 10:55:45 +02:00
parent 1e2f1da0aa
commit 3c523b4f7d
12 changed files with 793 additions and 725 deletions

View file

@ -2,27 +2,32 @@
require 'test_helper'
class ActivityStreamTest < ActiveSupport::TestCase
role = Role.lookup(name: 'Admin')
group = Group.lookup(name: 'Users')
admin_user = User.create_or_update(
login: 'admin',
firstname: 'Bob',
lastname: 'Smith',
email: 'bob@example.com',
password: 'some_pass',
active: true,
role_ids: [role.id],
group_ids: [group.id],
updated_by_id: 1,
created_by_id: 1
)
current_user = User.lookup(email: 'nicole.braun@zammad.org')
admin_user = nil
current_user = nil
activity_record_delay = nil
test 'aaa - setup' do
role = Role.lookup(name: 'Admin')
group = Group.lookup(name: 'Users')
admin_user = User.create_or_update(
login: 'admin',
firstname: 'Bob',
lastname: 'Smith',
email: 'bob@example.com',
password: 'some_pass',
active: true,
role_ids: [role.id],
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']
ENV['ZAMMAD_ACTIVITY_RECORD_DELAY'].to_i.seconds
else
90.seconds
end
activity_record_delay = if ENV['ZAMMAD_ACTIVITY_RECORD_DELAY']
ENV['ZAMMAD_ACTIVITY_RECORD_DELAY'].to_i.seconds
else
90.seconds
end
end
test 'ticket+user' do
tests = [

View file

@ -155,8 +155,8 @@ class AutoWizardTest < ActiveSupport::TestCase
{
id: 1,
channel_id: 1,
realname: 'some realname',
email: 'helpdesk@example.com',
realname: 'Zammad',
email: 'zammad@localhost',
}
],
}

View file

@ -2,36 +2,40 @@
require 'test_helper'
class ChatTest < ActiveSupport::TestCase
agent1 = nil
agent2 = nil
test 'aaa - setup' do
# create base
groups = Group.all
roles = Role.where( name: %w(Agent Chat) )
agent1 = User.create_or_update(
login: 'ticket-chat-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-chat-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-chat-agent2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'ticket-chat-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:38:00',
updated_by_id: 1,
created_by_id: 1,
)
# create base
groups = Group.all
roles = Role.where( name: %w(Agent Chat) )
agent1 = User.create_or_update(
login: 'ticket-chat-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-chat-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-chat-agent2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'ticket-chat-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:38:00',
updated_by_id: 1,
created_by_id: 1,
)
end
test 'default test' do

View file

@ -2,33 +2,43 @@
require 'test_helper'
class OnlineNotificationTest < ActiveSupport::TestCase
role = Role.lookup(name: 'Agent')
group = Group.lookup(name: 'Users')
agent_user1 = User.create_or_update(
login: 'agent_online_notify1',
firstname: 'Bob',
lastname: 'Smith',
email: 'agent_online_notify1@example.com',
password: 'some_pass',
active: true,
role_ids: [role.id],
group_ids: [group.id],
updated_by_id: 1,
created_by_id: 1
)
agent_user2 = User.create_or_update(
login: 'agent_online_notify2',
firstname: 'Bob',
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')
group = nil
agent_user1 = nil
agent_user2 = nil
customer_user = nil
test 'aaa - setup' do
role = Role.lookup(name: 'Agent')
group = Group.create_or_update(
name: 'OnlineNotificationTest',
updated_by_id: 1,
created_by_id: 1
)
agent_user1 = User.create_or_update(
login: 'agent_online_notify1',
firstname: 'Bob',
lastname: 'Smith',
email: 'agent_online_notify1@example.com',
password: 'some_pass',
active: true,
role_ids: [role.id],
group_ids: [group.id],
updated_by_id: 1,
created_by_id: 1
)
agent_user2 = User.create_or_update(
login: 'agent_online_notify2',
firstname: 'Bob',
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
@ -36,7 +46,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
# case #1
ticket1 = Ticket.create(
group_id: Group.lookup(name: 'Users').id,
group: group,
customer_id: customer_user.id,
owner_id: User.lookup(login: '-').id,
title: 'Unit Test 1 (äöüß)!',
@ -91,7 +101,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
# case #2
ticket2 = Ticket.create(
group_id: Group.lookup(name: 'Users').id,
group: group,
customer_id: customer_user.id,
owner_id: agent_user1.id,
title: 'Unit Test 1 (äöüß)!',
@ -146,7 +156,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
# case #3
ticket3 = Ticket.create(
group_id: Group.lookup(name: 'Users').id,
group: group,
customer_id: customer_user.id,
owner_id: User.lookup(login: '-').id,
title: 'Unit Test 2 (äöüß)!',
@ -226,7 +236,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
# case #4
ticket4 = Ticket.create(
group_id: Group.lookup(name: 'Users').id,
group: group,
customer_id: customer_user.id,
owner_id: agent_user1.id,
title: 'Unit Test 3 (äöüß)!',
@ -280,7 +290,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
# case #5
ticket5 = Ticket.create(
group_id: Group.lookup(name: 'Users').id,
group: group,
customer_id: customer_user.id,
owner_id: User.lookup(login: '-').id,
title: 'Unit Test 4 (äöüß)!',
@ -364,7 +374,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
test 'ticket notification item check' do
ticket1 = Ticket.create(
title: 'some title',
group: Group.lookup(name: 'Users'),
group: group,
customer_id: customer_user.id,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),

View file

@ -2,78 +2,84 @@
require 'test_helper'
class OrganizationRefObjectTouchTest < ActiveSupport::TestCase
agent1 = nil
organization1 = nil
customer1 = nil
customer2 = nil
test 'aaa - setup' do
# create base
groups = Group.where( name: 'Users' )
roles = Role.where( name: 'Agent' )
agent1 = User.create_or_update(
login: 'organization-ref-object-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'organization-ref-object-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where( name: 'Customer' )
organization1 = Organization.create_if_not_exists(
name: 'Ref Object Update Org 1',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
organization2 = Organization.create_if_not_exists(
name: 'Ref Object Update Org 2',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'organization-ref-object-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'organization-ref-object-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'organization-ref-object-update-customer2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'organization-ref-object-update-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: organization2.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
# create base
groups = Group.where(name: 'Users')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'organization-ref-object-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'organization-ref-object-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Ref Object Update Org 1',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
organization2 = Organization.create_if_not_exists(
name: 'Ref Object Update Org 2',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'organization-ref-object-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'organization-ref-object-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'organization-ref-object-update-customer2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'organization-ref-object-update-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: organization2.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_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(
title: "some title1\n äöüß",
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: customer1.id,
owner_id: agent1.id,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert(ticket, 'ticket created')
assert_equal(ticket.customer.id, customer1.id )
assert_equal(ticket.organization.id, organization1.id )
assert_equal(ticket.customer.id, customer1.id)
assert_equal(ticket.organization.id, organization1.id)
sleep 4

View file

@ -2,13 +2,14 @@
require 'test_helper'
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)
roles = Role.where(name: %w(Agent Admin))
user.roles = roles
user.save
test 'a cache' do
test 'b cache' do
Sessions::CacheIn.set('last_run_test', true, { expires_in: 1.second })
result = Sessions::CacheIn.get('last_run_test')
assert_equal(true, result, 'check 1')

View file

@ -2,59 +2,64 @@
require 'test_helper'
class TicketCustomerOrganizationUpdateTest < ActiveSupport::TestCase
agent1 = nil
organization1 = nil
customer1 = nil
test 'aaa - setup' do
# create base
groups = Group.where( name: 'Users' )
roles = Role.where( name: 'Agent' )
agent1 = User.create_or_update(
login: 'ticket-customer-organization-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-customer-organization-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where( name: 'Customer' )
organization1 = Organization.create_if_not_exists(
name: 'Customer Organization Update',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-customer-organization-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Customer1',
email: 'ticket-customer-organization-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
# create base
groups = Group.where(name: 'Users')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-customer-organization-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-customer-organization-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Customer Organization Update',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-customer-organization-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Customer1',
email: 'ticket-customer-organization-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
end
test 'create ticket, update customers organization later' do
ticket = Ticket.create(
title: "some title1\n äöüß",
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: customer1.id,
owner_id: agent1.id,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( customer1.id, ticket.customer.id )
assert_equal( organization1.id, ticket.organization.id )
assert(ticket, 'ticket created')
assert_equal(customer1.id, ticket.customer.id)
assert_equal(organization1.id, ticket.organization.id)
# update customer organization
customer1.organization_id = nil
@ -62,7 +67,7 @@ class TicketCustomerOrganizationUpdateTest < ActiveSupport::TestCase
# verify ticket
ticket = Ticket.find(ticket.id)
assert_equal( nil, ticket.organization_id )
assert_equal(nil, ticket.organization_id)
# update customer organization
customer1.organization_id = organization1.id
@ -70,7 +75,7 @@ class TicketCustomerOrganizationUpdateTest < ActiveSupport::TestCase
# verify ticket
ticket = Ticket.find(ticket.id)
assert_equal( organization1.id, ticket.organization_id )
assert_equal(organization1.id, ticket.organization_id)
ticket.destroy
end

View file

@ -2,107 +2,116 @@
require 'test_helper'
class TicketNotificationTest < ActiveSupport::TestCase
Trigger.create_or_update(
name: 'auto reply - new ticket',
condition: {
'ticket.action' => {
'operator' => 'is',
'value' => 'create',
agent1 = nil
agent2 = nil
customer = nil
test 'aaa - setup' do
Trigger.create_or_update(
name: 'auto reply - new ticket',
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' => {
'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,
],
},
},
perform: {
'notification.email' => {
'body' => '<p>Your request (Ticket##{ticket.number}) has been received and will be reviewed by our support staff.<p>
perform: {
'notification.email' => {
'body' => '<p>Your request (Ticket##{ticket.number}) has been received and will be reviewed by our support staff.<p>
<br/>
<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>
</p>
<br/>
<p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
'recipient' => 'ticket_customer',
'subject' => 'Thanks for your inquiry (#{ticket.title})',
'recipient' => 'ticket_customer',
'subject' => 'Thanks for your inquiry (#{ticket.title})',
},
},
},
disable_notification: true,
active: true,
created_by_id: 1,
updated_by_id: 1,
)
disable_notification: true,
active: true,
created_by_id: 1,
updated_by_id: 1,
)
# create agent1 & agent2
groups = Group.where(name: 'Users')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-notification-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-notification-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
preferences: {
locale: 'de-de',
},
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-notification-agent2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'ticket-notification-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
preferences: {
locale: 'en-ca',
},
updated_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 agent1 & agent2
Group.create_or_update(
name: 'TicketNotificationTest',
updated_by_id: 1,
created_by_id: 1
)
groups = Group.where(name: 'TicketNotificationTest')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-notification-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-notification-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
preferences: {
locale: 'de-de',
},
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-notification-agent2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'ticket-notification-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
preferences: {
locale: 'en-ca',
},
updated_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
roles = Role.where(name: 'Customer')
customer = User.create_or_update(
login: 'ticket-notification-customer@example.com',
firstname: 'Notification',
lastname: 'Customer',
email: 'ticket-notification-customer@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_by_id: 1,
created_by_id: 1,
)
# create customer
roles = Role.where(name: 'Customer')
customer = User.create_or_update(
login: 'ticket-notification-customer@example.com',
firstname: 'Notification',
lastname: 'Customer',
email: 'ticket-notification-customer@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_by_id: 1,
created_by_id: 1,
)
end
test 'ticket notification - to all agents / to explicit agents' do
# create ticket in group
ticket1 = Ticket.create(
title: 'some notification test 1',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
@ -135,8 +144,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket1 = Ticket.create(
title: 'some notification test 1',
group: Group.lookup(name: 'Users'),
title: 'some notification test 2',
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
@ -172,8 +181,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket1 = Ticket.create(
title: 'some notification test 1',
group: Group.lookup(name: 'Users'),
title: 'some notification test 3',
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
@ -264,8 +273,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket with agent1 as owner
ticket2 = Ticket.create(
title: 'some notification test 2',
group: Group.lookup(name: 'Users'),
title: 'some notification test 4',
group: Group.lookup(name: 'TicketNotificationTest'),
customer_id: 2,
owner_id: agent1.id,
state: Ticket::State.lookup(name: 'new'),
@ -326,8 +335,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket with agent2 and agent1 as owner
ticket3 = Ticket.create(
title: 'some notification test 3',
group: Group.lookup(name: 'Users'),
title: 'some notification test 5',
group: Group.lookup(name: 'TicketNotificationTest'),
customer_id: 2,
owner_id: agent1.id,
state: Ticket::State.lookup(name: 'new'),
@ -414,7 +423,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket1 = Ticket.create(
title: 'some notification test 1 - no notification',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
@ -467,7 +476,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket1 = Ticket.create(
title: 'some notification test - z preferences tests 1',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
@ -513,7 +522,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket2 = Ticket.create(
title: 'some notification test - z preferences tests 2',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
owner: agent1,
state: Ticket::State.lookup(name: 'new'),
@ -559,7 +568,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket3 = Ticket.create(
title: 'some notification test - z preferences tests 3',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
owner: agent2,
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_nobody'] = false
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
agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
@ -623,7 +632,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket4 = Ticket.create(
title: 'some notification test - z preferences tests 4',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
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_nobody'] = false
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
agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
@ -687,7 +696,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket5 = Ticket.create(
title: 'some notification test - z preferences tests 5',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
@ -751,7 +760,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket6 = Ticket.create(
title: 'some notification test - z preferences tests 6',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
owner: agent1,
state: Ticket::State.lookup(name: 'new'),
@ -828,7 +837,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket7 = Ticket.create(
title: 'some notification test - z preferences tests 7',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
owner: agent1,
state: Ticket::State.lookup(name: 'new'),
@ -883,7 +892,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket1 = Ticket.create(
title: 'some notification event test 1',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
@ -943,7 +952,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
# create ticket in group
ticket1 = Ticket.create(
title: 'some notification template test 1 Bobs\'s resumé',
group: Group.lookup(name: 'Users'),
group: Group.lookup(name: 'TicketNotificationTest'),
customer: customer,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),

View file

@ -2,277 +2,285 @@
require 'test_helper'
class TicketOverviewTest < ActiveSupport::TestCase
agent1 = nil
agent2 = nil
organization_id = nil
customer1 = nil
customer2 = nil
customer3 = nil
test 'aaa - setup' do
# create base
group = Group.create_or_update(
name: 'OverviewTest',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-overview-agent1@example.com',
firstname: 'Overview',
lastname: 'Agent1',
email: 'ticket-overview-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: [group],
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-overview-agent2@example.com',
firstname: 'Overview',
lastname: 'Agent2',
email: 'ticket-overview-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
#groups: groups,
updated_at: '2015-02-05 16:38:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_or_update(
name: 'Overview Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-overview-customer1@example.com',
firstname: 'Overview',
lastname: 'Customer1',
email: 'ticket-overview-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'ticket-overview-customer2@example.com',
firstname: 'Overview',
lastname: 'Customer2',
email: 'ticket-overview-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer3 = User.create_or_update(
login: 'ticket-overview-customer3@example.com',
firstname: 'Overview',
lastname: 'Customer3',
email: 'ticket-overview-customer3@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
Overview.destroy_all
UserInfo.current_user_id = 1
overview_role = Role.find_by(name: 'Agent')
Overview.create_or_update(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 7 ],
# create base
group = Group.create_or_update(
name: 'OverviewTest',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-overview-agent1@example.com',
firstname: 'Overview',
lastname: 'Agent1',
email: 'ticket-overview-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: [group],
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-overview-agent2@example.com',
firstname: 'Overview',
lastname: 'Agent2',
email: 'ticket-overview-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
#groups: groups,
updated_at: '2015-02-05 16:38:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_or_update(
name: 'Overview Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-overview-customer1@example.com',
firstname: 'Overview',
lastname: 'Customer1',
email: 'ticket-overview-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'ticket-overview-customer2@example.com',
firstname: 'Overview',
lastname: 'Customer2',
email: 'ticket-overview-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer3 = User.create_or_update(
login: 'ticket-overview-customer3@example.com',
firstname: 'Overview',
lastname: 'Customer3',
email: 'ticket-overview-customer3@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
Overview.destroy_all
UserInfo.current_user_id = 1
overview_role = Role.find_by(name: 'Agent')
Overview.create_or_update(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 7 ],
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
order: {
by: 'created_at',
direction: 'ASC',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
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',
},
)
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: 'Unassigned & Open',
link: 'all_unassigned',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
Overview.create_or_update(
name: 'Unassigned & Open',
link: 'all_unassigned',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [1, 2, 3],
},
'ticket.owner_id' => {
operator: 'is',
value: 1,
},
},
'ticket.owner_id' => {
operator: 'is',
value: 1,
order: {
by: 'created_at',
direction: 'ASC',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
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 ],
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',
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
)
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',
pre_condition: 'current_user.id',
},
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
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',
},
)
order: {
by: 'created_at',
direction: 'ASC',
},
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_role = Role.find_by(name: 'Customer')
Overview.create_or_update(
name: 'My Tickets',
link: 'my_tickets',
prio: 1100,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
overview_role = Role.find_by(name: 'Customer')
Overview.create_or_update(
name: 'My Tickets',
link: 'my_tickets',
prio: 1100,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ],
},
'ticket.customer_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
'ticket.customer_id' => {
operator: 'is',
pre_condition: 'current_user.id',
order: {
by: 'created_at',
direction: 'DESC',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
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 ],
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',
},
'ticket.organization_id' => {
operator: 'is',
pre_condition: 'current_user.organization_id',
)
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',
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.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 ],
order: {
by: 'created_at',
direction: 'DESC',
},
'ticket.organization_id' => {
operator: 'is',
pre_condition: 'current_user.organization_id',
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',
},
},
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.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' => {
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.create_or_update(
name: 'Not Shown Admin',
link: 'not_shown_admin',
prio: 9900,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3 ],
overview_role = Role.find_by(name: 'Admin')
Overview.create_or_update(
name: 'Not Shown Admin',
link: 'not_shown_admin',
prio: 9900,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: [ 1, 2, 3 ],
},
},
},
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',
},
)
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',
},
)
end
test 'ticket create' do

View file

@ -2,58 +2,64 @@
require 'test_helper'
class TicketRefObjectTouchTest < ActiveSupport::TestCase
agent1 = nil
organization1 = nil
customer1 = nil
customer2 = nil
test 'aaa - setup' do
# create base
groups = Group.where( name: 'Users' )
roles = Role.where( name: 'Agent' )
agent1 = User.create_or_update(
login: 'ticket-ref-object-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-ref-object-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where( name: 'Customer' )
organization1 = Organization.create_if_not_exists(
name: 'Ref Object Update Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-ref-object-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Customer1',
email: 'ticket-ref-object-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'ticket-ref-object-update-customer2@example.com',
firstname: 'Notification',
lastname: 'Customer2',
email: 'ticket-ref-object-update-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
# create base
groups = Group.where(name: 'Users')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-ref-object-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-ref-object-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Ref Object Update Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-ref-object-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Customer1',
email: 'ticket-ref-object-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'ticket-ref-object-update-customer2@example.com',
firstname: 'Notification',
lastname: 'Customer2',
email: 'ticket-ref-object-update-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_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(
title: "some title1\n äöüß",
@ -66,8 +72,8 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
created_by_id: 1,
)
assert(ticket, 'ticket created')
assert_equal(ticket.customer.id, customer1.id )
assert_equal(ticket.organization.id, organization1.id )
assert_equal(ticket.customer.id, customer1.id)
assert_equal(ticket.organization.id, organization1.id)
# check if customer and organization has been touched
customer1 = User.find(customer1.id)
@ -105,7 +111,7 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
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
ticket = Ticket.create(

View file

@ -2,76 +2,84 @@
require 'test_helper'
class TicketSelectorTest < ActiveSupport::TestCase
agent1 = nil
agent2 = nil
group = nil
organization1 = nil
customer1 = nil
customer2 = nil
test 'aaa - setup' do
# create base
group = Group.create_or_update(
name: 'SelectorTest',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-selector-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-selector-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: [group],
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-selector-agent2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'ticket-selector-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
#groups: groups,
updated_at: '2015-02-05 16:38:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Selector Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-selector-customer1@example.com',
firstname: 'Notification',
lastname: 'Customer1',
email: 'ticket-selector-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'ticket-selector-customer2@example.com',
firstname: 'Notification',
lastname: 'Customer2',
email: 'ticket-selector-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
# create base
group = Group.create_or_update(
name: 'SelectorTest',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'ticket-selector-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'ticket-selector-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: [group],
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
agent2 = User.create_or_update(
login: 'ticket-selector-agent2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'ticket-selector-agent2@example.com',
password: 'agentpw',
active: true,
roles: roles,
#groups: groups,
updated_at: '2015-02-05 16:38:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Selector Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'ticket-selector-customer1@example.com',
firstname: 'Notification',
lastname: 'Customer1',
email: 'ticket-selector-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'ticket-selector-customer2@example.com',
firstname: 'Notification',
lastname: 'Customer2',
email: 'ticket-selector-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_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

View file

@ -2,58 +2,64 @@
require 'test_helper'
class UserRefObjectTouchTest < ActiveSupport::TestCase
agent1 = nil
organization1 = nil
customer1 = nil
customer2 = nil
test 'aaa - setup' do
# create base
groups = Group.where(name: 'Users')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'user-ref-object-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'user-ref-object-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Ref Object Update Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'user-ref-object-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'user-ref-object-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'user-ref-object-update-customer2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'user-ref-object-update-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
# create base
groups = Group.where(name: 'Users')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'user-ref-object-update-agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'user-ref-object-update-agent1@example.com',
password: 'agentpw',
active: true,
roles: roles,
groups: groups,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Ref Object Update Org',
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer1 = User.create_or_update(
login: 'user-ref-object-update-customer1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'user-ref-object-update-customer1@example.com',
password: 'customerpw',
active: true,
organization_id: organization1.id,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_by_id: 1,
created_by_id: 1,
)
customer2 = User.create_or_update(
login: 'user-ref-object-update-customer2@example.com',
firstname: 'Notification',
lastname: 'Agent2',
email: 'user-ref-object-update-customer2@example.com',
password: 'customerpw',
active: true,
organization_id: nil,
roles: roles,
updated_at: '2015-02-05 16:37:00',
updated_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(
title: "some title1\n äöüß",