/** * * @param Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $tag = new Tag(['name' => $request->get('name'), 'for' => 'recipe']); $tag->user()->associate(Auth::user()); $tag->save(); return $this->responseCreatedWithTransformer($tag, new TagTransformer()); }
/** * @test * @return void */ public function it_can_delete_an_recipe_tag() { $this->logInUser(); $tag = new Tag(['name' => 'echidna', 'for' => 'recipe']); $tag->user()->associate($this->user); $tag->save(); $this->seeInDatabase('tags', ['name' => 'echidna']); $response = $this->call('DELETE', '/api/recipeTags/' . $tag->id); $this->assertEquals(204, $response->getStatusCode()); $this->missingFromDatabase('tags', ['name' => 'echidna']); // // @TODO Test the 404 for the other methods as well (show, update) $response = $this->call('DELETE', '/api/recipeTags/' . $tag->id); $this->assertEquals(404, $response->getStatusCode()); }