From ea7ada3027470fa69bb44661e05a736e2c01f1a6 Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Fri, 10 Aug 2018 05:10:46 +0900 Subject: [PATCH] [phase-18]Add new/create action test for GlossaryCategoriesController --- .../glossary_categories_controller_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/functional/glossary_categories_controller_test.rb b/test/functional/glossary_categories_controller_test.rb index 1fcd01d..27cfc1e 100644 --- a/test/functional/glossary_categories_controller_test.rb +++ b/test/functional/glossary_categories_controller_test.rb @@ -30,4 +30,21 @@ class GlossaryCategoriesControllerTest < ActionController::TestCase assert_redirected_to project_glossary_category_path(@project, category) assert_equal 'Colour', category.name end + + def test_new + @request.session[:user_id] = users('users_002').id + get :new, params: {id: 1, project_id: 1} + assert_response :success + assert_select 'form', true + end + + def test_create + @request.session[:user_id] = users('users_002').id + post :create, params: { + project_id: 1, glossary_category: {name: 'Material'} + } + category = GlossaryCategory.find_by(name: 'Material') + assert_not_nil category + assert_redirected_to project_glossary_category_path(@project, category) + end end