[phase-18]Add destroy action test for GlossaryCategoriesController, and fix redirect_to action

This commit is contained in:
Toru Takahashi 2018-08-10 19:15:51 +09:00 committed by TAKAHASHI,Toru
parent ea7ada3027
commit aca71c076c
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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