Write the new role in reassign checkbox label

This commit is contained in:
Anton Khorev 2025-02-05 13:00:04 +03:00
parent 06cece27fe
commit b3a0038d27
3 changed files with 27 additions and 7 deletions

View file

@ -21,7 +21,8 @@
<%= bootstrap_form_for @new_comment, :url => issue_comments_path(@issue) do |f| %> <%= bootstrap_form_for @new_comment, :url => issue_comments_path(@issue) do |f| %>
<%= f.richtext_field :body, :cols => 80, :rows => 20, :hide_label => true %> <%= f.richtext_field :body, :cols => 80, :rows => 20, :hide_label => true %>
<%= f.form_group do %> <%= f.form_group do %>
<%= f.check_box :reassign, { :label => t(".reassign_param"), :id => "reassign", :name => "reassign", :checked => false }, true, false %> <%= f.check_box :reassign, { :label => @issue.assigned_role == "administrator" ? t(".reassign_to_moderators") : t(".reassign_to_administrators"),
:id => "reassign", :name => "reassign", :checked => false }, true, false %>
<% end %> <% end %>
<%= f.primary %> <%= f.primary %>
<% end %> <% end %>

View file

@ -1551,7 +1551,8 @@ en:
reopened: Issue status has been set to 'Open' reopened: Issue status has been set to 'Open'
comments: comments:
comment_from_html: "Comment from %{user_link} on %{comment_created_at}" comment_from_html: "Comment from %{user_link} on %{comment_created_at}"
reassign_param: Reassign Issue? reassign_to_moderators: Reassign Issue to Moderators
reassign_to_administrators: Reassign Issue to Administrators
reports: reports:
reported_by_html: "Reported as %{category} by %{user} on %{updated_at}" reported_by_html: "Reported as %{category} by %{user} on %{updated_at}"
helper: helper:

View file

@ -114,15 +114,15 @@ class IssuesTest < ApplicationSystemTestCase
assert_equal("test comment", issue.comments.first.body) assert_equal("test comment", issue.comments.first.body)
end end
def test_reassign_issue def test_reassign_issue_to_moderators
issue = create(:issue) issue = create(:issue, :assigned_role => "administrator")
assert_equal "administrator", issue.assigned_role
sign_in_as(create(:administrator_user)) sign_in_as(create(:administrator_user))
visit issue_path(issue) visit issue_path(issue)
assert_unchecked_field "Reassign Issue to Moderators"
fill_in :issue_comment_body, :with => "reassigning to moderators" fill_in :issue_comment_body, :with => "reassigning to moderators"
check :reassign check "Reassign Issue to Moderators"
click_on "Add Comment" click_on "Add Comment"
assert_content "and the issue was reassigned" assert_content "and the issue was reassigned"
@ -132,6 +132,24 @@ class IssuesTest < ApplicationSystemTestCase
assert_equal "moderator", issue.assigned_role assert_equal "moderator", issue.assigned_role
end end
def test_reassign_issue_to_administrators
issue = create(:issue, :assigned_role => "moderator")
sign_in_as(create(:moderator_user))
visit issue_path(issue)
assert_unchecked_field "Reassign Issue to Administrators"
fill_in :issue_comment_body, :with => "reassigning to administrators"
check "Reassign Issue to Administrators"
click_on "Add Comment"
assert_content "and the issue was reassigned"
assert_current_path issues_path(:status => "open")
issue.reload
assert_equal "administrator", issue.assigned_role
end
def test_reassign_issue_as_super_user def test_reassign_issue_as_super_user
issue = create(:issue) issue = create(:issue)
sign_in_as(create(:super_user)) sign_in_as(create(:super_user))
@ -139,7 +157,7 @@ class IssuesTest < ApplicationSystemTestCase
visit issue_path(issue) visit issue_path(issue)
fill_in :issue_comment_body, :with => "reassigning to moderators" fill_in :issue_comment_body, :with => "reassigning to moderators"
check :reassign check "Reassign Issue to Moderators"
click_on "Add Comment" click_on "Add Comment"
assert_content "and the issue was reassigned" assert_content "and the issue was reassigned"