Skip to content

Commit

Permalink
Category parent_id can be non=present or null
Browse files Browse the repository at this point in the history
  • Loading branch information
rowasc committed May 22, 2020
1 parent 3dcc21e commit c295f2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion tests/integration/v4/tags.v4.feature
Expand Up @@ -206,7 +206,7 @@ Feature: Testing the Categories API
And the "parent_id.0" property equals "Parent category must exist"
Then the guzzle status code should be 422

Scenario: Creating a tag with empty parent_id works
Scenario: Creating a tag with no parent_id works
Given that I want to make a new "Category"
And that the oauth token is "testadminuser"
And that the api_url is "api/v4"
Expand All @@ -225,6 +225,25 @@ Feature: Testing the Categories API
Then the response is JSON
Then the guzzle status code should be 201

Scenario: Creating a tag with empty parent_id works
Given that I want to make a new "Category"
And that the oauth token is "testadminuser"
And that the api_url is "api/v4"
And that the request "data" is:
"""
{
"parent_id": null,
"tag":"I expect a tag to be here",
"description":"Is this a box? Awesome",
"type":"category",
"priority":1,
"color":"#00ff00",
"role": ["admin", "user"]
}
"""
When I request "/categories"
Then the response is JSON
Then the guzzle status code should be 201
Scenario: Updating a Tag
Given that I want to update a "Category"
And that the oauth token is "testadminuser"
Expand Down
2 changes: 1 addition & 1 deletion v4/Models/Category.php
Expand Up @@ -158,7 +158,7 @@ public static function validationMessages()
public function getRules()
{
return [
'parent_id' => 'sometimes|exists:tags,id',
'parent_id' => 'nullable|sometimes|exists:tags,id',
'tag' => [
'required',
'min:2',
Expand Down

0 comments on commit c295f2a

Please sign in to comment.