comparison test/unit/group_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.
17 17
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 class GroupTest < ActiveSupport::TestCase 20 class GroupTest < ActiveSupport::TestCase
21 fixtures :projects, :trackers, :issue_statuses, :issues, 21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 :enumerations, :users, :issue_categories, 22 :enumerations, :users,
23 :projects_trackers, 23 :projects_trackers,
24 :roles, 24 :roles,
25 :member_roles, 25 :member_roles,
26 :members, 26 :members,
27 :enabled_modules,
28 :workflows,
29 :groups_users 27 :groups_users
30 28
31 include Redmine::I18n 29 include Redmine::I18n
32 30
33 def test_create 31 def test_create
34 g = Group.new(:name => 'New group') 32 g = Group.new(:name => 'New group')
35 assert g.save 33 assert g.save
36 g.reload 34 g.reload
37 assert_equal 'New group', g.name 35 assert_equal 'New group', g.name
36 end
37
38 def test_name_should_accept_255_characters
39 name = 'a' * 255
40 g = Group.new(:name => name)
41 assert g.save
42 g.reload
43 assert_equal name, g.name
38 end 44 end
39 45
40 def test_blank_name_error_message 46 def test_blank_name_error_message
41 set_language_if_valid 'en' 47 set_language_if_valid 'en'
42 g = Group.new 48 g = Group.new
118 assert !User.find(8).member_of?(Project.find(5)) 124 assert !User.find(8).member_of?(Project.find(5))
119 end 125 end
120 126
121 def test_destroy_should_unassign_issues 127 def test_destroy_should_unassign_issues
122 group = Group.first 128 group = Group.first
123 Issue.update_all(["assigned_to_id = ?", group.id], 'id = 1') 129 Issue.where(:id => 1).update_all(["assigned_to_id = ?", group.id])
124 130
125 assert group.destroy 131 assert group.destroy
126 assert group.destroyed? 132 assert group.destroyed?
127 133
128 assert_equal nil, Issue.find(1).assigned_to_id 134 assert_equal nil, Issue.find(1).assigned_to_id