Redmine 4.1.7

This commit is contained in:
Manuel Cillero 2023-07-07 08:08:27 +02:00
parent 55458d3479
commit 3ca3c37487
103 changed files with 2426 additions and 431 deletions

View file

@ -124,6 +124,49 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_select 'a[href="/issues/6"]', 0
end
def test_index_should_list_issues_of_closed_subprojects
@request.session[:user_id] = 1
project = Project.find(1)
with_settings :display_subprojects_issues => '1' do
# One of subprojects is closed
Project.find_by(:identifier => 'subproject1').close
get(:index, :params => {:project_id => project.id})
assert_response :success
assert_equal 10, issues_in_list.count
# All subprojects are closed
project.descendants.each(&:close)
get(:index, :params => {:project_id => project.id})
assert_response :success
assert_equal 10, issues_in_list.count
end
end
def test_index_with_subproject_filter_should_not_exclude_closed_subprojects_issues
subproject1 = Project.find(3)
subproject2 = Project.find(4)
subproject1.close
with_settings :display_subprojects_issues => '1' do
get(
:index,
:params => {
:project_id => 1,
:set_filter => 1,
:f => ['subproject_id'],
:op => {'subproject_id' => '!'},
:v => {'subproject_id' => [subproject2.id.to_s]},
:c => ['project']
}
)
end
assert_response :success
column_values = columns_values_in_list('project')
assert_includes column_values, subproject1.name
assert_equal 9, column_values.size
end
def test_index_with_project_and_subprojects_should_show_private_subprojects_with_permission
@request.session[:user_id] = 2
Setting.display_subprojects_issues = 1
@ -1664,6 +1707,22 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_select '#content a.new-issue[href="/issues/new"]', :text => 'New issue'
end
def test_index_should_show_setting_link_with_edit_project_permission
role = Role.find(1)
role.add_permission! :edit_project
@request.session[:user_id] = 2
get(:index, :params => {:project_id => 1})
assert_select '#content a.icon-settings[href="/projects/ecookbook/settings/issues"]', 1
end
def test_index_should_not_show_setting_link_without_edit_project_permission
role = Role.find(1)
role.remove_permission! :edit_project
@request.session[:user_id] = 2
get(:index, :params => {:project_id => 1})
assert_select '#content a.icon-settings[href="/projects/ecookbook/settings/issues"]', 0
end
def test_index_should_not_include_new_issue_tab_when_disabled
with_settings :new_item_menu_tab => '0' do
@request.session[:user_id] = 2
@ -1720,6 +1779,22 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
def test_index_should_respect_timespan_format
with_settings :timespan_format => 'minutes' do
get(
:index,
:params => {
:set_filter => 1,
:c => %w(estimated_hours total_estimated_hours spent_hours total_spent_hours)
}
)
assert_select 'table.issues tr#issue-1 td.estimated_hours', :text => '200:00'
assert_select 'table.issues tr#issue-1 td.total_estimated_hours', :text => '200:00'
assert_select 'table.issues tr#issue-1 td.spent_hours', :text => '154:15'
assert_select 'table.issues tr#issue-1 td.total_spent_hours', :text => '154:15'
end
end
def test_show_by_anonymous
get :show, :params => {
:id => 1
@ -2615,6 +2690,32 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
def test_show_should_not_display_edit_attachment_icon_for_user_without_edit_issue_permission_on_tracker
role = Role.find(2)
role.set_permission_trackers 'edit_issues', [2, 3]
role.save!
@request.session[:user_id] = 2
get :show, params: {id: 4}
assert_response :success
assert_select 'div.attachments .icon-edit', 0
end
def test_show_should_not_display_delete_attachment_icon_for_user_without_edit_issue_permission_on_tracker
role = Role.find(2)
role.set_permission_trackers 'edit_issues', [2, 3]
role.save!
@request.session[:user_id] = 2
get :show, params: {id: 4}
assert_response :success
assert_select 'div.attachments .icon-del', 0
end
def test_get_new
@request.session[:user_id] = 2
get :new, :params => {
@ -4816,6 +4917,41 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
def test_get_edit_should_display_visible_spent_time_custom_field
@request.session[:user_id] = 2
get(
:edit,
:params => {
:id => 13,
}
)
assert_response :success
assert_select '#issue-form select#time_entry_custom_field_values_10', 1
end
def test_get_edit_should_not_display_spent_time_custom_field_not_visible
cf = TimeEntryCustomField.find(10)
cf.visible = false
cf.role_ids = [1]
cf.save!
@request.session[:user_id] = 2
get(
:edit,
:params => {
:id => 13,
}
)
assert_response :success
assert_select '#issue-form select#time_entry_custom_field_values_10', 0
end
def test_update_form_for_existing_issue
@request.session[:user_id] = 2
patch :edit, :params => {
@ -5222,6 +5358,24 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_equal spent_hours_before + 2.5, issue.spent_hours
end
def test_put_update_should_check_add_issue_notes_permission
role = Role.find(1)
role.remove_permission! :add_issue_notes
@request.session[:user_id] = 2
assert_no_difference 'Journal.count' do
put(
:update,
:params => {
:id => 1,
:issue => {
:notes => 'New note'
}
}
)
end
end
def test_put_update_should_preserve_parent_issue_even_if_not_visible
parent = Issue.generate!(:project_id => 1, :is_private => true)
issue = Issue.generate!(:parent_issue_id => parent.id)
@ -5528,6 +5682,29 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'this is my comment'
end
def test_put_with_spent_time_when_assigned_to_of_private_issue_is_update_at_the_same_time
@request.session[:user_id] = 3
Role.find(2).update! :issues_visibility => 'own'
private_issue = Issue.find(3)
assert_difference('TimeEntry.count', 1) do
put(
:update,
params: {
id: private_issue.id,
issue: { assigned_to_id: nil },
time_entry: {
comments: "add spent time", activity_id: TimeEntryActivity.first.id, hours: 1
}
}
)
end
assert_select '#errorExplanation', {text: /Log time is invalid/, count: 0}
assert_select '#errorExplanation', {text: /Issue is invalid/, count: 0}
assert_redirected_to action: 'show', id: private_issue.id
assert_not private_issue.reload.visible?
end
def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
issue = Issue.find(2)
@request.session[:user_id] = 2