Feature #15348 » 0001-Add-an-option-to-control-issue-assignment-to-groups.patch
| app/models/group.rb | ||
|---|---|---|
| 39 | 39 |
scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)}
|
| 40 | 40 |
scope :givable, lambda {where(:type => 'Group')}
|
| 41 | 41 | |
| 42 |
# users.assignable is currently interpreted only for Group assignees. |
|
| 42 | 43 |
safe_attributes( |
| 43 | 44 |
'name', |
| 45 |
'assignable', |
|
| 44 | 46 |
'twofa_required', |
| 45 | 47 |
'user_ids', |
| 46 | 48 |
'custom_field_values', |
| app/models/project.rb | ||
|---|---|---|
| 604 | 604 |
def assignable_users(tracker=nil) |
| 605 | 605 |
return @assignable_users[tracker] if @assignable_users && @assignable_users[tracker] |
| 606 | 606 | |
| 607 |
types = ['User'] |
|
| 608 |
types << 'Group' if Setting.issue_group_assignment? |
|
| 609 | ||
| 610 | 607 |
scope = Principal. |
| 611 | 608 |
active. |
| 612 | 609 |
joins(:members => :roles). |
| 613 |
where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}).
|
|
| 610 |
where(:members => {:project_id => id}, :roles => {:assignable => true}).
|
|
| 614 | 611 |
distinct. |
| 615 | 612 |
sorted |
| 616 | 613 | |
| 614 |
if Setting.issue_group_assignment? |
|
| 615 |
# users.assignable is currently interpreted only for Group assignees. |
|
| 616 |
scope = scope.where(:type => 'User').or( |
|
| 617 |
scope.where(:type => 'Group', :assignable => true) |
|
| 618 |
) |
|
| 619 |
else |
|
| 620 |
scope = scope.where(:type => 'User') |
|
| 621 |
end |
|
| 622 | ||
| 617 | 623 |
if tracker |
| 618 | 624 |
# Rejects users that cannot the view the tracker |
| 619 | 625 |
roles = |
| app/views/groups/_form.html.erb | ||
|---|---|---|
| 4 | 4 |
<p><%= f.text_field :name, :required => true, :size => 60, |
| 5 | 5 |
:disabled => !@group.safe_attribute?('name') %></p>
|
| 6 | 6 |
<% unless @group.builtin? %> |
| 7 |
<% if Setting.issue_group_assignment? %> |
|
| 8 |
<p><%= f.check_box :assignable, :label => :field_group_issue_assignable %></p> |
|
| 9 |
<% end %> |
|
| 7 | 10 |
<p><%= f.check_box :twofa_required, disabled: !Setting.twofa_optional? %> |
| 8 | 11 |
<% if Setting.twofa_required? %> |
| 9 | 12 |
<em class="info"><%= l 'twofa_text_group_required' %></em> |
| config/locales/en.yml | ||
|---|---|---|
| 416 | 416 |
field_full_width_layout: Full width layout |
| 417 | 417 |
field_digest: Checksum |
| 418 | 418 |
field_default_assigned_to: Default assignee |
| 419 |
field_group_issue_assignable: Issues can be assigned to this group |
|
| 419 | 420 |
field_recently_used_projects: Number of recently used projects in jump box |
| 420 | 421 |
field_history_default_tab: Issue's history default tab |
| 421 | 422 |
field_unique_id: Unique ID |
| config/locales/ja.yml | ||
|---|---|---|
| 1233 | 1233 |
label_last_notes: 最新のコメント |
| 1234 | 1234 |
field_digest: チェックサム |
| 1235 | 1235 |
field_default_assigned_to: デフォルトの担当者 |
| 1236 |
field_group_issue_assignable: このグループにチケットを割り当て可能 |
|
| 1236 | 1237 |
setting_show_custom_fields_on_registration: アカウント登録画面でカスタムフィールドを表示 |
| 1237 | 1238 |
label_no_preview_alternative_html: このファイルはプレビューできません。 %{link} してください。
|
| 1238 | 1239 |
label_no_preview_download: ダウンロード |
| db/migrate/20260425000000_add_assignable_to_users.rb | ||
|---|---|---|
| 1 |
# frozen_string_literal: true |
|
| 2 | ||
| 3 |
class AddAssignableToUsers < ActiveRecord::Migration[8.1] |
|
| 4 |
def change |
|
| 5 |
add_column :users, :assignable, :boolean, :default => true, :null => false |
|
| 6 |
end |
|
| 7 |
end |
|
| test/functional/groups_controller_test.rb | ||
|---|---|---|
| 166 | 166 |
assert_select 'div#tab-content-memberships a.icon-link-break', :text => 'Remove' |
| 167 | 167 |
end |
| 168 | 168 | |
| 169 |
def test_edit_should_hide_assignable_checkbox_when_group_assignment_is_disabled |
|
| 170 |
with_settings :issue_group_assignment => '0' do |
|
| 171 |
get(:edit, :params => {:id => 10})
|
|
| 172 |
end |
|
| 173 |
assert_response :success |
|
| 174 |
assert_select 'input[name=?]', 'group[assignable]', :count => 0 |
|
| 175 |
end |
|
| 176 | ||
| 169 | 177 |
def test_update |
| 170 | 178 |
new_name = 'New name' |
| 171 |
put(
|
|
| 172 |
:update,
|
|
| 173 |
:params => {
|
|
| 174 |
:id => 10,
|
|
| 175 |
:group => {
|
|
| 176 |
:name => new_name
|
|
| 179 |
with_settings :issue_group_assignment => '1' do
|
|
| 180 |
put(
|
|
| 181 |
:update,
|
|
| 182 |
:params => {
|
|
| 183 |
:id => 10,
|
|
| 184 |
:group => {:name => new_name, :assignable => '0'}
|
|
| 177 | 185 |
} |
| 178 |
}
|
|
| 179 |
)
|
|
| 186 |
)
|
|
| 187 |
end
|
|
| 180 | 188 |
assert_redirected_to '/groups' |
| 181 | 189 |
group = Group.find(10) |
| 182 | 190 |
assert_equal new_name, group.name |
| 191 |
assert_not Group.find(10).assignable? |
|
| 183 | 192 |
end |
| 184 | 193 | |
| 185 | 194 |
def test_update_with_failure |
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 4335 | 4335 |
assert_equal group, issue.assigned_to |
| 4336 | 4336 |
end |
| 4337 | 4337 | |
| 4338 |
def test_post_new_with_non_assignable_group_assignment |
|
| 4339 |
group = Group.find(11) |
|
| 4340 |
group.update!(:assignable => false) |
|
| 4341 |
project = Project.find(1) |
|
| 4342 |
project.members << Member.new(:principal => group, :roles => [Role.givable.first]) |
|
| 4343 | ||
| 4344 |
with_settings :issue_group_assignment => '1' do |
|
| 4345 |
@request.session[:user_id] = 2 |
|
| 4346 |
assert_no_difference 'Issue.count' do |
|
| 4347 |
post( |
|
| 4348 |
:create, |
|
| 4349 |
:params => {
|
|
| 4350 |
:project_id => project.id, |
|
| 4351 |
:issue => {
|
|
| 4352 |
:tracker_id => 3, |
|
| 4353 |
:status_id => 1, |
|
| 4354 |
:subject => 'This is the test_new_with_non_assignable_group_assignment issue', |
|
| 4355 |
:assigned_to_id => group.id |
|
| 4356 |
} |
|
| 4357 |
} |
|
| 4358 |
) |
|
| 4359 |
end |
|
| 4360 |
end |
|
| 4361 |
assert_response :success |
|
| 4362 |
assert_select_error /Assignee is invalid/i |
|
| 4363 |
end |
|
| 4364 | ||
| 4338 | 4365 |
def test_post_create_without_start_date_and_default_start_date_is_not_creation_date |
| 4339 | 4366 |
with_settings :default_issue_start_date_to_creation_date => 0 do |
| 4340 | 4367 |
@request.session[:user_id] = 2 |
| ... | ... | |
| 7579 | 7606 |
end |
| 7580 | 7607 |
end |
| 7581 | 7608 | |
| 7609 |
def test_bulk_update_with_non_assignable_group_assignee |
|
| 7610 |
group = Group.find(11) |
|
| 7611 |
group.update!(:assignable => false) |
|
| 7612 |
project = Project.find(1) |
|
| 7613 |
project.members << Member.new(:principal => group, :roles => [Role.givable.first]) |
|
| 7614 | ||
| 7615 |
@request.session[:user_id] = 2 |
|
| 7616 |
original_assignees = Issue.where(:id => [1, 2]).collect(&:assigned_to) |
|
| 7617 | ||
| 7618 |
with_settings :issue_group_assignment => '1' do |
|
| 7619 |
post( |
|
| 7620 |
:bulk_update, |
|
| 7621 |
:params => {
|
|
| 7622 |
:ids => [1, 2], |
|
| 7623 |
:notes => 'Bulk editing', |
|
| 7624 |
:issue => {
|
|
| 7625 |
:priority_id => '', |
|
| 7626 |
:assigned_to_id => group.id, |
|
| 7627 |
:custom_field_values => {
|
|
| 7628 |
'2' => '' |
|
| 7629 |
} |
|
| 7630 |
} |
|
| 7631 |
} |
|
| 7632 |
) |
|
| 7633 |
end |
|
| 7634 | ||
| 7635 |
assert_response :success |
|
| 7636 |
assert_equal original_assignees, Issue.where(:id => [1, 2]).collect(&:assigned_to) |
|
| 7637 |
assert_select_error /Assignee is invalid/i |
|
| 7638 |
end |
|
| 7639 | ||
| 7582 | 7640 |
def test_bulk_update_on_different_projects |
| 7583 | 7641 |
@request.session[:user_id] = 2 |
| 7584 | 7642 |
# update issues priority |
| test/unit/issue_test.rb | ||
|---|---|---|
| 2736 | 2736 |
end |
| 2737 | 2737 |
end |
| 2738 | 2738 | |
| 2739 |
test "#assignable_users with issue_group_assignment should exclude non-assignable groups" do |
|
| 2740 |
issue = Issue.new(:project => Project.find(2)) |
|
| 2741 |
Group.find(11).update!(:assignable => false) |
|
| 2742 | ||
| 2743 |
with_settings :issue_group_assignment => '1' do |
|
| 2744 |
assert_not_include Group.find(11), issue.assignable_users |
|
| 2745 |
end |
|
| 2746 |
end |
|
| 2747 | ||
| 2739 | 2748 |
def test_assignable_users_should_not_include_builtin_groups |
| 2740 | 2749 |
Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [1]) |
| 2741 | 2750 |
Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [1]) |
| ... | ... | |
| 2759 | 2768 |
assert_not_include user, issue2.assignable_users |
| 2760 | 2769 |
end |
| 2761 | 2770 | |
| 2771 |
def test_assignable_users_should_include_the_current_group_assignee_even_if_group_is_no_longer_assignable |
|
| 2772 |
group = Group.generate! |
|
| 2773 |
Member.create!(:project_id => 1, :principal => group, :role_ids => [1]) |
|
| 2774 | ||
| 2775 |
with_settings :issue_group_assignment => '1' do |
|
| 2776 |
issue = Issue.generate!(:project_id => 1, :assigned_to => group) |
|
| 2777 |
group.update!(:assignable => false) |
|
| 2778 |
assert_include group, Issue.find(issue.id).assignable_users |
|
| 2779 |
end |
|
| 2780 |
end |
|
| 2781 | ||
| 2762 | 2782 |
def test_create_should_send_email_notification |
| 2763 | 2783 |
ActionMailer::Base.deliveries.clear |
| 2764 | 2784 |
issue = Issue.new(:project_id => 1, :tracker_id => 1, |
- « Previous
- 1
- 2
- Next »