Project API and globalActivities flag (#3564)
* expose globalActivities setting in project entity * fix globalActivities being true by default if created via API
This commit is contained in:
@@ -433,6 +433,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
'billable' => 'bool',
|
||||
'color' => '@string',
|
||||
'customer' => 'int',
|
||||
'globalActivities' => 'bool',
|
||||
'comment' => '@string',
|
||||
];
|
||||
|
||||
@@ -445,6 +446,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
'billable' => 'bool',
|
||||
'color' => '@string',
|
||||
'customer' => ['result' => 'object', 'type' => 'Customer'],
|
||||
'globalActivities' => 'bool',
|
||||
'comment' => '@string',
|
||||
];
|
||||
|
||||
@@ -461,6 +463,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
'parentTitle' => 'string',
|
||||
'start' => '@datetime',
|
||||
'end' => '@datetime',
|
||||
'globalActivities' => 'bool',
|
||||
'teams' => ['result' => 'array', 'type' => 'Team'],
|
||||
'comment' => '@string',
|
||||
];
|
||||
@@ -478,6 +481,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
'parentTitle' => 'string',
|
||||
'start' => '@datetime',
|
||||
'end' => '@datetime',
|
||||
'globalActivities' => 'bool',
|
||||
'teams' => ['result' => 'array', 'type' => 'Team'],
|
||||
'comment' => '@string',
|
||||
'budget' => 'float',
|
||||
|
||||
@@ -298,12 +298,51 @@ class ProjectControllerTest extends APIControllerBaseTest
|
||||
$this->assertIsArray($result);
|
||||
self::assertApiResponseTypeStructure('ProjectEntity', $result);
|
||||
$this->assertNotEmpty($result['id']);
|
||||
self::assertTrue($result['globalActivities']);
|
||||
self::assertEquals('2018-02-08T13:02:54+0000', $result['orderDate']);
|
||||
self::assertEquals('2019-02-01T19:32:17+0000', $result['start']);
|
||||
self::assertEquals('2020-02-08T21:11:42+0000', $result['end']);
|
||||
self::assertEquals('1234567890/WXYZ/SUBPROJECT/1234/CONTRACT/EMPLOYEE1', $result['orderNumber']);
|
||||
}
|
||||
|
||||
public function testPostActionWithOtherFields()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$data = [
|
||||
'name' => 'foo',
|
||||
'customer' => 1,
|
||||
'globalActivities' => '0',
|
||||
];
|
||||
$this->request($client, '/api/projects', 'POST', [], json_encode($data));
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
$this->assertIsArray($result);
|
||||
self::assertApiResponseTypeStructure('ProjectEntity', $result);
|
||||
$this->assertNotEmpty($result['id']);
|
||||
self::assertEquals('foo', $result['name']);
|
||||
self::assertFalse($result['globalActivities']);
|
||||
}
|
||||
|
||||
public function testPostActionWithOtherFields2()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$data = [
|
||||
'name' => 'foo',
|
||||
'customer' => 1,
|
||||
'globalActivities' => '1',
|
||||
];
|
||||
$this->request($client, '/api/projects', 'POST', [], json_encode($data));
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
$this->assertIsArray($result);
|
||||
self::assertApiResponseTypeStructure('ProjectEntity', $result);
|
||||
$this->assertNotEmpty($result['id']);
|
||||
self::assertEquals('foo', $result['name']);
|
||||
self::assertTrue($result['globalActivities']);
|
||||
}
|
||||
|
||||
public function testPostActionWithLeastFields()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
|
||||
Reference in New Issue
Block a user