diff options
author | Go MAEDA <maeda@farend.jp> | 2022-11-16 09:24:17 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2022-11-16 09:24:17 +0000 |
commit | b3e42149896a6199ee6225f1f6bad8c4778adf1f (patch) | |
tree | fdbf124a205bc3fe76d8e20a88b52ca43ce4095c /test/helpers/issues_helper_test.rb | |
parent | f972b5bfa655972b2d469dc79c3b9ba3a971d457 (diff) | |
download | redmine-b3e42149896a6199ee6225f1f6bad8c4778adf1f.tar.gz redmine-b3e42149896a6199ee6225f1f6bad8c4778adf1f.zip |
Add the ability to change the author of an issue (#1739).
Patch by Vladimir Kovacik, Jiri Stepanek, Aighan Pacobilch, Olivier Houdas, Takenori TAKAKI, and Mizuki ISHIKAWA.
git-svn-id: https://svn.redmine.org/redmine/trunk@21958 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/helpers/issues_helper_test.rb')
-rw-r--r-- | test/helpers/issues_helper_test.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/helpers/issues_helper_test.rb b/test/helpers/issues_helper_test.rb index 6992001ac..91cdc7990 100644 --- a/test/helpers/issues_helper_test.rb +++ b/test/helpers/issues_helper_test.rb @@ -465,4 +465,62 @@ class IssuesHelperTest < Redmine::HelperTest assert_include "<a href=\"/issues?issue_id=#{open_issue.id}%2C#{closed_issue.id}&set_filter=true&status_id=o\">1 open</a>", html assert_include "<a href=\"/issues?issue_id=#{open_issue.id}%2C#{closed_issue.id}&set_filter=true&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 |