Commit 11cebefc authored by Vipul Basapati's avatar Vipul Basapati

Modified the Blogs Request on web and api to check for publish_datetime #250

Fixed style CI issues
parent 0191fac8
...@@ -121,12 +121,15 @@ class BlogsController extends APIController ...@@ -121,12 +121,15 @@ class BlogsController extends APIController
{ {
$featured_image = ($action == 'insert') ? 'required' : ''; $featured_image = ($action == 'insert') ? 'required' : '';
$publish_datetime = $request->publish_datetime !== '' ? 'required|date' : 'required';
$validation = Validator::make($request->all(), [ $validation = Validator::make($request->all(), [
'name' => 'required|max:191', 'name' => 'required|max:191',
'featured_image' => $featured_image, 'featured_image' => $featured_image,
'content' => 'required', 'publish_datetime' => $publish_datetime,
'categories' => 'required', 'content' => 'required',
'tags' => 'required', 'categories' => 'required',
'tags' => 'required',
]); ]);
return $validation; return $validation;
......
...@@ -27,11 +27,12 @@ class StoreBlogsRequest extends Request ...@@ -27,11 +27,12 @@ class StoreBlogsRequest extends Request
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|max:191', 'name' => 'required|max:191',
'featured_image' => 'required', 'featured_image' => 'required',
'content' => 'required', 'publish_datetime' => 'required|date',
'categories' => 'required', 'content' => 'required',
'tags' => 'required', 'categories' => 'required',
'tags' => 'required',
]; ];
} }
......
...@@ -27,10 +27,11 @@ class UpdateBlogsRequest extends Request ...@@ -27,10 +27,11 @@ class UpdateBlogsRequest extends Request
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|max:191|unique:blogs,name,'.$this->segment(3), 'name' => 'required|max:191|unique:blogs,name,'.$this->segment(3),
'content' => 'required', 'publish_datetime' => 'required|date',
'categories' => 'required', 'content' => 'required',
'tags' => 'required', 'categories' => 'required',
'tags' => 'required',
]; ];
} }
......
...@@ -30,7 +30,7 @@ class UpdateProfileRequest extends Request ...@@ -30,7 +30,7 @@ class UpdateProfileRequest extends Request
return [ return [
'first_name' => 'required|max:255', 'first_name' => 'required|max:255',
'last_name' => 'required|max:255', 'last_name' => 'required|max:255',
'email' => ['sometimes', 'required', 'email', 'max:255', Rule::unique('users')] 'email' => ['sometimes', 'required', 'email', 'max:255', Rule::unique('users')],
]; ];
} }
} }
...@@ -188,7 +188,7 @@ return [ ...@@ -188,7 +188,7 @@ return [
'blogs' => [ 'blogs' => [
'title' => 'Blog Title', 'title' => 'Blog Title',
'category' => 'Blog Category', 'category' => 'Blog Category',
'publish' => 'Publich Date & Time', 'publish' => 'Publish Date & Time',
'image' => 'Featured Image', 'image' => 'Featured Image',
'content' => 'Content', 'content' => 'Content',
'tags' => 'Tags', 'tags' => 'Tags',
......
...@@ -100,6 +100,17 @@ class ManageBlogsTest extends TestCase ...@@ -100,6 +100,17 @@ class ManageBlogsTest extends TestCase
->assertSessionHasErrors('featured_image'); ->assertSessionHasErrors('featured_image');
} }
/** @test */
public function it_requires_publish_datetime_while_creating()
{
$blog = $this->makeBlog();
unset($blog->publish_datetime);
$this->post(route('admin.blogs.store'), $blog->toArray())
->assertSessionHasErrors('publish_datetime');
}
/** @test */ /** @test */
public function it_requires_categories_while_creating() public function it_requires_categories_while_creating()
{ {
...@@ -156,6 +167,17 @@ class ManageBlogsTest extends TestCase ...@@ -156,6 +167,17 @@ class ManageBlogsTest extends TestCase
->assertSessionHasErrors('content'); ->assertSessionHasErrors('content');
} }
/** @test */
public function it_requires_publish_datetime_while_updating()
{
$this->withExceptionHandling();
unset($this->blog->publish_datetime);
$this->patch(route('admin.blogs.update', $this->blog), $this->blog->toArray())
->assertSessionHasErrors('publish_datetime');
}
/** @test */ /** @test */
public function it_requires_categories_while_updating() public function it_requires_categories_while_updating()
{ {
......
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