Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -35,6 +37,24 @@ class RolesControllerTest < Redmine::ControllerTest
end
end
def test_index_should_show_warning_when_no_workflow_is_defined
Role.find_by_name('Developer').workflow_rules.destroy_all
Role.find_by_name('Anonymous').workflow_rules.destroy_all
get :index
assert_response :success
assert_select 'table.roles' do
# Manager
assert_select 'tr.givable:nth-of-type(1) span.icon-warning', :count => 0
# Developer
assert_select 'tr.givable:nth-of-type(2) span.icon-warning', :text => /#{I18n.t(:text_role_no_workflow)}/
# Reporter
assert_select 'tr.givable:nth-of-type(3) span.icon-warning', :count => 0
# No warnings for built-in roles such as Anonymous and Non-member
assert_select 'tr.builtin span.icon-warning', :count => 0
end
end
def test_new
get :new
assert_response :success
@ -138,6 +158,7 @@ class RolesControllerTest < Redmine::ControllerTest
assert_select 'input[name=?][value=?]', 'role[name]', 'Manager'
assert_select 'select[name=?]', 'role[issues_visibility]'
assert_select '#role-permissions-trackers table .delete_issues_shown'
end
def test_edit_anonymous
@ -146,6 +167,7 @@ class RolesControllerTest < Redmine::ControllerTest
assert_select 'input[name=?]', 'role[name]', 0
assert_select 'select[name=?]', 'role[issues_visibility]', 0
assert_select '#role-permissions-trackers table .delete_issues_shown', 0
end
def test_edit_invalid_should_respond_with_404
@ -202,11 +224,11 @@ class RolesControllerTest < Redmine::ControllerTest
def test_destroy_role_in_use
delete :destroy, :params => {:id => 1}
assert_redirected_to '/roles'
assert_equal 'This role is in use and cannot be deleted.', flash[:error]
assert_equal 'This role is in use and cannot be deleted.', flash[:error]
assert_not_nil Role.find_by_id(1)
end
def test_get_permissions
def test_permissions
get :permissions
assert_response :success
@ -214,10 +236,20 @@ class RolesControllerTest < Redmine::ControllerTest
assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
end
def test_post_permissions
post :permissions, :params => {
def test_permissions_with_filter
get :permissions, :params => {
:ids => ['2', '3']
}
assert_response :success
assert_select 'table.permissions thead th', 3
assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]'
assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
end
def test_update_permissions
post :update_permissions, :params => {
:permissions => {
'0' => '',
'1' => ['edit_issues'],
'3' => ['add_issues', 'delete_issues']
}
@ -226,13 +258,18 @@ class RolesControllerTest < Redmine::ControllerTest
assert_equal [:edit_issues], Role.find(1).permissions
assert_equal [:add_issues, :delete_issues], Role.find(3).permissions
assert Role.find(2).permissions.empty?
end
def test_clear_all_permissions
post :permissions, :params => {:permissions => { '0' => '' }}
assert_redirected_to '/roles'
assert Role.find(1).permissions.empty?
def test_update_permissions_should_not_update_other_roles
assert_no_changes -> { Role.find(2).permissions } do
assert_changes -> { Role.find(1).permissions } do
post :update_permissions, :params => {
:permissions => {
'1' => ['edit_issues']
}
}
end
end
end
def test_move_highest