diff --git a/server/models/MailTemplate.php b/server/models/MailTemplate.php index 2c41041a..2d031e91 100644 --- a/server/models/MailTemplate.php +++ b/server/models/MailTemplate.php @@ -12,7 +12,7 @@ class MailTemplate extends DataStore { $bean = RedBean::findOne(MailTemplate::TABLE, 'type = :type AND language = :language', array( ':type' => $type, - ':language' => $globalLanguage + ':language' => $globalLanguage->value )); return ($bean) ? new MailTemplate($bean) : null; @@ -22,6 +22,7 @@ class MailTemplate extends DataStore { return [ 'type', 'subject', + 'language', 'body' ]; } diff --git a/server/models/Setting.php b/server/models/Setting.php index 5c961113..0df2404b 100644 --- a/server/models/Setting.php +++ b/server/models/Setting.php @@ -4,7 +4,7 @@ class Setting extends DataStore { const TABLE = 'setting'; public static function getSetting($name) { - return parent::getDataStore('name', $name); + return parent::getDataStore($name, 'name'); } public static function getProps() { diff --git a/server/tests/controllers/user/loginTest.php b/server/tests/controllers/user/loginTest.php index 7b80f38b..13d29800 100644 --- a/server/tests/controllers/user/loginTest.php +++ b/server/tests/controllers/user/loginTest.php @@ -5,7 +5,7 @@ include_once 'tests/__mocks__/ResponseMock.php'; include_once 'tests/__mocks__/ControllerMock.php'; include_once 'tests/__mocks__/SessionMock.php'; include_once 'tests/__mocks__/UserMock.php'; -include_once 'models/ERRORS.php'; +include_once 'data/ERRORS.php'; include_once 'controllers/user/login.php'; diff --git a/tests/init.rb b/tests/init.rb index 9a3a25e6..5c5f792b 100644 --- a/tests/init.rb +++ b/tests/init.rb @@ -8,6 +8,7 @@ require './libs.rb' require './scripts.rb' # TESTS +require './system/init-settings.rb' require './user/signup.rb' require './user/login.rb' require './user/send-recover-password.rb' diff --git a/tests/libs.rb b/tests/libs.rb index 7472135a..1da036ee 100644 --- a/tests/libs.rb +++ b/tests/libs.rb @@ -1,5 +1,5 @@ -def request(path, data) +def request(path, data = {}) uri = URI('http://localhost:8080' + path) response = Net::HTTP.post_form(uri, data) @@ -8,8 +8,8 @@ end class Database def initialize() - mysqlUser = ENV['MYSQL_USER'] || 'root'; - mysqlPass = ENV['MYSQL_PASSWORD'] || ''; + mysqlUser = ENV['MYSQL_USER'] || 'root' + mysqlPass = ENV['MYSQL_PASSWORD'] || '' @connection = Mysql.new('localhost', mysqlUser , mysqlPass, 'development') end diff --git a/tests/system/init-settings.rb b/tests/system/init-settings.rb new file mode 100644 index 00000000..e12fd28d --- /dev/null +++ b/tests/system/init-settings.rb @@ -0,0 +1,10 @@ +describe '/system/init-settings' do + it 'should initialize correctly' do + result = request('/system/init-settings') + + lang = $database.getRow('setting', 'language', 'name') + + (result['status']).should.equal('success') + (lang['value']).should.equal('en') + end +end \ No newline at end of file