##// END OF EJS Templates
Merged r9387 from trunk....
Merged r9387 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9401 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r8116:34087c417819
r9267:59f14478eda8
Show More
group_test.rb
113 lines | 3.5 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
User groups branch merged....
r2755 # Redmine - project management software
Jean-Philippe Lang
Ability to assign issues to groups (#2964)....
r6186 # Copyright (C) 2006-2011 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/unit/group_test.rb....
r6622 #
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/unit/group_test.rb....
r6622 #
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
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class GroupTest < ActiveSupport::TestCase
Toshi MARUYAMA
Rails3: replace "all" fixtures at test/unit/group_test.rb...
r7391 fixtures :projects, :trackers, :issue_statuses, :issues,
:enumerations, :users, :issue_categories,
:projects_trackers,
:roles,
:member_roles,
:members,
:enabled_modules,
:workflows,
:groups_users
Jean-Philippe Lang
User groups branch merged....
r2755
Toshi MARUYAMA
use set_language_if_valid instead of I18n.locale at unit group test (#9795)...
r8115 include Redmine::I18n
Jean-Philippe Lang
User groups branch merged....
r2755 def test_create
g = Group.new(:lastname => 'New group')
assert g.save
end
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
Fixed: Unrelated error message when creating a group with an invalid name (#9795)....
r8111 def test_blank_name_error_message
Toshi MARUYAMA
use set_language_if_valid instead of I18n.locale at unit group test (#9795)...
r8115 set_language_if_valid 'en'
Jean-Philippe Lang
Fixed: Unrelated error message when creating a group with an invalid name (#9795)....
r8111 g = Group.new
assert !g.save
assert_include "Name can't be blank", g.errors.full_messages
end
Toshi MARUYAMA
add unit test of group blank name in French (#9795)...
r8116 def test_blank_name_error_message_fr
set_language_if_valid 'fr'
str = "Nom doit \xc3\xaatre renseign\xc3\xa9(e)"
str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
g = Group.new
assert !g.save
assert_include str, g.errors.full_messages
end
Jean-Philippe Lang
User groups branch merged....
r2755 def test_roles_given_to_new_user
group = Group.find(11)
user = User.find(9)
project = Project.first
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
User groups branch merged....
r2755 Member.create!(:principal => group, :project => project, :role_ids => [1, 2])
group.users << user
assert user.member_of?(project)
end
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
User groups branch merged....
r2755 def test_roles_given_to_existing_user
group = Group.find(11)
user = User.find(9)
project = Project.first
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
User groups branch merged....
r2755 group.users << user
m = Member.create!(:principal => group, :project => project, :role_ids => [1, 2])
assert user.member_of?(project)
end
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
User groups branch merged....
r2755 def test_roles_updated
group = Group.find(11)
user = User.find(9)
project = Project.first
group.users << user
m = Member.create!(:principal => group, :project => project, :role_ids => [1])
assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
User groups branch merged....
r2755 m.role_ids = [1, 2]
assert_equal [1, 2], user.reload.roles_for_project(project).collect(&:id).sort
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
User groups branch merged....
r2755 m.role_ids = [2]
assert_equal [2], user.reload.roles_for_project(project).collect(&:id).sort
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
User groups branch merged....
r2755 m.role_ids = [1]
assert_equal [1], user.reload.roles_for_project(project).collect(&:id).sort
end
def test_roles_removed_when_removing_group_membership
assert User.find(8).member_of?(Project.find(5))
Member.find_by_project_id_and_user_id(5, 10).destroy
assert !User.find(8).member_of?(Project.find(5))
end
def test_roles_removed_when_removing_user_from_group
assert User.find(8).member_of?(Project.find(5))
User.find(8).groups.clear
assert !User.find(8).member_of?(Project.find(5))
end
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
Ability to assign issues to groups (#2964)....
r6186 def test_destroy_should_unassign_issues
group = Group.first
Issue.update_all(["assigned_to_id = ?", group.id], 'id = 1')
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
Ability to assign issues to groups (#2964)....
r6186 assert group.destroy
assert group.destroyed?
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
Ability to assign issues to groups (#2964)....
r6186 assert_equal nil, Issue.find(1).assigned_to_id
end
Jean-Philippe Lang
User groups branch merged....
r2755 end