##// END OF EJS Templates
Rails3: model: replace deprecated validate method at member_role model...
Rails3: model: replace deprecated validate method at member_role model git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8068 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r7391:eb1d9289e886
r7948:1de2c1c2af36
Show More
group_test.rb
95 lines | 3.0 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
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
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