Reverts r21958 and r21959 (#1739).

git-svn-id: https://svn.redmine.org/redmine/trunk@21960 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2022-11-18 08:17:50 +00:00
parent 44c72fe7b0
commit 0f2378c121
60 changed files with 3 additions and 200 deletions

View File

@@ -534,7 +534,7 @@ module IssuesHelper
old_value = format_date(detail.old_value.to_date) if detail.old_value
when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
'priority_id', 'category_id', 'fixed_version_id', 'author_id'
'priority_id', 'category_id', 'fixed_version_id'
value = find_name_by_reflection(field, detail.value)
old_value = find_name_by_reflection(field, detail.old_value)
@@ -778,23 +778,4 @@ module IssuesHelper
projects
end
end
def author_options_for_select(issue, project)
users = issue.assignable_users.select {|m| m.is_a?(User) && m.allowed_to?(:add_issues, project) }
if issue.new_record?
if users.include?(User.current)
principals_options_for_select(users, issue.author)
else
principals_options_for_select([User.current] + users)
end
elsif issue.persisted?
if users.include?(issue.author)
principals_options_for_select(users, issue.author)
else
author_principal = Principal.find(issue.author_id)
principals_options_for_select([author_principal] + users, author_principal)
end
end
end
end

View File

@@ -111,7 +111,6 @@ class Issue < ActiveRecord::Base
before_validation :clear_disabled_fields
before_save :close_duplicates, :update_done_ratio_from_issue_status,
:force_updated_on_change, :update_closed_on
before_create :set_author_journal
after_save do |issue|
if !issue.saved_change_to_id? && issue.saved_change_to_project_id?
issue.send :after_project_change
@@ -520,9 +519,6 @@ class Issue < ActiveRecord::Base
safe_attributes(
'deleted_attachment_ids',
:if => lambda {|issue, user| issue.attachments_deletable?(user)})
safe_attributes(
'author_id',
:if => lambda {|issue, user| user.allowed_to?(:change_issue_author, issue.project)})
def safe_attribute_names(user=nil)
names = super
@@ -2024,14 +2020,6 @@ class Issue < ActiveRecord::Base
end
end
def set_author_journal
return unless new_record?
return unless self.author.present? && User.current.present? && self.author != User.current
self.init_journal(User.current)
self.current_journal.__send__(:add_attribute_detail, 'author_id', User.current.id, self.author.id)
end
def send_notification
if notify? && Setting.notified_events.include?('issue_added')
Mailer.deliver_issue_add(self)

View File

@@ -3,9 +3,6 @@
<div class="splitcontent">
<div class="splitcontentleft">
<% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
<% if User.current.allowed_to?(:change_issue_author, @project) %>
<p><%= f.select :author_id, author_options_for_select(@issue, @project), :include_blank => false, :required => true %></p>
<% end %>
<p>
<%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), {:required => true},
:onchange => "updateIssueFrom('#{escape_javascript(update_issue_form_path(@project, @issue))}', this)" %>

View File

@@ -1478,4 +1478,3 @@ ar:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1570,4 +1570,3 @@ az:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1426,4 +1426,3 @@ bg:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1491,4 +1491,3 @@ bs:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1468,4 +1468,3 @@ ca:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1461,4 +1461,3 @@ cs:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1495,4 +1495,3 @@ da:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1442,4 +1442,3 @@ de:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1478,4 +1478,3 @@ el:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1479,4 +1479,3 @@ en-GB:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -541,7 +541,6 @@ en:
permission_view_private_notes: View private notes
permission_set_notes_private: Set notes as private
permission_delete_issues: Delete issues
permission_change_issue_author: Change issue author
permission_manage_public_queries: Manage public queries
permission_save_queries: Save queries
permission_view_gantt: View gantt chart

View File

@@ -1508,4 +1508,3 @@ es-PA:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1545,4 +1545,3 @@ es:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1483,4 +1483,3 @@ et:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1479,4 +1479,3 @@ eu:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1424,4 +1424,3 @@ fa:
is disabled.
text_user_destroy_confirmation: مطمئنید که می خواهید این کاربر و همه ارجاع‌های مربوط به او را حذف کنید؟ این کار قابل بازگشت نیست. غالبا، قفل کردن کاربر به جای حذف، راه حل به‌تری است. برای تأیید، لطفاً شناسه ورود کاربر (%{login}) را در زیر وارد کنید.
text_project_destroy_enter_identifier: برای تایید، لطفا شناسه پروژه (%{identifier}) را وارد کنید.
permission_change_issue_author: Change issue author

View File

@@ -1499,4 +1499,3 @@ fi:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1459,4 +1459,3 @@ fr:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1484,4 +1484,3 @@ gl:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1483,4 +1483,3 @@ he:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1475,4 +1475,3 @@ hr:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1497,4 +1497,3 @@
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1480,4 +1480,3 @@ id:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1471,4 +1471,3 @@ it:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1431,4 +1431,3 @@ ja:
field_is_member_of_group: グループ
text_users_bulk_destroy_head: 以下のユーザーとこれらのユーザーへのすべての参照を削除しようとしています。削除後は元に戻せません。通常は削除よりロックのほうが適切です。
text_users_bulk_destroy_confirm: 削除する場合は確認のため "%{yes}" と入力してください。
permission_change_issue_author: Change issue author

View File

@@ -1516,4 +1516,3 @@ ko:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1439,4 +1439,3 @@ lt:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1472,4 +1472,3 @@ lv:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1478,4 +1478,3 @@ mk:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1478,4 +1478,3 @@ mn:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1453,4 +1453,3 @@ nl:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1468,4 +1468,3 @@
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1425,4 +1425,3 @@ pl:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1483,4 +1483,3 @@ pt-BR:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1471,4 +1471,3 @@ pt:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1473,4 +1473,3 @@ ro:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1552,4 +1552,3 @@ ru:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1467,4 +1467,3 @@ sk:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1478,4 +1478,3 @@ sl:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1440,4 +1440,3 @@ sq:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1480,4 +1480,3 @@ sr-YU:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1479,4 +1479,3 @@ sr:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1511,4 +1511,3 @@ sv:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1474,4 +1474,3 @@ th:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1485,4 +1485,3 @@ tr:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1466,4 +1466,3 @@ uk:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1530,4 +1530,3 @@ vi:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -1496,4 +1496,3 @@
text_users_bulk_destroy_head: 您即將刪除下列用戶,並移除與這些用戶相關聯的資料。
此動作無法復原。鎖定用戶經常是一個比刪除用戶還要來得更好的解決方案。
text_users_bulk_destroy_confirm: 請於下方輸入 "%{yes}" 以便確認。
permission_change_issue_author: Change issue author

View File

@@ -1433,4 +1433,3 @@ zh:
all references to them. This cannot be undone. Often, locking users instead of deleting
them is the better solution.
text_users_bulk_destroy_confirm: To confirm, please enter "%{yes}" below.
permission_change_issue_author: Change issue author

View File

@@ -72,7 +72,6 @@ module Redmine
map.permission :view_private_notes, {}, :read => true, :require => :member
map.permission :set_notes_private, {}, :require => :member
map.permission :delete_issues, {:issues => :destroy}, :require => :member
map.permission :change_issue_author, {:issues => [:edit, :update]}
map.permission :mention_users, {}
# Watchers
map.permission :view_issue_watchers, {}, :read => true

View File

@@ -8306,7 +8306,6 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def test_destroy_child_issue
User.current = User.find(1)
parent = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Parent Issue')
child = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Child Issue', :parent_issue_id => parent.id)
assert child.is_descendant_of?(parent.reload)

View File

@@ -103,7 +103,6 @@ class VersionsControllerTest < Redmine::ControllerTest
end
def test_index_should_show_issue_assignee
User.current = User.find_by_login('jsmith')
with_settings :gravatar_enabled => '1' do
Issue.generate!(:project_id => 3, :fixed_version_id => 4, :assigned_to => User.find_by_login('jsmith'))
Issue.generate!(:project_id => 3, :fixed_version_id => 4)

View File

@@ -465,62 +465,4 @@ class IssuesHelperTest < Redmine::HelperTest
assert_include "<a href=\"/issues?issue_id=#{open_issue.id}%2C#{closed_issue.id}&amp;set_filter=true&amp;status_id=o\">1 open</a>", html
assert_include "<a href=\"/issues?issue_id=#{open_issue.id}%2C#{closed_issue.id}&amp;set_filter=true&amp;status_id=c\">1 closed</a>", html
end
def test_author_options_for_select_if_new_record_and_users_includes_current_user
User.current = User.find(2)
issue = Issue.new(project_id: 1)
assignable_users = [User.find(3), User.find(2)]
assert_includes assignable_users, User.current
assert_equal(
principals_options_for_select(assignable_users, nil),
author_options_for_select(issue, issue.project))
end
def test_author_options_for_select_if_new_record_and_users_not_includes_current_user
User.current = User.find(1)
issue = Issue.new(project_id: 1)
assignable_users = [User.find(3), User.find(2)]
assert_not_includes assignable_users, User.current
assert_equal(
principals_options_for_select([User.current] + assignable_users, nil),
author_options_for_select(issue, issue.project))
end
def test_author_options_for_select_if_persisted_record_and_users_includes_author
User.current = User.find(2)
issue = Issue.find(1)
issue.update(author_id: 2)
assignable_users = [User.find(3), User.find(2)]
assert_includes assignable_users, issue.author
assert_equal(
principals_options_for_select(assignable_users, issue.author),
author_options_for_select(issue, issue.project))
end
def test_author_options_for_select_if_persisted_record_and_users_not_includes_author
User.current = User.find(2)
issue = Issue.find(1)
issue.update(author_id: 1)
assignable_users = [User.find(3), User.find(2)]
assert_not_includes assignable_users, issue.author
assert_equal(
principals_options_for_select([User.find(1)] + assignable_users, issue.author),
author_options_for_select(issue, issue.project))
end
def test_author_options_for_select_if_persisted_record_and_author_is_anonymous
User.current = User.find(2)
issue = Issue.find(1)
issue.update(author_id: User.anonymous.id)
assignable_users = [User.find(3), User.find(2)]
assert_not_includes assignable_users, issue.author
assert_equal(
principals_options_for_select([User.anonymous] + assignable_users, issue.author),
author_options_for_select(issue, issue.project))
end
end

View File

@@ -22,7 +22,7 @@ require File.expand_path('../../test_helper', __FILE__)
class JournalsHelperTest < Redmine::HelperTest
include JournalsHelper
fixtures :projects, :trackers, :issue_statuses, :issues, :journals, :journal_details,
fixtures :projects, :trackers, :issue_statuses, :issues, :journals,
:enumerations, :issue_categories,
:projects_trackers,
:users, :roles, :member_roles, :members,

View File

@@ -95,7 +95,7 @@ module ObjectHelpers
issue.project ||= Project.find(1)
issue.tracker ||= issue.project.trackers.first
issue.subject = 'Generated' if issue.subject.blank?
issue.author ||= (User.current || User.find(2))
issue.author ||= User.find(2)
yield issue if block_given?
issue
end

View File

@@ -60,7 +60,6 @@ class IssueNestedSetTest < ActiveSupport::TestCase
end
def test_creating_a_child_in_a_subproject_should_validate
User.current = User.find(1)
issue = Issue.generate!
child = nil
assert_difference 'Journal.count', 1 do

View File

@@ -2789,7 +2789,6 @@ class IssueTest < ActiveSupport::TestCase
end
def test_journalized_multi_custom_field
User.current = User.find(1)
field = IssueCustomField.create!(:name => 'filter', :field_format => 'list',
:is_filter => true, :is_for_all => true,
:tracker_ids => [1],
@@ -3466,55 +3465,4 @@ class IssueTest < ActiveSupport::TestCase
r = Issue.like('issue today')
assert_include Issue.find(7), r
end
def test_author_should_be_changed_when_user_with_permission_change_issue_author
Role.all.each do |r|
r.add_permission! :change_issue_author
end
User.current = User.find(2)
issue = Issue.generate!(:author => User.find(3))
assert_equal 3, issue.author_id
issue.safe_attributes = { 'author_id' => 4 }
assert_equal 4, issue.author_id
assert_not_equal 3, issue.author_id
end
def test_author_should_not_be_changed_when_user_without_permission_change_issue_author
Role.all.each do |r|
r.remove_permission! :change_issue_author
end
User.current = User.find(2)
issue = Issue.generate!(:author => User.find(3))
assert_equal 3, issue.author_id
issue.safe_attributes = { 'author_id' => 4 }
assert_not_equal 4, issue.author_id
assert_equal 3, issue.author_id
end
def test_create_should_create_journal_if_user_other_than_current_user_is_set_as_the_author
User.current = User.find(1)
issue = nil
assert_difference 'Journal.count' do
issue = Issue.generate!(author: User.find(2))
end
first_journal_detail = issue.journals.first.details.first
assert_equal 'author_id', first_journal_detail.prop_key
assert_equal '1', first_journal_detail.old_value
assert_equal '2', first_journal_detail.value
end
def test_create_should_create_journal_if_current_user_is_set_as_the_author
User.current = User.find(1)
issue = nil
assert_no_difference 'Journal.count' do
issue = Issue.generate!(author: User.current)
end
assert_not issue.journals.present?
end
end