diff --git a/src/humulus/recipes.py b/src/humulus/recipes.py index d79c78a..9632c43 100644 --- a/src/humulus/recipes.py +++ b/src/humulus/recipes.py @@ -196,3 +196,10 @@ def create(): @bp.route('/info/') def info(id): return render_template('recipes/info.html', recipe=get_doc_or_404(id)) + + +@bp.route('/delete/', methods=('POST',)) +def delete(id): + recipe = get_doc_or_404(id) + recipe.delete() + return redirect(url_for('home.index')) diff --git a/tests/test_recipes.py b/tests/test_recipes.py index 1d4be02..79b35e1 100644 --- a/tests/test_recipes.py +++ b/tests/test_recipes.py @@ -162,3 +162,13 @@ def test_recipe_form_doc(app): 'high_attenuation': '75' } } + + +def test_recipe_delete(client): + """Test success in deleting a document.""" + response = client.post('/recipes/delete/awesome-lager') + assert response.status_code == 302 + + # Try to get the doc now + response = client.get('/recipes/info/awesome-lager') + assert response.status_code == 404