Commit a24f5e10 authored by Vipul Basapati's avatar Vipul Basapati

Added update validation for same name in BlogTag

parent 7c23cfb6
......@@ -66,7 +66,7 @@ class BlogCategoriesController extends Controller
* @param \App\Models\BlogCategories\BlogCategory $blogCategory
* @param \App\Http\Requests\Backend\BlogCategories\EditBlogCategoriesRequest $request
*
* @return mixed
* @return \App\Http\Responses\Backend\BlogCategory\EditResponse
*/
public function edit(BlogCategory $blogCategory, EditBlogCategoriesRequest $request)
{
......
......@@ -27,7 +27,7 @@ class UpdateBlogTagsRequest extends Request
public function rules()
{
return [
'name' => 'required|max:191',
'name' => 'required|max:191|unique:blog_tags,name,' . $this->segment(3)
];
}
......
......@@ -76,4 +76,17 @@ class ManageBlogTagsTest extends TestCase
$this->assertDatabaseMissing(config('module.blog_tags.table'), ['name' => $tag->name, 'id' => $tag->id, 'deleted_at' => null]);
}
/** @test */
public function a_user_can_not_update_a_blog_tag_with_same_name()
{
$this->actingAs($this->admin)->withExceptionHandling();
$catTag = create(BlogTag::class, ['name' => 'Cat']);
$dogTag = create(BlogTag::class, ['name' => 'Dog']);
$this->patch(route('admin.blogTags.update', $dogTag),
['name' => 'Cat']
)->assertSessionHasErrors('name');
}
}
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