##// END OF EJS Templates
Speeds up rendering of the project list for users who belong to hundreds of projects....
Speeds up rendering of the project list for users who belong to hundreds of projects. git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15375:52fbcebb6dfd
r15741:f8df935dcada
Show More
groups_controller_test.rb
168 lines | 4.6 KiB | text/x-ruby | RubyLexer
/ test / functional / groups_controller_test.rb
Jean-Philippe Lang
User groups branch merged....
r2755 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
User groups branch merged....
r2755 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809 #
Jean-Philippe Lang
User groups branch merged....
r2755 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809 #
Jean-Philippe Lang
User groups branch merged....
r2755 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Jean-Philippe Lang
User groups branch merged....
r2755
Jean-Philippe Lang
Adds our own class for controller tests....
r15279 class GroupsControllerTest < Redmine::ControllerTest
Jean-Baptiste Barth
Fixed test/functional/groups_controller_test.rb breaking when run alone (#12285)...
r10560 fixtures :projects, :users, :members, :member_roles, :roles, :groups_users
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
User groups branch merged....
r2755 def setup
@request.session[:user_id] = 1
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
User groups branch merged....
r2755 def test_index
get :index
assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select 'table.groups'
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
Count users with a single query on group list (#16905)....
r12874 def test_index_should_show_user_count
get :index
assert_response :success
assert_select 'tr#group-11 td.user_count', :text => '1'
end
Jean-Philippe Lang
Adds name filter on group list....
r15375 def test_index_with_name_filter
Group.generate!(:name => "Clients")
get :index, :name => "cli"
assert_response :success
assert_select 'table.groups tbody tr', 1
assert_select 'table.groups tbody td.name', :text => 'Clients'
end
Jean-Philippe Lang
User groups branch merged....
r2755 def test_show
get :show, :id => 10
assert_response :success
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
Test for when group does not exist....
r9819 def test_show_invalid_should_return_404
get :show, :id => 99
assert_response 404
end
Jean-Philippe Lang
User groups branch merged....
r2755 def test_new
get :new
assert_response :success
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 assert_select 'input[name=?]', 'group[name]'
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
User groups branch merged....
r2755 def test_create
assert_difference 'Group.count' do
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 post :create, :group => {:name => 'New group'}
Jean-Philippe Lang
User groups branch merged....
r2755 end
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to '/groups'
Toshi MARUYAMA
Rails4: replace deprecated Relation#first with finder options at GroupsControllerTest...
r12233 group = Group.order('id DESC').first
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7848 assert_equal 'New group', group.name
assert_equal [], group.users
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
Adds 'Create and continue' button on the new group form....
r6184 def test_create_and_continue
assert_difference 'Group.count' do
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
Jean-Philippe Lang
Adds 'Create and continue' button on the new group form....
r6184 end
assert_redirected_to '/groups/new'
Toshi MARUYAMA
Rails4: replace deprecated Relation#first with finder options at GroupsControllerTest...
r12233 group = Group.order('id DESC').first
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7848 assert_equal 'New group', group.name
end
def test_create_with_failure
assert_no_difference 'Group.count' do
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 post :create, :group => {:name => ''}
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7848 end
assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select_error /Name cannot be blank/i
Jean-Philippe Lang
Adds 'Create and continue' button on the new group form....
r6184 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
User groups branch merged....
r2755 def test_edit
get :edit, :id => 10
assert_response :success
Jean-Philippe Lang
Add links to projects in Group projects list (#12843)....
r10953
assert_select 'div#tab-content-users'
assert_select 'div#tab-content-memberships' do
assert_select 'a', :text => 'Private child of eCookbook'
end
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
User groups branch merged....
r2755 def test_update
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7848 new_name = 'New name'
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 put :update, :id => 10, :group => {:name => new_name}
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to '/groups'
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7848 group = Group.find(10)
assert_equal new_name, group.name
end
def test_update_with_failure
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 put :update, :id => 10, :group => {:name => ''}
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7848 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select_error /Name cannot be blank/i
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
User groups branch merged....
r2755 def test_destroy
assert_difference 'Group.count', -1 do
post :destroy, :id => 10
end
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to '/groups'
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
Moved new group user to its own action GroupsController#new_users....
r13220 def test_new_users
get :new_users, :id => 10
assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select 'input[name=?]', 'user_search'
Jean-Philippe Lang
Moved new group user to its own action GroupsController#new_users....
r13220 end
def test_xhr_new_users
xhr :get, :new_users, :id => 10
assert_response :success
assert_equal 'text/javascript', response.content_type
end
Jean-Philippe Lang
User groups branch merged....
r2755 def test_add_users
assert_difference 'Group.find(10).users.count', 2 do
post :add_users, :id => 10, :user_ids => ['2', '3']
end
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7869 def test_xhr_add_users
assert_difference 'Group.find(10).users.count', 2 do
xhr :post, :add_users, :id => 10, :user_ids => ['2', '3']
Jean-Philippe Lang
Removes RJS from GroupsController....
r9861 assert_response :success
assert_equal 'text/javascript', response.content_type
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7869 end
Jean-Philippe Lang
Removes RJS from GroupsController....
r9861 assert_match /John Smith/, response.body
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7869 end
Jean-Philippe Lang
User groups branch merged....
r2755 def test_remove_user
assert_difference 'Group.find(10).users.count', -1 do
Jean-Philippe Lang
Adds routes for group users....
r7826 delete :remove_user, :id => 10, :user_id => '8'
Jean-Philippe Lang
User groups branch merged....
r2755 end
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/groups_controller_test.rb....
r6809
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7869 def test_xhr_remove_user
assert_difference 'Group.find(10).users.count', -1 do
xhr :delete, :remove_user, :id => 10, :user_id => '8'
Jean-Philippe Lang
Removes RJS from GroupsController....
r9861 assert_response :success
assert_equal 'text/javascript', response.content_type
Jean-Philippe Lang
Adds functional tests for GroupsController....
r7869 end
end
Jean-Philippe Lang
Fixed: list of users for adding to a group may be empty if 100 first users have been added (#8029)....
r5164 def test_autocomplete_for_user
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 xhr :get, :autocomplete_for_user, :id => 10, :q => 'smi', :format => 'js'
Jean-Philippe Lang
Fixed: list of users for adding to a group may be empty if 100 first users have been added (#8029)....
r5164 assert_response :success
Jean-Philippe Lang
Adds pagination to users list when adding project or group members (#9549)....
r10970 assert_include 'John Smith', response.body
Jean-Philippe Lang
Fixed: list of users for adding to a group may be empty if 100 first users have been added (#8029)....
r5164 end
Jean-Philippe Lang
User groups branch merged....
r2755 end