Defect #13762 » 0001-Check-attributes-against-the-given-user-in-Issue-saf.patch
| app/models/issue.rb | ||
|---|---|---|
|
attrs = attrs.deep_dup
|
||
|
# Project and Tracker must be set before since new_statuses_allowed_to depends on it.
|
||
|
if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
|
||
|
if (p = attrs.delete('project_id')) && safe_attribute?('project_id', user)
|
||
|
if p.is_a?(String) && !/^\d*$/.match?(p)
|
||
|
p_id = Project.find_by_identifier(p).try(:id)
|
||
|
else
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id')
|
||
|
if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id', user)
|
||
|
if allowed_target_trackers(user).where(:id => t.to_i).exists?
|
||
|
self.tracker_id = t
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
statuses_allowed = new_statuses_allowed_to(user)
|
||
|
if (s = attrs.delete('status_id')) && safe_attribute?('status_id')
|
||
|
if (s = attrs.delete('status_id')) && safe_attribute?('status_id', user)
|
||
|
if statuses_allowed.collect(&:id).include?(s.to_i)
|
||
|
self.status_id = s
|
||
|
end
|
||
| ... | ... | |
|
!attrs.key?('is_private') && safe_attribute?('is_private', user)
|
||
|
attrs['is_private'] = '1'
|
||
|
end
|
||
|
if (u = attrs.delete('assigned_to_id')) && safe_attribute?('assigned_to_id')
|
||
|
if (u = attrs.delete('assigned_to_id')) && safe_attribute?('assigned_to_id', user)
|
||
|
self.assigned_to_id = u
|
||
|
end
|
||
|
attrs = delete_unsafe_attributes(attrs, user)
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
assert_equal Date.parse('2012-07-16'), issue.due_date
|
||
|
end
|
||
|
def test_safe_attributes_should_check_status_against_the_given_user
|
||
|
User.current = nil
|
||
|
issue = Issue.find(1)
|
||
|
issue.send(:safe_attributes=, {'status_id' => '5'}, User.find(2))
|
||
|
assert_equal 5, issue.status_id
|
||
|
end
|
||
|
def test_safe_attributes_should_check_project_against_the_given_user
|
||
|
User.current = nil
|
||
|
issue = Issue.find(1)
|
||
|
issue.send(:safe_attributes=, {'project_id' => '2'}, User.find(2))
|
||
|
assert_equal 2, issue.project_id
|
||
|
end
|
||
|
def test_safe_attributes_should_check_tracker_against_the_given_user
|
||
|
User.current = nil
|
||
|
issue = Issue.find(1)
|
||
|
issue.send(:safe_attributes=, {'tracker_id' => '2'}, User.find(2))
|
||
|
assert_equal 2, issue.tracker_id
|
||
|
end
|
||
|
def test_safe_attributes_should_check_assignee_against_the_given_user
|
||
|
User.current = nil
|
||
|
issue = Issue.find(1)
|
||
|
issue.send(:safe_attributes=, {'assigned_to_id' => '3'}, User.find(2))
|
||
|
assert_equal 3, issue.assigned_to_id
|
||
|
end
|
||
|
def test_required_attributes_should_be_validated
|
||
|
cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string',
|
||
|
:is_for_all => true, :tracker_ids => [1, 2])
|
||