Skip to content

Commit

Permalink
[api] add incident number in patchinfo also on maintenance_request ac…
Browse files Browse the repository at this point in the history
…cept
  • Loading branch information
adrianschroeter committed Apr 3, 2012
1 parent cd05aea commit 4c49dd4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/api/app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,12 @@ def command_changestate

# create patchinfo XML file
node = Builder::XmlMarkup.new(:indent=>2)
xml = node.patchinfo() do |n|
attrs = { }
if patchinfo.db_project.project_type == "maintenance_incident"
# this is a maintenance incident project, the sub project name is the maintenance ID
attrs[:incident] = patchinfo.db_project.name.gsub(/.*:/, '')
end
xml = node.patchinfo(attrs) do |n|
node.packager req.creator
node.category "recommended" # update_patchinfo may switch to security
node.rating "low"
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/source_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ def index_project_createpatchinfo
# create patchinfo XML file
node = Builder::XmlMarkup.new(:indent=>2)
attrs = { }
if MaintenanceIncident.count( :conditions => ["db_project_id = ?", pkg.db_project.id] )
if pkg.db_project.project_type == "maintenance_incident"
# this is a maintenance incident project, the sub project name is the maintenance ID
attrs[:incident] = pkg.db_project.name.gsub(/.*:/, '')
end
Expand Down
2 changes: 2 additions & 0 deletions src/api/test/functional/maintenance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def test_maintenance_request_from_foreign_project
get "/source/#{incidentProject}/patchinfo/_patchinfo"
assert_response :success
assert_xml_tag :tag => 'packager', :content => "tom"
assert_xml_tag( :tag => "patchinfo", :attributes => { :incident => "0" } )
assert_xml_tag :tag => 'description', :content => "To fix my bug"

# again but find update project automatically and use a linked package
Expand Down Expand Up @@ -203,6 +204,7 @@ def test_maintenance_request_from_foreign_project
assert_response :success
assert_xml_tag :tag => 'packager', :content => "tom"
assert_xml_tag :tag => 'description', :content => "To fix my bug"
assert_xml_tag( :tag => "patchinfo", :attributes => { :incident => "1" } )

# reopen ...
prepare_request_with_user "maintenance_coord", "power"
Expand Down

0 comments on commit 4c49dd4

Please sign in to comment.