From aca71c076c2bdde062647638e89fa449f249d4e5 Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Fri, 10 Aug 2018 19:15:51 +0900 Subject: [PATCH] [phase-18]Add destroy action test for GlossaryCategoriesController, and fix redirect_to action --- app/controllers/glossary_categories_controller.rb | 2 +- test/functional/glossary_categories_controller_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/glossary_categories_controller.rb b/app/controllers/glossary_categories_controller.rb index be5289c..78e57d9 100644 --- a/app/controllers/glossary_categories_controller.rb +++ b/app/controllers/glossary_categories_controller.rb @@ -36,7 +36,7 @@ class GlossaryCategoriesController < ApplicationController def destroy @category.destroy - redirect_to project_glossary_categories_path + redirect_to project_glossary_categories_path(@project) end # Find the category whose id is the :id parameter diff --git a/test/functional/glossary_categories_controller_test.rb b/test/functional/glossary_categories_controller_test.rb index 27cfc1e..a55a47c 100644 --- a/test/functional/glossary_categories_controller_test.rb +++ b/test/functional/glossary_categories_controller_test.rb @@ -47,4 +47,11 @@ class GlossaryCategoriesControllerTest < ActionController::TestCase assert_not_nil category assert_redirected_to project_glossary_category_path(@project, category) end + + def test_destroy + @request.session[:user_id] = users('users_002').id + delete :destroy, params: { id: 1, project_id: 1 } + assert_raise(ActiveRecord::RecordNotFound) { GlossaryCategory.find(1) } + assert_redirected_to project_glossary_categories_path(@project) + end end