Skip to content

Commit

Permalink
[api] hot-fix accepting of maintenance incident requests with cleanup…
Browse files Browse the repository at this point in the history
… again

Regression from 8b4d426

Doing request revoke in model is right, but we need to be
able to opt-out the request which is currently processed
  • Loading branch information
adrianschroeter committed Sep 17, 2015
1 parent 0be0baf commit 90d50c9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/Gemfile.lock
Expand Up @@ -341,4 +341,4 @@ DEPENDENCIES
web-console (~> 2.0)
webmock (>= 1.18.0)
xmlhash (>= 1.3.6)
yajl-ruby
yajl-ruby
1 change: 1 addition & 0 deletions src/api/app/controllers/source_controller.rb
Expand Up @@ -185,6 +185,7 @@ def delete_project
path = project.source_path
path << build_query_from_hash(params, [:user, :comment])

project.revoke_requests
project.destroy

Suse::Backend.delete path
Expand Down
4 changes: 3 additions & 1 deletion src/api/app/models/project.rb
Expand Up @@ -136,7 +136,9 @@ def cleanup_before_destroy
end

# revoke all requests
revoke_requests
# FIXME: this is breaking request accepting with cleanup, if the project
# will be removed during that
# revoke_requests
end

def delete_on_backend(comment = nil)
Expand Down
12 changes: 10 additions & 2 deletions src/api/test/functional/maintenance_test.rb
Expand Up @@ -225,6 +225,9 @@ def test_maintenance_request_from_foreign_and_remote_project
<action type="maintenance_incident">
<source project="home:tom:branches:kde4" package="kdelibs" />
<target project="My:Maintenance" releaseproject="BaseDistro2.0" />
<options>
<sourceupdate>cleanup</sourceupdate>
</options>
</action>
<description>To fix my bug</description>
<state name="new" />
Expand Down Expand Up @@ -252,6 +255,10 @@ def test_maintenance_request_from_foreign_and_remote_project
# accept request
prepare_request_with_user 'maintenance_coord', 'power'

# not allowed to remove project
delete "/source/home:tom:branches:kde4"
assert_response 403

post "/request/#{id2}?cmd=changestate&newstate=accepted&force=1"
assert_response :success
get "/request/#{id2}"
Expand All @@ -261,6 +268,9 @@ def test_maintenance_request_from_foreign_and_remote_project
assert_xml_tag( :tag => 'acceptinfo' )
post "/request/#{id2}?cmd=diff&view=xml", nil
assert_response :success
# project got cleaned up
get "/source/home:tom:branches:kde4"
assert_response 404

get "/request/#{id2}"
assert_response :success
Expand Down Expand Up @@ -289,8 +299,6 @@ def test_maintenance_request_from_foreign_and_remote_project
assert_response :success
delete '/source/BaseDistro2.0:LinkedUpdateProject/kdelibs'
assert_response :success
delete '/source/home:tom:branches:kde4'
assert_response :success
end

def test_OBS_BranchTarget
Expand Down
1 change: 0 additions & 1 deletion src/api/test/functional/request_controller_test.rb
Expand Up @@ -196,7 +196,6 @@ def test_submit_request_of_new_package
{"who"=>"Iggy", "when"=>"2010-07-12T00:00:01", "description"=>"Request got a new priority: critical => low", "comment"=>"dontcare"},
{"who"=>"Iggy", "when"=>"2010-07-12T00:00:02", "description"=>"Request got declined", "comment"=>"notgood"},
{"who"=>"Iggy", "when"=>"2010-07-12T00:00:03", "description"=>"Request got reopened", "comment"=>"oops"},
{"who"=>"Iggy", "when"=>"2010-07-12T00:00:04", "description"=>"Request got revoked", "comment"=>"The source project 'home:Iggy:branches:home:Iggy' was removed"},
{"who"=>"Iggy", "when"=>"2010-07-12T00:00:04", "description"=>"Request got accepted", "comment"=>"approved"}
],
'description' => 'DESCRIPTION IS HERE'
Expand Down

0 comments on commit 90d50c9

Please sign in to comment.