comparison test/functional/groups_controller_test.rb @ 1526:404aa68d4227

Merge from live branch
author Chris Cannam
date Thu, 11 Sep 2014 12:46:20 +0100
parents dffacf8a6908
children
comparison
equal deleted inserted replaced
1493:a5f2bdf3b486 1526:404aa68d4227
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
51 def test_create 51 def test_create
52 assert_difference 'Group.count' do 52 assert_difference 'Group.count' do
53 post :create, :group => {:name => 'New group'} 53 post :create, :group => {:name => 'New group'}
54 end 54 end
55 assert_redirected_to '/groups' 55 assert_redirected_to '/groups'
56 group = Group.first(:order => 'id DESC') 56 group = Group.order('id DESC').first
57 assert_equal 'New group', group.name 57 assert_equal 'New group', group.name
58 assert_equal [], group.users 58 assert_equal [], group.users
59 end 59 end
60 60
61 def test_create_and_continue 61 def test_create_and_continue
62 assert_difference 'Group.count' do 62 assert_difference 'Group.count' do
63 post :create, :group => {:name => 'New group'}, :continue => 'Create and continue' 63 post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
64 end 64 end
65 assert_redirected_to '/groups/new' 65 assert_redirected_to '/groups/new'
66 group = Group.first(:order => 'id DESC') 66 group = Group.order('id DESC').first
67 assert_equal 'New group', group.name 67 assert_equal 'New group', group.name
68 end 68 end
69 69
70 def test_create_with_failure 70 def test_create_with_failure
71 assert_no_difference 'Group.count' do 71 assert_no_difference 'Group.count' do
77 77
78 def test_edit 78 def test_edit
79 get :edit, :id => 10 79 get :edit, :id => 10
80 assert_response :success 80 assert_response :success
81 assert_template 'edit' 81 assert_template 'edit'
82 assert_tag 'div', :attributes => {:id => 'tab-content-users'} 82
83 assert_tag 'div', :attributes => {:id => 'tab-content-memberships'} 83 assert_select 'div#tab-content-users'
84 assert_select 'div#tab-content-memberships' do
85 assert_select 'a', :text => 'Private child of eCookbook'
86 end
84 end 87 end
85 88
86 def test_update 89 def test_update
87 new_name = 'New name' 90 new_name = 'New name'
88 put :update, :id => 10, :group => {:name => new_name} 91 put :update, :id => 10, :group => {:name => new_name}
190 assert_equal 'text/javascript', response.content_type 193 assert_equal 'text/javascript', response.content_type
191 end 194 end
192 end 195 end
193 196
194 def test_autocomplete_for_user 197 def test_autocomplete_for_user
195 get :autocomplete_for_user, :id => 10, :q => 'mis' 198 get :autocomplete_for_user, :id => 10, :q => 'smi', :format => 'js'
196 assert_response :success 199 assert_response :success
197 users = assigns(:users) 200 assert_include 'John Smith', response.body
198 assert_not_nil users
199 assert users.any?
200 assert !users.include?(Group.find(10).users.first)
201 end 201 end
202 end 202 end