Unit tests fixed + models & routers update
This commit is contained in:
@@ -39,7 +39,6 @@ class Model extends \Sudzy\ValidModel {
|
||||
$this->setTimestamp();
|
||||
try {
|
||||
parent::save();
|
||||
return true;
|
||||
} catch(\Sudzy\ValidationException $e) {
|
||||
$this->setError($e->getValidationErrors());
|
||||
} catch(\PDOException $e) {
|
||||
@@ -47,7 +46,7 @@ class Model extends \Sudzy\ValidModel {
|
||||
} catch(\Exception $e) {
|
||||
$this->setError($e->getMessage());
|
||||
}
|
||||
return false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function trash() {
|
||||
|
@@ -32,16 +32,7 @@ class NewsletterTemplate extends Model {
|
||||
$template->set($data);
|
||||
}
|
||||
|
||||
$saved = $template->save();
|
||||
|
||||
if($saved === true) {
|
||||
return true;
|
||||
} else {
|
||||
$errors = $template->getValidationErrors();
|
||||
if(!empty($errors)) {
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
$template->save();
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
@@ -164,8 +164,7 @@ class Segment extends Model {
|
||||
$segment->set($data);
|
||||
}
|
||||
|
||||
$segment->save();
|
||||
return $segment;
|
||||
return $segment->save();
|
||||
}
|
||||
|
||||
static function getPublic() {
|
||||
|
@@ -10,8 +10,7 @@ class Setting extends Model {
|
||||
parent::__construct();
|
||||
|
||||
$this->addValidations('name', array(
|
||||
'required' => 'name_is_blank',
|
||||
'isString' => 'name_is_not_string'
|
||||
'required' => __('You need to specify a name.')
|
||||
));
|
||||
}
|
||||
|
||||
@@ -55,10 +54,11 @@ class Setting extends Model {
|
||||
$value = serialize($value);
|
||||
}
|
||||
|
||||
return Setting::createOrUpdate(array(
|
||||
$setting = Setting::createOrUpdate(array(
|
||||
'name' => $key,
|
||||
'value' => $value
|
||||
));
|
||||
return ($setting->id() > 0 && $setting->getErrors() === false);
|
||||
} else {
|
||||
$main_key = array_shift($keys);
|
||||
|
||||
@@ -101,8 +101,7 @@ class Setting extends Model {
|
||||
}
|
||||
|
||||
public static function createOrUpdate($model) {
|
||||
$exists = self::where('name', $model['name'])
|
||||
->find_one();
|
||||
$exists = self::where('name', $model['name'])->findOne();
|
||||
|
||||
if($exists === false) {
|
||||
$new_model = self::create();
|
||||
|
Reference in New Issue
Block a user