To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / test / functional / .svn / text-base / groups_controller_test.rb.svn-base @ 441:cbce1fd3b1b7

History | View | Annotate | Download (3.2 KB)

1 0:513646585e45 Chris
# Redmine - project management software
2
# Copyright (C) 2006-2009  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
18 119:8661b858af72 Chris
require File.expand_path('../../test_helper', __FILE__)
19 0:513646585e45 Chris
require 'groups_controller'
20
21
# Re-raise errors caught by the controller.
22
class GroupsController; def rescue_action(e) raise e end; end
23
24
class GroupsControllerTest < ActionController::TestCase
25
  fixtures :projects, :users, :members, :member_roles, :groups_users
26
27
  def setup
28
    @controller = GroupsController.new
29
    @request    = ActionController::TestRequest.new
30
    @response   = ActionController::TestResponse.new
31
    User.current = nil
32
    @request.session[:user_id] = 1
33
  end
34
35
  def test_index
36
    get :index
37
    assert_response :success
38
    assert_template 'index'
39
  end
40
41
  def test_show
42
    get :show, :id => 10
43
    assert_response :success
44
    assert_template 'show'
45
  end
46
47
  def test_new
48
    get :new
49
    assert_response :success
50
    assert_template 'new'
51
  end
52
53
  def test_create
54
    assert_difference 'Group.count' do
55
      post :create, :group => {:lastname => 'New group'}
56
    end
57 37:94944d00e43c chris
    assert_redirected_to '/groups'
58 0:513646585e45 Chris
  end
59
60
  def test_edit
61
    get :edit, :id => 10
62
    assert_response :success
63
    assert_template 'edit'
64
  end
65
66
  def test_update
67
    post :update, :id => 10
68 37:94944d00e43c chris
    assert_redirected_to '/groups'
69 0:513646585e45 Chris
  end
70
71
  def test_destroy
72
    assert_difference 'Group.count', -1 do
73
      post :destroy, :id => 10
74
    end
75 37:94944d00e43c chris
    assert_redirected_to '/groups'
76 0:513646585e45 Chris
  end
77
78
  def test_add_users
79
    assert_difference 'Group.find(10).users.count', 2 do
80
      post :add_users, :id => 10, :user_ids => ['2', '3']
81
    end
82
  end
83
84
  def test_remove_user
85
    assert_difference 'Group.find(10).users.count', -1 do
86
      post :remove_user, :id => 10, :user_id => '8'
87
    end
88
  end
89
90
  def test_new_membership
91
    assert_difference 'Group.find(10).members.count' do
92
      post :edit_membership, :id => 10, :membership => { :project_id => 2, :role_ids => ['1', '2']}
93
    end
94
  end
95
96
  def test_edit_membership
97
    assert_no_difference 'Group.find(10).members.count' do
98
      post :edit_membership, :id => 10, :membership_id => 6, :membership => { :role_ids => ['1', '3']}
99
    end
100
  end
101
102
  def test_destroy_membership
103
    assert_difference 'Group.find(10).members.count', -1 do
104
      post :destroy_membership, :id => 10, :membership_id => 6
105
    end
106
  end
107 441:cbce1fd3b1b7 Chris
108
  def test_autocomplete_for_user
109
    get :autocomplete_for_user, :id => 10, :q => 'mis'
110
    assert_response :success
111
    users = assigns(:users)
112
    assert_not_nil users
113
    assert users.any?
114
    assert !users.include?(Group.find(10).users.first)
115
  end
116 0:513646585e45 Chris
end