1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Merge pull request #9737 from turbo124/v5-develop

v5.10.5
This commit is contained in:
David Bomba 2024-07-08 09:47:50 +10:00 committed by GitHub
commit 75a7378c2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 118 additions and 6 deletions

View File

@ -1 +1 @@
5.10.4
5.10.5

View File

@ -80,8 +80,8 @@ class StoreProjectRequest extends Request
$input['budgeted_hours'] = 0;
}
$input['task_rate'] = isset($input['task_rate']) ? $input['task_rate'] : 0;
$input['task_rate'] = (isset($input['task_rate']) && floatval($input['task_rate']) >= 0) ? $input['task_rate'] : 0;
$this->replace($input);
}

View File

@ -45,7 +45,8 @@ class UpdateProjectRequest extends Request
$rules['number'] = Rule::unique('projects')->where('company_id', $user->company()->id)->ignore($this->project->id);
}
$rules['budgeted_hours'] = 'sometimes|numeric';
$rules['budgeted_hours'] = 'sometimes|bail|numeric';
$rules['task_rate'] = 'sometimes|bail|numeric';
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->fileValidation();

View File

@ -17,8 +17,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => env('APP_VERSION', '5.10.4'),
'app_tag' => env('APP_TAG', '5.10.4'),
'app_version' => env('APP_VERSION', '5.10.5'),
'app_tag' => env('APP_TAG', '5.10.5'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),

View File

@ -47,6 +47,117 @@ class ProjectApiTest extends TestCase
Model::reguard();
}
public function testCreateProjectWithNullTaskRate()
{
$data = [
'client_id' => $this->client->hashed_id,
'name' => 'howdy',
'task_rate' => null,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson("/api/v1/projects", $data);
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals(0, $arr['data']['task_rate']);
}
public function testCreateProjectWithNullTaskRate2()
{
$data = [
'client_id' => $this->client->hashed_id,
'name' => 'howdy',
'task_rate' => "A",
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson("/api/v1/projects", $data);
$response->assertStatus(422);
$arr = $response->json();
}
public function testCreateProjectWithNullTaskRate3()
{
$data = [
'client_id' => $this->client->hashed_id,
'name' => 'howdy',
'task_rate' => "10",
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson("/api/v1/projects", $data);
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals(10, $arr['data']['task_rate']);
}
public function testCreateProjectWithNullTaskRate5()
{
$data = [
'client_id' => $this->client->hashed_id,
'name' => 'howdy',
'task_rate' => "-10",
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson("/api/v1/projects", $data);
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals(0, $arr['data']['task_rate']);
}
public function testCreateProjectWithNullTaskRate4()
{
$data = [
'client_id' => $this->client->hashed_id,
'name' => 'howdy',
'task_rate' => 10,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson("/api/v1/projects", $data);
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals(10, $arr['data']['task_rate']);
}
public function testProjectIncludesZeroCount()
{