Defect #33521 » diff.patch
| app/controllers/application_controller.rb | ||
|---|---|---|
| 411 | 411 |
@attachments = att || [] |
| 412 | 412 |
end |
| 413 | 413 | |
| 414 |
def parse_params_for_bulk_update(params) |
|
| 415 |
attributes = (params || {}).reject {|k, v| v.blank?}
|
|
| 416 |
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
|
|
| 417 |
if custom = attributes[:custom_field_values] |
|
| 418 |
custom.reject! {|k, v| v.blank?}
|
|
| 419 |
custom.keys.each do |k| |
|
| 414 |
def parse_none_to_blank(params) |
|
| 415 |
attributes = (params || {})
|
|
| 416 |
attributes.each_key {|k| attributes[k] = '' if attributes[k] == 'none'}
|
|
| 417 |
if (custom = attributes[:custom_field_values]) |
|
| 418 |
custom.each_key do |k| |
|
| 420 | 419 |
if custom[k].is_a?(Array) |
| 421 | 420 |
custom[k] << '' if custom[k].delete('__none__')
|
| 422 | 421 |
else |
| ... | ... | |
| 427 | 426 |
attributes |
| 428 | 427 |
end |
| 429 | 428 | |
| 429 |
def parse_params_for_bulk_update(params) |
|
| 430 |
attributes = (params || {}).reject {|k, v| v.blank?}
|
|
| 431 |
if custom = attributes[:custom_field_values] |
|
| 432 |
custom.reject! {|k, v| v.blank?}
|
|
| 433 |
end |
|
| 434 | ||
| 435 |
parse_none_to_blank(attributes) |
|
| 436 |
end |
|
| 437 | ||
| 430 | 438 |
# make sure that the user is a member of the project (or admin) if project is private |
| 431 | 439 |
# used as a before_action for actions that do not require any particular permission on the project |
| 432 | 440 |
def check_project_privacy |
| app/controllers/issues_controller.rb | ||
|---|---|---|
| 561 | 561 |
return false |
| 562 | 562 |
end |
| 563 | 563 |
end |
| 564 |
issue_attributes = parse_none_to_blank(issue_attributes) |
|
| 564 | 565 |
@issue.safe_attributes = issue_attributes |
| 565 | 566 |
@priorities = IssuePriority.active |
| 566 | 567 |
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 6660 | 6660 |
assert_equal 2, issue.reload.assigned_to_id |
| 6661 | 6661 |
end |
| 6662 | 6662 | |
| 6663 |
def test_update_with_value_of_none |
|
| 6664 |
@request.session[:user_id] = 2 |
|
| 6665 |
issue = Issue.find(1) |
|
| 6666 |
issue.custom_field_values = {1 => 'MySQL'}
|
|
| 6667 |
issue.assigned_to_id = 2 |
|
| 6668 |
issue.save! |
|
| 6669 | ||
| 6670 |
put( |
|
| 6671 |
:update, |
|
| 6672 |
params: {
|
|
| 6673 |
id: issue.id, |
|
| 6674 |
issue: {
|
|
| 6675 |
assigned_to_id: 'none', |
|
| 6676 |
category_id: 'none', |
|
| 6677 |
fixed_version_id: 'none', |
|
| 6678 |
custom_field_values: { 1 => '__none__' }
|
|
| 6679 |
} |
|
| 6680 |
} |
|
| 6681 |
) |
|
| 6682 | ||
| 6683 |
issue.reload |
|
| 6684 |
assert_nil issue.assigned_to |
|
| 6685 |
assert_nil issue.category |
|
| 6686 |
assert_nil issue.fixed_version |
|
| 6687 |
assert_equal '', issue.custom_field_value(1) |
|
| 6688 |
end |
|
| 6689 | ||
| 6663 | 6690 |
def test_get_bulk_edit |
| 6664 | 6691 |
@request.session[:user_id] = 2 |
| 6665 | 6692 |
get(:bulk_edit, :params => {:ids => [1, 3]})
|
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »