##// END OF EJS Templates
Adds name filter on group list....
Jean-Philippe Lang -
r15375:52fbcebb6dfd
parent child
Show More
@@ -1,28 +1,39
1 1 <div class="contextual">
2 2 <%= link_to l(:label_group_new), new_group_path, :class => 'icon icon-add' %>
3 3 </div>
4 4
5 5 <%= title l(:label_group_plural) %>
6
7 <%= form_tag(groups_path, :method => :get) do %>
8 <fieldset><legend><%= l(:label_filter_plural) %></legend>
9 <label for='name'><%= l(:label_group) %>:</label>
10 <%= text_field_tag 'name', params[:name], :size => 30 %>
11 <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
12 <%= link_to l(:button_clear), groups_path, :class => 'icon icon-reload' %>
13 </fieldset>
14 <% end %>
15 &nbsp;
16
6 17 <% if @groups.any? %>
7 18 <div class="autoscroll">
8 19 <table class="list groups">
9 20 <thead><tr>
10 21 <th><%=l(:label_group)%></th>
11 22 <th><%=l(:label_user_plural)%></th>
12 23 <th></th>
13 24 </tr></thead>
14 25 <tbody>
15 26 <% @groups.each do |group| %>
16 27 <tr id="group-<%= group.id %>" class="<%= cycle 'odd', 'even' %> <%= "builtin" if group.builtin? %>">
17 28 <td class="name"><%= link_to group, edit_group_path(group) %></td>
18 29 <td class="user_count"><%= (@user_count_by_group_id[group.id] || 0) unless group.builtin? %></td>
19 30 <td class="buttons"><%= delete_link group unless group.builtin? %></td>
20 31 </tr>
21 32 <% end %>
22 33 </tbody>
23 34 </table>
24 35 </div>
25 36 <span class="pagination"><%= pagination_links_full @group_pages, @group_count %></span>
26 37 <% else %>
27 38 <p class="nodata"><%= l(:label_no_data) %></p>
28 39 <% end %>
@@ -1,159 +1,168
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2016 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class GroupsControllerTest < Redmine::ControllerTest
21 21 fixtures :projects, :users, :members, :member_roles, :roles, :groups_users
22 22
23 23 def setup
24 24 @request.session[:user_id] = 1
25 25 end
26 26
27 27 def test_index
28 28 get :index
29 29 assert_response :success
30 30 assert_select 'table.groups'
31 31 end
32 32
33 33 def test_index_should_show_user_count
34 34 get :index
35 35 assert_response :success
36 36 assert_select 'tr#group-11 td.user_count', :text => '1'
37 37 end
38 38
39 def test_index_with_name_filter
40 Group.generate!(:name => "Clients")
41
42 get :index, :name => "cli"
43 assert_response :success
44 assert_select 'table.groups tbody tr', 1
45 assert_select 'table.groups tbody td.name', :text => 'Clients'
46 end
47
39 48 def test_show
40 49 get :show, :id => 10
41 50 assert_response :success
42 51 end
43 52
44 53 def test_show_invalid_should_return_404
45 54 get :show, :id => 99
46 55 assert_response 404
47 56 end
48 57
49 58 def test_new
50 59 get :new
51 60 assert_response :success
52 61 assert_select 'input[name=?]', 'group[name]'
53 62 end
54 63
55 64 def test_create
56 65 assert_difference 'Group.count' do
57 66 post :create, :group => {:name => 'New group'}
58 67 end
59 68 assert_redirected_to '/groups'
60 69 group = Group.order('id DESC').first
61 70 assert_equal 'New group', group.name
62 71 assert_equal [], group.users
63 72 end
64 73
65 74 def test_create_and_continue
66 75 assert_difference 'Group.count' do
67 76 post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
68 77 end
69 78 assert_redirected_to '/groups/new'
70 79 group = Group.order('id DESC').first
71 80 assert_equal 'New group', group.name
72 81 end
73 82
74 83 def test_create_with_failure
75 84 assert_no_difference 'Group.count' do
76 85 post :create, :group => {:name => ''}
77 86 end
78 87 assert_response :success
79 88 assert_select_error /Name cannot be blank/i
80 89 end
81 90
82 91 def test_edit
83 92 get :edit, :id => 10
84 93 assert_response :success
85 94
86 95 assert_select 'div#tab-content-users'
87 96 assert_select 'div#tab-content-memberships' do
88 97 assert_select 'a', :text => 'Private child of eCookbook'
89 98 end
90 99 end
91 100
92 101 def test_update
93 102 new_name = 'New name'
94 103 put :update, :id => 10, :group => {:name => new_name}
95 104 assert_redirected_to '/groups'
96 105 group = Group.find(10)
97 106 assert_equal new_name, group.name
98 107 end
99 108
100 109 def test_update_with_failure
101 110 put :update, :id => 10, :group => {:name => ''}
102 111 assert_response :success
103 112 assert_select_error /Name cannot be blank/i
104 113 end
105 114
106 115 def test_destroy
107 116 assert_difference 'Group.count', -1 do
108 117 post :destroy, :id => 10
109 118 end
110 119 assert_redirected_to '/groups'
111 120 end
112 121
113 122 def test_new_users
114 123 get :new_users, :id => 10
115 124 assert_response :success
116 125 assert_select 'input[name=?]', 'user_search'
117 126 end
118 127
119 128 def test_xhr_new_users
120 129 xhr :get, :new_users, :id => 10
121 130 assert_response :success
122 131 assert_equal 'text/javascript', response.content_type
123 132 end
124 133
125 134 def test_add_users
126 135 assert_difference 'Group.find(10).users.count', 2 do
127 136 post :add_users, :id => 10, :user_ids => ['2', '3']
128 137 end
129 138 end
130 139
131 140 def test_xhr_add_users
132 141 assert_difference 'Group.find(10).users.count', 2 do
133 142 xhr :post, :add_users, :id => 10, :user_ids => ['2', '3']
134 143 assert_response :success
135 144 assert_equal 'text/javascript', response.content_type
136 145 end
137 146 assert_match /John Smith/, response.body
138 147 end
139 148
140 149 def test_remove_user
141 150 assert_difference 'Group.find(10).users.count', -1 do
142 151 delete :remove_user, :id => 10, :user_id => '8'
143 152 end
144 153 end
145 154
146 155 def test_xhr_remove_user
147 156 assert_difference 'Group.find(10).users.count', -1 do
148 157 xhr :delete, :remove_user, :id => 10, :user_id => '8'
149 158 assert_response :success
150 159 assert_equal 'text/javascript', response.content_type
151 160 end
152 161 end
153 162
154 163 def test_autocomplete_for_user
155 164 xhr :get, :autocomplete_for_user, :id => 10, :q => 'smi', :format => 'js'
156 165 assert_response :success
157 166 assert_include 'John Smith', response.body
158 167 end
159 168 end
General Comments 0
You need to be logged in to leave comments. Login now