Guillermo - add test supported languages [skip ci]

This commit is contained in:
AntonyAntonio 2016-12-21 01:09:35 -03:00
parent 7f9c12df36
commit 69c3410e03
13 changed files with 100 additions and 3 deletions

View File

@ -19,7 +19,9 @@ class GetSettingsController extends Controller {
'layout' => Setting::getSetting('layout')->getValue(),
'allow-attachments' => Setting::getSetting('allow-attachments')->getValue(),
'max-size' => Setting::getSetting('max-size')->getValue(),
'departments' => Department::getDepartmentNames()
'departments' => Department::getDepartmentNames(),
'supportedLanguages' => Language::getSupportedLanguages(),
'allowedLanguages' => Language::getAllowedLanguages()
]);
}
}

View File

@ -26,6 +26,10 @@ class CreateController extends Controller {
'departmentId' => [
'validation' => DataValidator::dataStoreId('department'),
'error' => ERRORS::INVALID_DEPARTMENT
],
'language' => [
'validation' => DataValidator::in(Language::getSupportedLanguages()),
'error' => ERRORS::INVALID_LANGUAGE
]
]
];

View File

@ -24,5 +24,24 @@ class Language extends DataStore {
];
}
public static function getSupportedLanguages() {
$array = [];
foreach(Language::LANGUAGES as $languageCode) {
if (self::getDataStore($languageCode,'code')->supported) {
array_push($array, $languageCode);
}
}
return $array;
}
public static function getAllowedLanguages() {
$array = [];
foreach(Language::LANGUAGES as $languageCode) {
if (self::getDataStore($languageCode,'code')->allowed) {
array_push($array, $languageCode);
}
}
return $array;
}
}

View File

@ -19,7 +19,8 @@ class Ticket extends DataStore {
'author',
'owner',
'ownTicketeventList',
'unreadStaff'
'unreadStaff',
'language'
);
}

View File

@ -32,6 +32,7 @@ class Scripts
title: 'Winter is coming',
content: 'The north remembers',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})

View File

@ -7,6 +7,7 @@ describe 'Retrieve all tickets' do
title: title,
content: 'The north remembers',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})

View File

@ -7,6 +7,7 @@ describe 'system/delete-department' do
title: 'Transferible ticket 1',
content: 'The north remembers',
departmentId: 4,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -14,6 +15,7 @@ describe 'system/delete-department' do
title: 'Transferible ticket 2',
content: 'The north remembers',
departmentId: 4,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -21,6 +23,7 @@ describe 'system/delete-department' do
title: 'Transferible ticket 3',
content: 'The north remembers',
departmentId: 4,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})

View File

@ -18,7 +18,6 @@ describe'system/edit-settings' do
"smtp-user" => 'admin',
"smtp-pass" => 'pass1234',
})
puts result['message']
(result['status']).should.equal('success')
@ -52,6 +51,48 @@ describe'system/edit-settings' do
row = $database.getRow('setting', 'smtp-pass', 'name')
(row['value']).should.equal('pass1234')
request('/user/logout')
end
it 'should change allowed and supported languages' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
result= request('/system/edit-settings', {
"csrf_userid" => $csrf_userid,
"csrf_token" => $csrf_token,
"supportedLanguages" => '["en", "pr", "jp", "ru"]',
"allowedLanguages" => '["en","pr", "jp", "ru", "de"]'
})
(result['status']).should.equal('success')
row = $database.getRow('language', 'en', 'code')
(row['supported']).should.equal('1')
row = $database.getRow('language', 'pr', 'code')
(row['supported']).should.equal('1')
row = $database.getRow('language', 'jp', 'code')
(row['supported']).should.equal('1')
row = $database.getRow('language', 'ru', 'code')
(row['supported']).should.equal('1')
row = $database.getRow('language', 'en', 'code')
(row['allowed']).should.equal('1')
row = $database.getRow('language', 'pr', 'code')
(row['allowed']).should.equal('1')
row = $database.getRow('language', 'jp', 'code')
(row['allowed']).should.equal('1')
row = $database.getRow('language', 'ru', 'code')
(row['allowed']).should.equal('1')
row = $database.getRow('language', 'de', 'code')
(row['allowed']).should.equal('1')
request('/user/logout')
end
end

View File

@ -7,5 +7,16 @@ describe '/system/get-settings' do
(result['data']['departments'][0]['name']).should.equal('Tech Support')
(result['data']['departments'][1]['name']).should.equal('Suggestions')
(result['data']['departments'][2]['name']).should.equal('Sales and Subscriptions')
(result['data']['allowedLanguages'][0]).should.equal('en')
(result['data']['allowedLanguages'][1]).should.equal('es')
(result['data']['allowedLanguages'][2]).should.equal('de')
(result['data']['allowedLanguages'][3]).should.equal('fr')
(result['data']['allowedLanguages'][4]).should.equal('pr')
(result['data']['allowedLanguages'][5]).should.equal('jp')
(result['data']['allowedLanguages'][6]).should.equal('ru')
(result['data']['allowedLanguages'][7]).should.equal('cn')
(result['data']['allowedLanguages'][8]).should.equal('in')
(result['data']['allowedLanguages'][9]).should.equal('tr')
(result['data']['supportedLanguages'][0]).should.equal('en')
end
end

View File

@ -7,6 +7,7 @@ describe '/ticket/create' do
result = request('/ticket/create', {
title: 'GG',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: 'INVALID_TOKEN'
})
@ -20,6 +21,7 @@ describe '/ticket/create' do
result = request('/ticket/create', {
title: 'GG',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -35,6 +37,7 @@ describe '/ticket/create' do
result = request('/ticket/create',{
title: long_text,
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -48,6 +51,7 @@ describe '/ticket/create' do
title: 'Winter is coming',
content: 'Test',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -64,6 +68,7 @@ describe '/ticket/create' do
title: 'Winter is coming',
content: long_text,
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -78,6 +83,7 @@ describe '/ticket/create' do
title: 'Winter is coming',
content: 'The north remembers',
departmentId: 30,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -92,6 +98,7 @@ describe '/ticket/create' do
title: 'Winter is coming',
content: 'The north remembers',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -116,6 +123,7 @@ describe '/ticket/create' do
title: 'Winter is coming1',
content: 'The north remembers',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -123,6 +131,7 @@ describe '/ticket/create' do
title: 'Winter is coming2',
content: 'The north remembers',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
@ -130,6 +139,7 @@ describe '/ticket/create' do
title: 'Winter is coming3',
content: 'The north remembers',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})

View File

@ -8,6 +8,7 @@ describe 'Ticket Events' do
title: 'Ticket with many events',
content: 'This is a ticket with many events',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})

View File

@ -11,6 +11,7 @@ describe '/ticket/get/' do
title: 'Should we pay?',
content: 'A Lannister always pays his debts.',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})

View File

@ -7,6 +7,8 @@ describe '/user/get' do
title: 'Should we pay?',
content: 'A Lannister always pays his debts.',
departmentId: 1,
language: 'en',
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})