From 83edf85f3dbbe2c099ec757c529318544fc4f030 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Mon, 19 Dec 2016 23:17:35 -0300 Subject: [PATCH] Guillermo - path edit-settings tests[skip ci] --- server/controllers/system/edit-settings.php | 21 ++++---- server/controllers/system/init-settings.php | 2 +- tests/init.rb | 1 + tests/system/edit-settings.rb | 57 +++++++++++++++++++++ 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 tests/system/edit-settings.rb diff --git a/server/controllers/system/edit-settings.php b/server/controllers/system/edit-settings.php index 8d30587a..526d83ea 100644 --- a/server/controllers/system/edit-settings.php +++ b/server/controllers/system/edit-settings.php @@ -13,19 +13,20 @@ class EditSettingsController extends Controller { public function handler() { $settings = [ - 'manteniance-mode', - 'system-title', - 'timezone', - 'layout', - 'smtp-server', - 'smtp-email', - 'smtp-password', - 'smtp-port', - 'default-language', + 'language', 'recaptcha-public', 'recaptcha-private', + 'no-reply-email', + 'smtp-host', + 'smtp-port', + 'smtp-user', + 'smtp-pass', + 'time-zone', + 'maintenance-mode', + 'layout', 'allow-attachments', - 'max-size' + 'max-size', + 'system-title' ]; foreach($settings as $setting) { diff --git a/server/controllers/system/init-settings.php b/server/controllers/system/init-settings.php index aaf52287..03797874 100644 --- a/server/controllers/system/init-settings.php +++ b/server/controllers/system/init-settings.php @@ -38,7 +38,7 @@ class InitSettingsController extends Controller { 'layout' => 'boxed', 'allow-attachments' => 0, 'max-size' => 0, - + 'system-title' => 'Support Center' ]); } diff --git a/tests/init.rb b/tests/init.rb index 39acfcba..48ea0c17 100644 --- a/tests/init.rb +++ b/tests/init.rb @@ -11,6 +11,7 @@ require './scripts.rb' # TESTS require './system/init-settings.rb' require './system/get-settings.rb' +require './system/edit-settings.rb' require './user/signup.rb' require './user/login.rb' require './user/send-recover-password.rb' diff --git a/tests/system/edit-settings.rb b/tests/system/edit-settings.rb new file mode 100644 index 00000000..beb96aa1 --- /dev/null +++ b/tests/system/edit-settings.rb @@ -0,0 +1,57 @@ +describe'system/edit-settings' do + request('/user/logout') + Scripts.login($staff[:email], $staff[:password], true) + + it 'should edit settings' do + result= request('/system/edit-settings', { + "csrf_userid" => $csrf_userid, + "csrf_token" => $csrf_token, + "maintenance-mode" => 1, + "time-zone" => -3, + "layout" => 'full-width', + "allow-attachments" => 1, + "max-size" => 2, + "language" => 'es', + "no-reply-email" => 'testemail@hotmail.com', + "smtp-host" => 'www.opensupports.com', + "smtp-port" => 18, + "smtp-user" => 'admin', + "smtp-pass" => 'pass1234', + }) + puts result['message'] + + (result['status']).should.equal('success') + + row = $database.getRow('setting', 'maintenance-mode', 'name') + (row['value']).should.equal('1') + + 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') + (row['value']).should.equal('2') + + row = $database.getRow('setting', 'language', 'name') + (row['value']).should.equal('es') + + row = $database.getRow('setting', 'no-reply-email', 'name') + (row['value']).should.equal('testemail@hotmail.com') + + row = $database.getRow('setting', 'smtp-host', 'name') + (row['value']).should.equal('www.opensupports.com') + + row = $database.getRow('setting', 'smtp-port', 'name') + (row['value']).should.equal('18') + + row = $database.getRow('setting', 'smtp-user', 'name') + (row['value']).should.equal('admin') + + row = $database.getRow('setting', 'smtp-pass', 'name') + (row['value']).should.equal('pass1234') + + request('/user/logout') + end +end \ No newline at end of file