Commit 77e4e5fe authored by Florian Azizian's avatar Florian Azizian

FIX #11270 TIME 0:30 return custom field id in creation

parent 24a7d4f4
...@@ -47,13 +47,13 @@ class CustomFieldController ...@@ -47,13 +47,13 @@ class CustomFieldController
return $response->withStatus(400)->withJson(['errors' => 'Custom field with this label already exists']); return $response->withStatus(400)->withJson(['errors' => 'Custom field with this label already exists']);
} }
CustomFieldModel::create([ $id = CustomFieldModel::create([
'label' => $body['label'], 'label' => $body['label'],
'type' => $body['type'], 'type' => $body['type'],
'values' => empty($body['values']) ? null : json_encode($body['values']) 'values' => empty($body['values']) ? null : json_encode($body['values'])
]); ]);
return $response->withStatus(204); return $response->withStatus(204)->withJson(['customFieldId' => $id]);
} }
public function update(Request $request, Response $response, array $args) public function update(Request $request, Response $response, array $args)
......
...@@ -30,17 +30,11 @@ class CustomFieldControllerTest extends TestCase ...@@ -30,17 +30,11 @@ class CustomFieldControllerTest extends TestCase
$response = $customFieldController->create($fullRequest, new \Slim\Http\Response()); $response = $customFieldController->create($fullRequest, new \Slim\Http\Response());
$this->assertSame(204, $response->getStatusCode()); $this->assertSame(204, $response->getStatusCode());
$responseBody = json_decode((string)$response->getBody());
$field = \CustomField\models\CustomFieldModel::get([ $this->assertInternalType('int', $responseBody->customFieldId);
'select' => ['id'], 'where' => ['label = ?'], 'data' => ['mon custom'], 'limit' => 1, 'orderBy' => ['id DESC']
]);
self::$id = $field[0]['id'];
$field = \CustomField\models\CustomFieldModel::getById(['id' => self::$id]);
$this->assertSame('mon custom', $field['label']);
$this->assertSame('select', $field['type']);
self::$id = $responseBody->customFieldId;
// Errors // Errors
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']); $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment