Ivan - Fix issues with mail templating and add it to ruby tests [skip ci]

This commit is contained in:
ivan 2016-07-27 00:44:07 -03:00
parent 4ccbd75759
commit 3f01526814
6 changed files with 18 additions and 6 deletions

View File

@ -12,7 +12,7 @@ class MailTemplate extends DataStore {
$bean = RedBean::findOne(MailTemplate::TABLE, 'type = :type AND language = :language', array( $bean = RedBean::findOne(MailTemplate::TABLE, 'type = :type AND language = :language', array(
':type' => $type, ':type' => $type,
':language' => $globalLanguage ':language' => $globalLanguage->value
)); ));
return ($bean) ? new MailTemplate($bean) : null; return ($bean) ? new MailTemplate($bean) : null;
@ -22,6 +22,7 @@ class MailTemplate extends DataStore {
return [ return [
'type', 'type',
'subject', 'subject',
'language',
'body' 'body'
]; ];
} }

View File

@ -4,7 +4,7 @@ class Setting extends DataStore {
const TABLE = 'setting'; const TABLE = 'setting';
public static function getSetting($name) { public static function getSetting($name) {
return parent::getDataStore('name', $name); return parent::getDataStore($name, 'name');
} }
public static function getProps() { public static function getProps() {

View File

@ -5,7 +5,7 @@ include_once 'tests/__mocks__/ResponseMock.php';
include_once 'tests/__mocks__/ControllerMock.php'; include_once 'tests/__mocks__/ControllerMock.php';
include_once 'tests/__mocks__/SessionMock.php'; include_once 'tests/__mocks__/SessionMock.php';
include_once 'tests/__mocks__/UserMock.php'; include_once 'tests/__mocks__/UserMock.php';
include_once 'models/ERRORS.php'; include_once 'data/ERRORS.php';
include_once 'controllers/user/login.php'; include_once 'controllers/user/login.php';

View File

@ -8,6 +8,7 @@ require './libs.rb'
require './scripts.rb' require './scripts.rb'
# TESTS # TESTS
require './system/init-settings.rb'
require './user/signup.rb' require './user/signup.rb'
require './user/login.rb' require './user/login.rb'
require './user/send-recover-password.rb' require './user/send-recover-password.rb'

View File

@ -1,5 +1,5 @@
def request(path, data) def request(path, data = {})
uri = URI('http://localhost:8080' + path) uri = URI('http://localhost:8080' + path)
response = Net::HTTP.post_form(uri, data) response = Net::HTTP.post_form(uri, data)
@ -8,8 +8,8 @@ end
class Database class Database
def initialize() def initialize()
mysqlUser = ENV['MYSQL_USER'] || 'root'; mysqlUser = ENV['MYSQL_USER'] || 'root'
mysqlPass = ENV['MYSQL_PASSWORD'] || ''; mysqlPass = ENV['MYSQL_PASSWORD'] || ''
@connection = Mysql.new('localhost', mysqlUser , mysqlPass, 'development') @connection = Mysql.new('localhost', mysqlUser , mysqlPass, 'development')
end end

View File

@ -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