##// END OF EJS Templates
Replace Date.today with User.current.today (#22320)....
Replace Date.today with User.current.today (#22320). Depending on the offset between a user's configured timezone and the server timezone, Date.today may be more or less often wrong from the user's perspective, leading to things like issues marked as overdue too early or too late, or yesterday / tomorrow being displayed / selected where 'today' is intended. A test case illustrating the problem with Issue#overdue? is included Patch by Jens Kraemer. git-svn-id: http://svn.redmine.org/redmine/trunk@15379 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r14997:ed50d42210ea
Show More
group_test.rb
169 lines | 4.9 KiB | text/x-ruby | RubyLexer
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/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,
Jean-Philippe Lang
Removed unused fixtures....
r11091 :enumerations, :users,
Toshi MARUYAMA
Rails3: replace "all" fixtures at test/unit/group_test.rb...
r7391 :projects_trackers,
:roles,
:member_roles,
:members,
: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
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 g = Group.new(:name => 'New group')
Jean-Philippe Lang
User groups branch merged....
r2755 assert g.save
Jean-Philippe Lang
Replaced group[lastname] parameter with group[name]....
r9562 g.reload
assert_equal 'New group', g.name
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from test/unit/group_test.rb....
r6622
Jean-Philippe Lang
Raised group name maximum length to 255 characters (#13174)....
r11162 def test_name_should_accept_255_characters
name = 'a' * 255
g = Group.new(:name => name)
assert g.save
g.reload
assert_equal name, g.name
end
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
Jean-Philippe Lang
Replaced "can't" with "cannot" in error messages....
r13399 assert_include "Name cannot be blank", g.errors.full_messages
Jean-Philippe Lang
Fixed: Unrelated error message when creating a group with an invalid name (#9795)....
r8111 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'
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 str = "Nom doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
Toshi MARUYAMA
add unit test of group blank name in French (#9795)...
r8116 g = Group.new
assert !g.save
assert_include str, g.errors.full_messages
end
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 def test_group_roles_should_be_given_to_added_user
Jean-Philippe Lang
User groups branch merged....
r2755 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
REST Api for Groups (#8981)....
r9575 def test_new_roles_should_be_given_to_existing_user
Jean-Philippe Lang
User groups branch merged....
r2755 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
REST Api for Groups (#8981)....
r9575 def test_user_roles_should_updated_when_updating_user_ids
group = Group.find(11)
user = User.find(9)
project = Project.first
Member.create!(:principal => group, :project => project, :role_ids => [1, 2])
group.user_ids = [user.id]
group.save!
assert User.find(9).member_of?(project)
group.user_ids = [1]
group.save!
assert !User.find(9).member_of?(project)
end
def test_user_roles_should_updated_when_updating_group_roles
Jean-Philippe Lang
User groups branch merged....
r2755 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
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 def test_user_memberships_should_be_removed_when_removing_group_membership
Jean-Philippe Lang
User groups branch merged....
r2755 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
Jean-Philippe Lang
REST Api for Groups (#8981)....
r9575 def test_user_roles_should_be_removed_when_removing_user_from_group
Jean-Philippe Lang
User groups branch merged....
r2755 assert User.find(8).member_of?(Project.find(5))
Jean-Philippe Lang
Test failure due to a regression in Rails 3.2.5....
r9579 User.find(8).groups = []
Jean-Philippe Lang
User groups branch merged....
r2755 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
Jean-Philippe Lang
Fixed test failure with ruby1.8.7 and postgresql (#17976)....
r13056 group = Group.find(10)
Toshi MARUYAMA
Rails4: replace deprecated Relation#update_all at GroupTest...
r12255 Issue.where(:id => 1).update_all(["assigned_to_id = ?", group.id])
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
Adds a few tests....
r13313
def test_builtin_groups_should_be_created_if_missing
Group.delete_all
assert_difference 'Group.count', 2 do
group = Group.anonymous
assert_equal GroupAnonymous, group.class
group = Group.non_member
assert_equal GroupNonMember, group.class
end
end
def test_builtin_in_group_should_be_uniq
group = GroupAnonymous.new
group.name = 'Foo'
assert !group.save
end
def test_builtin_in_group_should_not_accept_users
group = Group.anonymous
assert_raise RuntimeError do
group.users << User.find(1)
end
assert_equal 0, group.reload.users.count
end
Jean-Philippe Lang
Fixed group sorted scope order (#20066)....
r13998
def test_sorted_scope_should_sort_groups_alphabetically
Group.delete_all
b = Group.generate!(:name => 'B')
a = Group.generate!(:name => 'A')
assert_equal %w(A B), Group.sorted.to_a.map(&:name)
end
Jean-Philippe Lang
User groups branch merged....
r2755 end