##// END OF EJS Templates
Use regular edit/update actions and named routes for JournalsController....
Use regular edit/update actions and named routes for JournalsController. git-svn-id: http://svn.redmine.org/redmine/trunk@15074 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14076:2bc5b60f9de7
r14692:6bb1ea8ae8a1
Show More
role_test.rb
142 lines | 4.3 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Localize anonymous and non member roles names (#8072)....
r5213 # Redmine - project management software
Jean-Philippe Lang
Copyright update....
r13490 # Copyright (C) 2006-2015 Jean-Philippe Lang
Jean-Philippe Lang
Workflow copy:...
r1237 #
# 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/role_test.rb....
r6649 #
Jean-Philippe Lang
Workflow copy:...
r1237 # 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/role_test.rb....
r6649 #
Jean-Philippe Lang
Workflow copy:...
r1237 # 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
Workflow copy:...
r1237
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class RoleTest < ActiveSupport::TestCase
Jean-Baptiste Barth
Fixed some more test/unit/*_test.rb breaking when run alone (#12285)...
r10564 fixtures :roles, :workflows, :trackers
Jean-Philippe Lang
Workflow copy:...
r1237
Jean-Philippe Lang
Code cleanup....
r9532 def test_sorted_scope
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 assert_equal Role.all.sort, Role.sorted.to_a
Jean-Philippe Lang
Code cleanup....
r9532 end
def test_givable_scope
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 assert_equal Role.all.reject(&:builtin?).sort, Role.givable.to_a
Jean-Philippe Lang
Code cleanup....
r9532 end
def test_builtin_scope
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 assert_equal Role.all.select(&:builtin?).sort, Role.builtin(true).to_a.sort
assert_equal Role.all.reject(&:builtin?).sort, Role.builtin(false).to_a.sort
Jean-Philippe Lang
Code cleanup....
r9532 end
Jean-Philippe Lang
Create role by copy (#9258)....
r10102 def test_copy_from
role = Role.find(1)
copy = Role.new.copy_from(role)
assert_nil copy.id
assert_equal '', copy.name
assert_equal role.permissions, copy.permissions
copy.name = 'Copy'
assert copy.save
end
Jean-Philippe Lang
Workflow copy:...
r1237 def test_copy_workflows
source = Role.find(1)
Jean-Philippe Lang
Makes new issue initial status settable in workflow (#5816)....
r14076 rule_count = source.workflow_rules.count
assert rule_count > 0
Toshi MARUYAMA
remove trailing white-spaces from test/unit/role_test.rb....
r6649
Jean-Philippe Lang
Workflow copy:...
r1237 target = Role.new(:name => 'Target')
assert target.save
Jean-Philippe Lang
Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521)....
r9794 target.workflow_rules.copy(source)
Jean-Philippe Lang
Workflow copy:...
r1237 target.reload
Jean-Philippe Lang
Makes new issue initial status settable in workflow (#5816)....
r14076 assert_equal rule_count, target.workflow_rules.size
Jean-Philippe Lang
Workflow copy:...
r1237 end
Jean-Philippe Lang
Merged nbc branch @ r1812 (commit access permission and reposman improvements)....
r1812
Jean-Philippe Lang
Perf: use a custom decoder for Role#permissions instead of YAML.load....
r9733 def test_permissions_should_be_unserialized_with_its_coder
Jean-Philippe Lang
PermissionsAttributeCoder.load called twice when mocha expectation is set....
r13398 Role::PermissionsAttributeCoder.stubs(:load).returns([:foo, :bar])
role = Role.find(1)
assert_equal [:foo, :bar], role.permissions
Jean-Philippe Lang
Perf: use a custom decoder for Role#permissions instead of YAML.load....
r9733 end
Jean-Philippe Lang
Merged nbc branch @ r1812 (commit access permission and reposman improvements)....
r1812 def test_add_permission
role = Role.find(1)
size = role.permissions.size
role.add_permission!("apermission", "anotherpermission")
role.reload
assert role.permissions.include?(:anotherpermission)
assert_equal size + 2, role.permissions.size
end
def test_remove_permission
role = Role.find(1)
size = role.permissions.size
perm = role.permissions[0..1]
role.remove_permission!(*perm)
role.reload
assert ! role.permissions.include?(perm[0])
assert_equal size - 2, role.permissions.size
end
Toshi MARUYAMA
remove trailing white-spaces from test/unit/role_test.rb....
r6649
Jean-Philippe Lang
Adds tests for Role#has_permissions?...
r13343 def test_has_permission
role = Role.create!(:name => 'Test', :permissions => [:view_issues, :edit_issues])
assert_equal true, role.has_permission?(:view_issues)
assert_equal false, role.has_permission?(:delete_issues)
end
def test_has_permission_without_permissions
role = Role.create!(:name => 'Test')
assert_equal false, role.has_permission?(:delete_issues)
end
Jean-Philippe Lang
Localize anonymous and non member roles names (#8072)....
r5213 def test_name
I18n.locale = 'fr'
assert_equal 'Manager', Role.find(1).name
assert_equal 'Anonyme', Role.anonymous.name
assert_equal 'Non membre', Role.non_member.name
end
Jean-Philippe Lang
Merged nbc branch @ r1812 (commit access permission and reposman improvements)....
r1812
Jean-Philippe Lang
Code cleanup....
r9532 def test_find_all_givable
assert_equal Role.all.reject(&:builtin?).sort, Role.find_all_givable
end
Jean-Philippe Lang
Removed some shoulda context....
r11634 def test_anonymous_should_return_the_anonymous_role
assert_no_difference('Role.count') do
Eric Davis
Change Role#anonymous and #non_member so they generate the record as needed....
r3249 role = Role.anonymous
assert role.builtin?
assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
end
Jean-Philippe Lang
Removed some shoulda context....
r11634 end
def test_anonymous_with_a_missing_anonymous_role_should_return_the_anonymous_role
Role.where(:builtin => Role::BUILTIN_ANONYMOUS).delete_all
Eric Davis
Change Role#anonymous and #non_member so they generate the record as needed....
r3249
Jean-Philippe Lang
Removed some shoulda context....
r11634 assert_difference('Role.count') do
role = Role.anonymous
assert role.builtin?
assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
Eric Davis
Change Role#anonymous and #non_member so they generate the record as needed....
r3249 end
end
Jean-Philippe Lang
Removed some shoulda context....
r11634 def test_non_member_should_return_the_non_member_role
assert_no_difference('Role.count') do
Eric Davis
Change Role#anonymous and #non_member so they generate the record as needed....
r3249 role = Role.non_member
assert role.builtin?
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
end
Jean-Philippe Lang
Removed some shoulda context....
r11634 end
def test_non_member_with_a_missing_non_member_role_should_return_the_non_member_role
Role.where(:builtin => Role::BUILTIN_NON_MEMBER).delete_all
Eric Davis
Change Role#anonymous and #non_member so they generate the record as needed....
r3249
Jean-Philippe Lang
Removed some shoulda context....
r11634 assert_difference('Role.count') do
role = Role.non_member
assert role.builtin?
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
Eric Davis
Change Role#anonymous and #non_member so they generate the record as needed....
r3249 end
end
Jean-Philippe Lang
Workflow copy:...
r1237 end