Merge branch 'develop' of git.znuny.com:zammad/zammad into develop

This commit is contained in:
Martin Edenhofer 2016-12-16 12:15:47 +01:00
commit a7cdb592b7
4 changed files with 404 additions and 1 deletions

View file

@ -64,6 +64,13 @@ module Import
end
def map(customer)
mapped = map_default(customer)
mapped[:created_at] ||= DateTime.current
mapped[:updated_at] ||= DateTime.current
mapped
end
def map_default(customer)
{
created_by_id: 1,
updated_by_id: 1,

View file

@ -0,0 +1,348 @@
{
"CustomerCompanyCity": "test712259",
"Config": {
"CustomerUserEmailUniqCheck": 1,
"CustomerUserSearchListLimit": 250,
"CustomerCompanySupport": 1,
"CustomerValid": "valid_id",
"CustomerUserSearchFields": [
"login",
"first_name",
"last_name",
"customer_id"
],
"CustomerUserSearchPrefix": "*",
"Params": {
"Table": "customer_user",
"CaseSensitive": 0
},
"CustomerUserListFields": [
"first_name",
"last_name",
"email"
],
"Map": [
[
"UserTitle",
"Title",
"title",
1,
0,
"var",
"",
0
],
[
"UserFirstname",
"Firstname",
"first_name",
1,
1,
"var",
"",
0
],
[
"UserLastname",
"Lastname",
"last_name",
1,
1,
"var",
"",
0
],
[
"UserLogin",
"Username",
"login",
1,
1,
"var",
"",
0
],
[
"UserPassword",
"Password",
"pw",
0,
0,
"var",
"",
0
],
[
"UserEmail",
"Email",
"email",
1,
1,
"var",
"",
0
],
[
"UserCustomerID",
"CustomerID",
"customer_id",
0,
1,
"var",
"",
0
],
[
"UserPhone",
"Phone",
"phone",
1,
0,
"var",
"",
0
],
[
"UserFax",
"Fax",
"fax",
1,
0,
"var",
"",
0
],
[
"UserMobile",
"Mobile",
"mobile",
1,
0,
"var",
"",
0
],
[
"UserStreet",
"Street",
"street",
1,
0,
"var",
"",
0
],
[
"UserZip",
"Zip",
"zip",
1,
0,
"var",
"",
0
],
[
"UserCity",
"City",
"city",
1,
0,
"var",
"",
0
],
[
"UserCountry",
"Country",
"country",
1,
0,
"var",
"",
0
],
[
"UserComment",
"Comment",
"comments",
1,
0,
"var",
"",
0
],
[
"ValidID",
"Valid",
"valid_id",
0,
1,
"int",
"",
0
]
],
"CustomerKey": "login",
"CustomerUserSearchSuffix": "*",
"Module": "Kernel::System::CustomerUser::DB",
"CacheTTL": 86400,
"Selections": {},
"CustomerID": "customer_id",
"Name": "Database Backend",
"CustomerUserPostMasterSearchFields": [
"email"
],
"CustomerUserNameFields": [
"title",
"first_name",
"last_name"
]
},
"UserCustomerID": "test712259",
"CustomerCompanyComment": "test712259",
"Source": "CustomerUser",
"UserTitle": "",
"CompanyConfig": {
"CustomerCompanySearchFields": [
"customer_id",
"name"
],
"CustomerCompanyListFields": [
"customer_id",
"name"
],
"Module": "Kernel::System::CustomerCompany::DB",
"CustomerCompanyKey": "customer_id",
"CustomerCompanySearchSuffix": "*",
"CacheTTL": 86400,
"CustomerCompanySearchListLimit": 250,
"CustomerCompanySearchPrefix": "",
"CustomerCompanyValid": "valid_id",
"Params": {
"Table": "customer_company",
"CaseSensitive": 0
},
"Map": [
[
"CustomerID",
"CustomerID",
"customer_id",
0,
1,
"var",
"",
0
],
[
"CustomerCompanyName",
"Customer",
"name",
1,
1,
"var",
"",
0
],
[
"CustomerCompanyStreet",
"Street",
"street",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyZIP",
"Zip",
"zip",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyCity",
"City",
"city",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyCountry",
"Country",
"country",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyURL",
"URL",
"url",
1,
0,
"var",
"[% Data.CustomerCompanyURL | html %]",
0
],
[
"CustomerCompanyComment",
"Comment",
"comments",
1,
0,
"var",
"",
0
],
[
"ValidID",
"Valid",
"valid_id",
0,
1,
"int",
"",
0
]
],
"Name": "Database Backend"
},
"UserZip": null,
"UserLastname": "test669673",
"ChangeBy": "1",
"CreateTime": null,
"UserLogin": "test669673",
"UserPhone": null,
"CustomerID": "test712259",
"CustomerCompanyValidID": "1",
"CustomerCompanyZIP": "test712259",
"UserCountry": null,
"UserPassword": "f8be19af2f25837a31eff9131b0e47a5173290652c04a48b49b86474d48825ee",
"ValidID": "1",
"UserRefreshTime": "0",
"UserEmail": "qa100@t-online.de",
"UserComment": "",
"UserID": "test669673",
"UserFirstname": "test669673",
"CustomerCompanyCountry": "test712259",
"UserFax": null,
"CreateBy": "1",
"ChangeTime": null,
"UserShowTickets": "25",
"UserStreet": null,
"CustomerCompanyURL": "test712259",
"CustomerCompanyName": "test712259",
"UserMobile": null,
"CustomerCompanyStreet": "test712259",
"UserCity": null
}

View file

@ -37,7 +37,7 @@ RSpec.describe Import::OTRS::CustomerUser do
let(:organization) { instance_double(Organization) }
let(:organization_id) { 1337 }
context 'Customer User' do
context 'regular user' do
let(:object_structure) { load_customer_json('default') }
let(:zammad_structure) {
@ -73,4 +73,49 @@ RSpec.describe Import::OTRS::CustomerUser do
updates_with(zammad_structure)
end
end
context 'no timestamps' do
let(:object_structure) { load_customer_json('no_timestamps') }
let(:zammad_structure) {
{
created_by_id: '1',
updated_by_id: '1',
active: true,
source: 'OTRS Import',
organization_id: 1337,
role_ids: [3],
updated_at: DateTime.current,
created_at: DateTime.current,
note: '',
email: 'qa100@t-online.de',
firstname: 'test669673',
lastname: 'test669673',
login: 'test669673',
password: 'f8be19af2f25837a31eff9131b0e47a5173290652c04a48b49b86474d48825ee',
phone: nil,
fax: nil,
mobile: nil,
street: nil,
zip: nil,
city: nil,
country: nil
}}
before(:each) do
travel_to DateTime.current
end
after(:each) do
travel_back
end
it 'creates' do
creates_with(zammad_structure)
end
it 'updates' do
updates_with(zammad_structure)
end
end
end

View file

@ -31,6 +31,9 @@ RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# make usage of time travel helpers possible
config.include ActiveSupport::Testing::TimeHelpers
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.