Project

General

Profile

Defect #23766 ยป 0001-Allow-to-specify-projects_id-as-identifier-in-issue-creation.diff

Holger Just, 2016-09-06 12:00

View differences:

app/models/issue.rb
# 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 allowed_target_projects(user).where(:id => p.to_i).exists?
self.project_id = p
if p.is_a?(String) && !p.match(/^\d*$/)
p_id = Project.find_by_identifier(p).try(:id)
else
p_id = p.to_i
end
if allowed_target_projects(user).where(:id => p_id).exists?
self.project_id = p_id
end
if project_id_changed? && attrs['category_id'].to_s == category_id_was.to_s
test/functional/issues_controller_test.rb
assert_equal 2, issue.tracker_id
end
def test_create_with_project_identifier
@request.session[:user_id] = 2
assert_difference 'Issue.count' do
post :create,
:issue => {:project_id => 'subproject1',
:tracker_id => 2,
:subject => 'Foo'}
assert_response 302
end
issue = Issue.order('id DESC').first
assert_equal 3, issue.project_id
assert_equal 2, issue.tracker_id
end
def test_create_without_project_id_and_continue_should_redirect_without_project_id
@request.session[:user_id] = 2
    (1-1/1)