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
{
$featured_image = ($action == 'insert') ? 'required' : '';
$publish_datetime = $request->publish_datetime !== '' ? 'required|date' : 'required';
$validation = Validator::make($request->all(), [
'name' => 'required|max:191',
'featured_image' => $featured_image,
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
'name' => 'required|max:191',
'featured_image' => $featured_image,
'publish_datetime' => $publish_datetime,
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
]);
return $validation;
......
......@@ -27,11 +27,12 @@ class StoreBlogsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'featured_image' => 'required',
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
'name' => 'required|max:191',
'featured_image' => 'required',
'publish_datetime' => 'required|date',
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
];
}
......
......@@ -27,10 +27,11 @@ class UpdateBlogsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191|unique:blogs,name,'.$this->segment(3),
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
'name' => 'required|max:191|unique:blogs,name,'.$this->segment(3),
'publish_datetime' => 'required|date',
'content' => 'required',
'categories' => 'required',
'tags' => 'required',
];
}
......
......@@ -30,7 +30,7 @@ class UpdateProfileRequest extends Request
return [
'first_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 [
'blogs' => [
'title' => 'Blog Title',
'category' => 'Blog Category',
'publish' => 'Publich Date & Time',
'publish' => 'Publish Date & Time',
'image' => 'Featured Image',
'content' => 'Content',
'tags' => 'Tags',
......
......@@ -100,6 +100,17 @@ class ManageBlogsTest extends TestCase
->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 */
public function it_requires_categories_while_creating()
{
......@@ -156,6 +167,17 @@ class ManageBlogsTest extends TestCase
->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 */
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