opensupports/tests/system/edit-settings.rb

100 lines
3.3 KiB
Ruby
Raw Normal View History

describe'system/edit-settings' do
request('/user/logout')
Scripts.login($staff[:email], $staff[:password], true)
it 'should edit settings' do
2018-12-24 01:44:59 +01:00
result = request('/system/edit-settings', {
"csrf_userid" => $csrf_userid,
"csrf_token" => $csrf_token,
2018-01-04 04:57:45 +01:00
"maintenance-mode" => 0,
"time-zone" => -3,
"layout" => 'full-width',
"allow-attachments" => 1,
2018-09-20 20:52:27 +02:00
"max-size" => 2,
"language" => 'en',
2018-12-24 01:44:59 +01:00
"server-email" => 'testemail@hotmail.com'
})
(result['status']).should.equal('success')
row = $database.getRow('setting', 'maintenance-mode', 'name')
(row['value']).should.equal('0')
row = $database.getRow('setting', 'time-zone', 'name')
(row['value']).should.equal('-3')
row = $database.getRow('setting', 'layout', 'name')
(row['value']).should.equal('full-width')
row = $database.getRow('setting', 'max-size', 'name')
2018-09-20 20:52:27 +02:00
(row['value']).should.equal('2')
row = $database.getRow('setting', 'language', 'name')
(row['value']).should.equal('en')
2018-12-24 01:44:59 +01:00
row = $database.getRow('setting', 'server-email', 'name')
(row['value']).should.equal('testemail@hotmail.com')
request('/user/logout')
end
2018-03-09 19:17:28 +01:00
it 'should fail if supported languages are invalid' 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", "pt", "jp", "ru", "de"]',
"allowedLanguages" => '["en", "pt", "jp", "ru"]'
})
(result['status']).should.equal('fail')
(result['message']).should.equal('INVALID_SUPPORTED_LANGUAGES')
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", "pt", "jp", "ru"]',
2018-03-09 19:17:28 +01:00
"allowedLanguages" => '["en", "pt", "jp", "ru", "de"]'
})
(result['status']).should.equal('success')
row = $database.getRow('language', 'en', 'code')
(row['supported']).should.equal('1')
row = $database.getRow('language', 'pt', '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', 'pt', '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')
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('EDIT_SETTINGS')
2016-12-29 21:25:45 +01:00
request('/user/logout')
end
2018-01-04 04:57:45 +01:00
end