Improved auto wizard test file and tests.

This commit is contained in:
Martin Edenhofer 2016-06-19 18:44:08 +02:00
parent cbcb3bee47
commit c5a6e00e81
2 changed files with 99 additions and 6 deletions

View file

@ -20,6 +20,41 @@
{ {
"name": "some group1", "name": "some group1",
"users": ["master@example.com","agent1@example.com"] "users": ["master@example.com","agent1@example.com"]
},
{
"name": "Users",
"users": ["master@example.com","agent1@example.com"],
"signature": "default",
"email_address_id": 1
}
],
"Channels": [
{
"id": 1,
"area": "Email::Account",
"group": "Users",
"options": {
"inbound": {
"adapter": "imap",
"options": {
"host": "mx1.example.com",
"user": "not_existing",
"password": "not_existing",
"ssl": true
}
},
"outbound": {
"adapter": "sendmail"
}
}
}
],
"EmailAddresses": [
{
"id": 1,
"channel_id": 1,
"realname": "Zammad Helpdesk",
"email": "zammad@localhost"
} }
], ],
"Settings": [ "Settings": [

View file

@ -107,6 +107,13 @@ class AutoWizardTest < ActiveSupport::TestCase
{ {
name: 'some group1', name: 'some group1',
users: ['master_unit_test01@example.com', 'agent1_unit_test01@example.com'] users: ['master_unit_test01@example.com', 'agent1_unit_test01@example.com']
},
{
name: 'Users',
users: ['master_unit_test01@example.com', 'agent1_unit_test01@example.com'],
signature: 'default',
email_address_id: 1,
note: 'Standard Group/Pool for Tickets.',
} }
], ],
Settings: [ Settings: [
@ -118,7 +125,40 @@ class AutoWizardTest < ActiveSupport::TestCase
name: 'product_name', name: 'product_name',
value: 'Zammad UnitTest02 System' value: 'Zammad UnitTest02 System'
}, },
] ],
Channels: [
{
id: 1,
area: 'Email::Account',
group: 'Users',
options: {
inbound: {
adapter: 'imap',
options: {
host: 'mx1.example.com',
user: 'not_existing',
password: 'some_pass',
ssl: true
}
},
outbound: {
adapter: 'sendmail'
}
},
preferences: {
online_service_disable: true,
},
active: true
}
],
EmailAddresses: [
{
id: 1,
channel_id: 1,
realname: 'some realname',
email: 'helpdesk@example.com',
}
],
} }
assert_equal(false, AutoWizard.enabled?) assert_equal(false, AutoWizard.enabled?)
auto_wizard_file_write(auto_wizard_data) auto_wizard_file_write(auto_wizard_data)
@ -142,11 +182,29 @@ class AutoWizardTest < ActiveSupport::TestCase
auto_wizard_data[:Groups].each {|local_group| auto_wizard_data[:Groups].each {|local_group|
group = Group.find_by(name: local_group[:name]) group = Group.find_by(name: local_group[:name])
assert_equal(local_group[:name], group.name) assert_equal(local_group[:name], group.name)
next unless local_group[:users] if local_group[:users]
local_group[:users].each {|local_user_login| local_group[:users].each {|local_user_login|
local_user = User.find_by(login: local_user_login) local_user = User.find_by(login: local_user_login)
assert(group.user_ids.include?(local_user.id)) assert(group.user_ids.include?(local_user.id))
} }
end
if local_group[:signature]
signature = group.signature
assert_equal('default', signature.name)
end
}
auto_wizard_data[:EmailAddresses].each {|local_email_address|
email_address = EmailAddress.find_by(email: local_email_address[:email])
assert_equal(local_email_address[:email], email_address.email)
assert_equal(local_email_address[:realname], email_address.realname)
channel = email_address.channel
assert_equal(local_email_address[:channel_id], email_address.channel.id)
}
auto_wizard_data[:Channels].each {|local_channel|
channel = Channel.find_by(id: local_channel[:id])
assert_equal(local_channel[:area], channel.area)
group = channel.group
assert_equal(local_channel[:group], group.name)
} }
auto_wizard_data[:Settings].each {|local_setting| auto_wizard_data[:Settings].each {|local_setting|
setting_value = Setting.get(local_setting[:name]) setting_value = Setting.get(local_setting[:name])