From b9f410b0f6c89fe3f479061a1daad1aac974434a Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Thu, 9 Aug 2018 23:46:52 +0900 Subject: [PATCH] [phase-18]Add edit/update action test for GlossaryCategoriesController --- .../glossary_categories_controller_test.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/functional/glossary_categories_controller_test.rb b/test/functional/glossary_categories_controller_test.rb index dedb052..1fcd01d 100644 --- a/test/functional/glossary_categories_controller_test.rb +++ b/test/functional/glossary_categories_controller_test.rb @@ -2,7 +2,8 @@ require File.expand_path('../../test_helper', __FILE__) class GlossaryCategoriesControllerTest < ActionController::TestCase fixtures :projects, :users, :roles, :members, :member_roles - + plugin_fixtures :glossary_categories + def setup @project = projects('projects_001') @project.enabled_module_names = [:glossary] @@ -14,4 +15,19 @@ class GlossaryCategoriesControllerTest < ActionController::TestCase get :index, params: {project_id: 1} assert_response :success end + + def test_edit + @request.session[:user_id] = users('users_002').id + get :edit, params: {id: 1, project_id: 1} + assert_response :success + assert_select 'form', true + end + + def test_update + @request.session[:user_id] = users('users_002').id + patch :update, params: {id: 1, project_id: 1, glossary_category: {name: 'Colour'}} + category = GlossaryCategory.find(1) + assert_redirected_to project_glossary_category_path(@project, category) + assert_equal 'Colour', category.name + end end