From c5a6e00e810e7d9b93b3965d9eb6ea052dba234d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 19 Jun 2016 18:44:08 +0200 Subject: [PATCH] Improved auto wizard test file and tests. --- contrib/auto_wizard_test.json | 35 ++++++++++++++++++ test/unit/auto_wizard_test.rb | 70 ++++++++++++++++++++++++++++++++--- 2 files changed, 99 insertions(+), 6 deletions(-) diff --git a/contrib/auto_wizard_test.json b/contrib/auto_wizard_test.json index dc76492a8..6fe24e154 100644 --- a/contrib/auto_wizard_test.json +++ b/contrib/auto_wizard_test.json @@ -20,6 +20,41 @@ { "name": "some group1", "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": [ diff --git a/test/unit/auto_wizard_test.rb b/test/unit/auto_wizard_test.rb index e9cdd5dba..a487c6c15 100644 --- a/test/unit/auto_wizard_test.rb +++ b/test/unit/auto_wizard_test.rb @@ -107,6 +107,13 @@ class AutoWizardTest < ActiveSupport::TestCase { name: 'some group1', 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: [ @@ -118,7 +125,40 @@ class AutoWizardTest < ActiveSupport::TestCase name: 'product_name', 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?) auto_wizard_file_write(auto_wizard_data) @@ -142,11 +182,29 @@ class AutoWizardTest < ActiveSupport::TestCase auto_wizard_data[:Groups].each {|local_group| group = Group.find_by(name: local_group[:name]) assert_equal(local_group[:name], group.name) - next unless local_group[:users] - local_group[:users].each {|local_user_login| - local_user = User.find_by(login: local_user_login) - assert(group.user_ids.include?(local_user.id)) - } + if local_group[:users] + local_group[:users].each {|local_user_login| + local_user = User.find_by(login: local_user_login) + 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| setting_value = Setting.get(local_setting[:name])