From 5c60a4f6ca92051850ec86a7cad6e12d2b7451ac Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 28 Nov 2011 17:46:21 +0000 Subject: [PATCH] Adds functional tests for GroupsController. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7968 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/groups_controller_test.rb | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb index c28ebbdea..158bf7d95 100644 --- a/test/functional/groups_controller_test.rb +++ b/test/functional/groups_controller_test.rb @@ -55,6 +55,9 @@ class GroupsControllerTest < ActionController::TestCase post :create, :group => {:lastname => 'New group'} end assert_redirected_to '/groups' + group = Group.first(:order => 'id DESC') + assert_equal 'New group', group.name + assert_equal [], group.users end def test_create_and_continue @@ -62,6 +65,16 @@ class GroupsControllerTest < ActionController::TestCase post :create, :group => {:lastname => 'New group'}, :continue => 'Create and continue' end assert_redirected_to '/groups/new' + group = Group.first(:order => 'id DESC') + assert_equal 'New group', group.name + end + + def test_create_with_failure + assert_no_difference 'Group.count' do + post :create, :group => {:lastname => ''} + end + assert_response :success + assert_template 'new' end def test_edit @@ -71,8 +84,17 @@ class GroupsControllerTest < ActionController::TestCase end def test_update - post :update, :id => 10 + new_name = 'New name' + put :update, :id => 10, :group => {:lastname => new_name} assert_redirected_to '/groups' + group = Group.find(10) + assert_equal new_name, group.name + end + + def test_update_with_failure + put :update, :id => 10, :group => {:lastname => ''} + assert_response :success + assert_template 'edit' end def test_destroy -- 2.39.5