@@ -0,0 +1,42 | |||||
|
1 | # Redmine - project management software | |||
|
2 | # Copyright (C) 2006-2014 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 | require File.expand_path('../../../test_helper', __FILE__) | |||
|
19 | ||||
|
20 | class GroupsHelperTest < ActionView::TestCase | |||
|
21 | include Redmine::I18n | |||
|
22 | include ERB::Util | |||
|
23 | include GroupsHelper | |||
|
24 | ||||
|
25 | fixtures :users | |||
|
26 | ||||
|
27 | def test_render_principals_for_new_group_users | |||
|
28 | group = Group.generate! | |||
|
29 | ||||
|
30 | result = render_principals_for_new_group_users(group) | |||
|
31 | assert_select_in result, 'input[name=?][value=2]', 'user_ids[]' | |||
|
32 | end | |||
|
33 | ||||
|
34 | def test_render_principals_for_new_group_users_with_limited_results_should_paginate | |||
|
35 | group = Group.generate! | |||
|
36 | ||||
|
37 | result = render_principals_for_new_group_users(group, 3) | |||
|
38 | assert_select_in result, 'p.pagination' | |||
|
39 | assert_select_in result, 'span.current.page', :text => '1' | |||
|
40 | assert_select_in result, 'a[href=?]', "/groups/#{group.id}/autocomplete_for_user.js?page=2", :text => '2' | |||
|
41 | end | |||
|
42 | end |
@@ -0,0 +1,42 | |||||
|
1 | # Redmine - project management software | |||
|
2 | # Copyright (C) 2006-2014 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 | require File.expand_path('../../../test_helper', __FILE__) | |||
|
19 | ||||
|
20 | class MembersHelperTest < ActionView::TestCase | |||
|
21 | include Redmine::I18n | |||
|
22 | include ERB::Util | |||
|
23 | include MembersHelper | |||
|
24 | ||||
|
25 | fixtures :projects, :users, :members, :member_roles | |||
|
26 | ||||
|
27 | def test_render_principals_for_new_members | |||
|
28 | project = Project.generate! | |||
|
29 | ||||
|
30 | result = render_principals_for_new_members(project) | |||
|
31 | assert_select_in result, 'input[name=?][value=2]', 'membership[user_ids][]' | |||
|
32 | end | |||
|
33 | ||||
|
34 | def test_render_principals_for_new_members_with_limited_results_should_paginate | |||
|
35 | project = Project.generate! | |||
|
36 | ||||
|
37 | result = render_principals_for_new_members(project, 3) | |||
|
38 | assert_select_in result, 'p.pagination' | |||
|
39 | assert_select_in result, 'span.current.page', :text => '1' | |||
|
40 | assert_select_in result, 'a[href=?]', "/projects/#{project.identifier}/memberships/autocomplete.js?page=2", :text => '2' | |||
|
41 | end | |||
|
42 | end |
@@ -26,10 +26,10 module GroupsHelper | |||||
26 | tabs |
|
26 | tabs | |
27 | end |
|
27 | end | |
28 |
|
28 | |||
29 | def render_principals_for_new_group_users(group) |
|
29 | def render_principals_for_new_group_users(group, limit=100) | |
30 | scope = User.active.sorted.not_in_group(group).like(params[:q]) |
|
30 | scope = User.active.sorted.not_in_group(group).like(params[:q]) | |
31 | principal_count = scope.count |
|
31 | principal_count = scope.count | |
32 |
principal_pages = Redmine::Pagination::Paginator.new principal_count, |
|
32 | principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] | |
33 | principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a |
|
33 | principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a | |
34 |
|
34 | |||
35 | s = content_tag('div', |
|
35 | s = content_tag('div', |
@@ -18,10 +18,10 | |||||
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 |
|
19 | |||
20 | module MembersHelper |
|
20 | module MembersHelper | |
21 | def render_principals_for_new_members(project) |
|
21 | def render_principals_for_new_members(project, limit=100) | |
22 | scope = Principal.active.visible.sorted.not_member_of(project).like(params[:q]) |
|
22 | scope = Principal.active.visible.sorted.not_member_of(project).like(params[:q]) | |
23 | principal_count = scope.count |
|
23 | principal_count = scope.count | |
24 |
principal_pages = Redmine::Pagination::Paginator.new principal_count, |
|
24 | principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] | |
25 | principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a |
|
25 | principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a | |
26 |
|
26 | |||
27 | s = content_tag('div', |
|
27 | s = content_tag('div', |
General Comments 0
You need to be logged in to leave comments.
Login now