Feature #15348 » 0001-Add-an-option-to-control-issue-assignment-to-groups.patch
| app/models/group.rb | ||
|---|---|---|
|
scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)}
|
||
|
scope :givable, lambda {where(:type => 'Group')}
|
||
|
# users.assignable is currently interpreted only for Group assignees.
|
||
|
safe_attributes(
|
||
|
'name',
|
||
|
'assignable',
|
||
|
'twofa_required',
|
||
|
'user_ids',
|
||
|
'custom_field_values',
|
||
| app/models/project.rb | ||
|---|---|---|
|
def assignable_users(tracker=nil)
|
||
|
return @assignable_users[tracker] if @assignable_users && @assignable_users[tracker]
|
||
|
types = ['User']
|
||
|
types << 'Group' if Setting.issue_group_assignment?
|
||
|
scope = Principal.
|
||
|
active.
|
||
|
joins(:members => :roles).
|
||
|
where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}).
|
||
|
where(:members => {:project_id => id}, :roles => {:assignable => true}).
|
||
|
distinct.
|
||
|
sorted
|
||
|
if Setting.issue_group_assignment?
|
||
|
# users.assignable is currently interpreted only for Group assignees.
|
||
|
scope = scope.where(:type => 'User').or(
|
||
|
scope.where(:type => 'Group', :assignable => true)
|
||
|
)
|
||
|
else
|
||
|
scope = scope.where(:type => 'User')
|
||
|
end
|
||
|
if tracker
|
||
|
# Rejects users that cannot the view the tracker
|
||
|
roles =
|
||
| app/views/groups/_form.html.erb | ||
|---|---|---|
|
<p><%= f.text_field :name, :required => true, :size => 60,
|
||
|
:disabled => !@group.safe_attribute?('name') %></p>
|
||
|
<% unless @group.builtin? %>
|
||
|
<% if Setting.issue_group_assignment? %>
|
||
|
<p><%= f.check_box :assignable, :label => :field_group_issue_assignable %></p>
|
||
|
<% end %>
|
||
|
<p><%= f.check_box :twofa_required, disabled: !Setting.twofa_optional? %>
|
||
|
<% if Setting.twofa_required? %>
|
||
|
<em class="info"><%= l 'twofa_text_group_required' %></em>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
field_full_width_layout: Full width layout
|
||
|
field_digest: Checksum
|
||
|
field_default_assigned_to: Default assignee
|
||
|
field_group_issue_assignable: Issues can be assigned to this group
|
||
|
field_recently_used_projects: Number of recently used projects in jump box
|
||
|
field_history_default_tab: Issue's history default tab
|
||
|
field_unique_id: Unique ID
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
label_last_notes: 最新のコメント
|
||
|
field_digest: チェックサム
|
||
|
field_default_assigned_to: デフォルトの担当者
|
||
|
field_group_issue_assignable: このグループにチケットを割り当て可能
|
||
|
setting_show_custom_fields_on_registration: アカウント登録画面でカスタムフィールドを表示
|
||
|
label_no_preview_alternative_html: このファイルはプレビューできません。 %{link} してください。
|
||
|
label_no_preview_download: ダウンロード
|
||
| db/migrate/20260425000000_add_assignable_to_users.rb | ||
|---|---|---|
|
# frozen_string_literal: true
|
||
|
class AddAssignableToUsers < ActiveRecord::Migration[8.1]
|
||
|
def change
|
||
|
add_column :users, :assignable, :boolean, :default => true, :null => false
|
||
|
end
|
||
|
end
|
||
| test/functional/groups_controller_test.rb | ||
|---|---|---|
|
assert_select 'div#tab-content-memberships a.icon-link-break', :text => 'Remove'
|
||
|
end
|
||
|
def test_edit_should_hide_assignable_checkbox_when_group_assignment_is_disabled
|
||
|
with_settings :issue_group_assignment => '0' do
|
||
|
get(:edit, :params => {:id => 10})
|
||
|
end
|
||
|
assert_response :success
|
||
|
assert_select 'input[name=?]', 'group[assignable]', :count => 0
|
||
|
end
|
||
|
def test_update
|
||
|
new_name = 'New name'
|
||
|
put(
|
||
|
:update,
|
||
|
:params => {
|
||
|
:id => 10,
|
||
|
:group => {
|
||
|
:name => new_name
|
||
|
with_settings :issue_group_assignment => '1' do
|
||
|
put(
|
||
|
:update,
|
||
|
:params => {
|
||
|
:id => 10,
|
||
|
:group => {:name => new_name, :assignable => '0'}
|
||
|
}
|
||
|
}
|
||
|
)
|
||
|
)
|
||
|
end
|
||
|
assert_redirected_to '/groups'
|
||
|
group = Group.find(10)
|
||
|
assert_equal new_name, group.name
|
||
|
assert_not Group.find(10).assignable?
|
||
|
end
|
||
|
def test_update_with_failure
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
assert_equal group, issue.assigned_to
|
||
|
end
|
||
|
def test_post_new_with_non_assignable_group_assignment
|
||
|
group = Group.find(11)
|
||
|
group.update!(:assignable => false)
|
||
|
project = Project.find(1)
|
||
|
project.members << Member.new(:principal => group, :roles => [Role.givable.first])
|
||
|
with_settings :issue_group_assignment => '1' do
|
||
|
@request.session[:user_id] = 2
|
||
|
assert_no_difference 'Issue.count' do
|
||
|
post(
|
||
|
:create,
|
||
|
:params => {
|
||
|
:project_id => project.id,
|
||
|
:issue => {
|
||
|
:tracker_id => 3,
|
||
|
:status_id => 1,
|
||
|
:subject => 'This is the test_new_with_non_assignable_group_assignment issue',
|
||
|
:assigned_to_id => group.id
|
||
|
}
|
||
|
}
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
assert_response :success
|
||
|
assert_select_error /Assignee is invalid/i
|
||
|
end
|
||
|
def test_post_create_without_start_date_and_default_start_date_is_not_creation_date
|
||
|
with_settings :default_issue_start_date_to_creation_date => 0 do
|
||
|
@request.session[:user_id] = 2
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def test_bulk_update_with_non_assignable_group_assignee
|
||
|
group = Group.find(11)
|
||
|
group.update!(:assignable => false)
|
||
|
project = Project.find(1)
|
||
|
project.members << Member.new(:principal => group, :roles => [Role.givable.first])
|
||
|
@request.session[:user_id] = 2
|
||
|
original_assignees = Issue.where(:id => [1, 2]).collect(&:assigned_to)
|
||
|
with_settings :issue_group_assignment => '1' do
|
||
|
post(
|
||
|
:bulk_update,
|
||
|
:params => {
|
||
|
:ids => [1, 2],
|
||
|
:notes => 'Bulk editing',
|
||
|
:issue => {
|
||
|
:priority_id => '',
|
||
|
:assigned_to_id => group.id,
|
||
|
:custom_field_values => {
|
||
|
'2' => ''
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
)
|
||
|
end
|
||
|
assert_response :success
|
||
|
assert_equal original_assignees, Issue.where(:id => [1, 2]).collect(&:assigned_to)
|
||
|
assert_select_error /Assignee is invalid/i
|
||
|
end
|
||
|
def test_bulk_update_on_different_projects
|
||
|
@request.session[:user_id] = 2
|
||
|
# update issues priority
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
test "#assignable_users with issue_group_assignment should exclude non-assignable groups" do
|
||
|
issue = Issue.new(:project => Project.find(2))
|
||
|
Group.find(11).update!(:assignable => false)
|
||
|
with_settings :issue_group_assignment => '1' do
|
||
|
assert_not_include Group.find(11), issue.assignable_users
|
||
|
end
|
||
|
end
|
||
|
def test_assignable_users_should_not_include_builtin_groups
|
||
|
Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [1])
|
||
|
Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [1])
|
||
| ... | ... | |
|
assert_not_include user, issue2.assignable_users
|
||
|
end
|
||
|
def test_assignable_users_should_include_the_current_group_assignee_even_if_group_is_no_longer_assignable
|
||
|
group = Group.generate!
|
||
|
Member.create!(:project_id => 1, :principal => group, :role_ids => [1])
|
||
|
with_settings :issue_group_assignment => '1' do
|
||
|
issue = Issue.generate!(:project_id => 1, :assigned_to => group)
|
||
|
group.update!(:assignable => false)
|
||
|
assert_include group, Issue.find(issue.id).assignable_users
|
||
|
end
|
||
|
end
|
||
|
def test_create_should_send_email_notification
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
issue = Issue.new(:project_id => 1, :tracker_id => 1,
|
||
- « Previous
- 1
- 2
- Next »