Project

General

Profile

Defect #33521 » diff.patch

Mizuki ISHIKAWA, 2021-08-04 10:49

View differences:

app/controllers/application_controller.rb
@attachments = att || []
end
def parse_params_for_bulk_update(params)
attributes = (params || {}).reject {|k, v| v.blank?}
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
if custom = attributes[:custom_field_values]
custom.reject! {|k, v| v.blank?}
custom.keys.each do |k|
def parse_none_to_blank(params)
attributes = (params || {})
attributes.each_key {|k| attributes[k] = '' if attributes[k] == 'none'}
if (custom = attributes[:custom_field_values])
custom.each_key do |k|
if custom[k].is_a?(Array)
custom[k] << '' if custom[k].delete('__none__')
else
......
attributes
end
def parse_params_for_bulk_update(params)
attributes = (params || {}).reject {|k, v| v.blank?}
if custom = attributes[:custom_field_values]
custom.reject! {|k, v| v.blank?}
end
parse_none_to_blank(attributes)
end
# make sure that the user is a member of the project (or admin) if project is private
# used as a before_action for actions that do not require any particular permission on the project
def check_project_privacy
app/controllers/issues_controller.rb
return false
end
end
issue_attributes = parse_none_to_blank(issue_attributes)
@issue.safe_attributes = issue_attributes
@priorities = IssuePriority.active
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
test/functional/issues_controller_test.rb
assert_equal 2, issue.reload.assigned_to_id
end
def test_update_with_value_of_none
@request.session[:user_id] = 2
issue = Issue.find(1)
issue.custom_field_values = {1 => 'MySQL'}
issue.assigned_to_id = 2
issue.save!
put(
:update,
params: {
id: issue.id,
issue: {
assigned_to_id: 'none',
category_id: 'none',
fixed_version_id: 'none',
custom_field_values: { 1 => '__none__' }
}
}
)
issue.reload
assert_nil issue.assigned_to
assert_nil issue.category
assert_nil issue.fixed_version
assert_equal '', issue.custom_field_value(1)
end
def test_get_bulk_edit
@request.session[:user_id] = 2
get(:bulk_edit, :params => {:ids => [1, 3]})
(5-5/5)