Skip to content

Commit

Permalink
Not validating created and modified fields in baked tables, fixes #3464
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 10, 2014
1 parent 1572434 commit cee14ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Console/Command/Task/ModelTask.php
Expand Up @@ -412,7 +412,7 @@ public function getValidation($model) {
*/
public function fieldValidation($fieldName, array $metaData, $primaryKey) {
$ignoreFields = array_merge($primaryKey, ['created', 'modified', 'updated']);
if ($metaData['null'] === true && in_array($fieldName, $ignoreFields)) {
if (in_array($fieldName, $ignoreFields)) {
return false;
}

Expand Down
11 changes: 10 additions & 1 deletion tests/TestCase/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -423,13 +423,22 @@ public function testGetValidation() {
$model = TableRegistry::get('BakeArticles');
$result = $this->Task->getValidation($model);
$expected = [
'id' => ['rule' => 'numeric', 'allowEmpty' => 'create'],
'bake_user_id' => ['rule' => 'numeric', 'allowEmpty' => false],
'title' => ['rule' => false, 'allowEmpty' => false],
'body' => ['rule' => false, 'allowEmpty' => true],
'published' => ['rule' => 'boolean', 'allowEmpty' => true],
];
$this->assertEquals($expected, $result);

$model = TableRegistry::get('BakeComments');
$result = $this->Task->getValidation($model);
$expected = [
'bake_article_id' => ['rule' => 'numeric', 'allowEmpty' => false],
'bake_user_id' => ['rule' => 'numeric', 'allowEmpty' => false],
'comment' => ['rule' => false, 'allowEmpty' => true],
'published' => ['rule' => false,'allowEmpty' => true]
];
$this->assertEquals($expected, $result);
}

/**
Expand Down

0 comments on commit cee14ac

Please sign in to comment.