Skip to content

Commit

Permalink
[api] fix double render crash when trying to delete a not existing re…
Browse files Browse the repository at this point in the history
…po via request accept
  • Loading branch information
adrianschroeter committed Feb 8, 2013
1 parent b5e110e commit f34b297
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ def command_changestate
r=Repository.find_by_project_and_repo_name(target_project.name, action.target_repository)
unless r
render_error :status => 400, :errorcode => "repository_missing", :message => "The repository #{target_project} / #{action.target_repository} does not exist"
return
end
else
# remove entire project
Expand Down
11 changes: 11 additions & 0 deletions src/api/test/functional/request_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,11 @@ def test_repository_delete_request
node = ActiveXML::Node.new(@response.body)
assert node.has_attribute?(:id)
iddelete = node.value('id')
post "/request?cmd=create", rq
assert_response :success
node = ActiveXML::Node.new(@response.body)
assert node.has_attribute?(:id)
iddelete2 = node.value('id')

prepare_request_with_user "Iggy", "asdfasdf"
post "/request/#{iddelete}?cmd=changestate&newstate=accepted"
Expand All @@ -2151,6 +2156,12 @@ def test_repository_delete_request
assert_xml_tag :parent => { :tag => 'repository', :attributes => { :name => "base" } },
:tag => 'path', :attributes => { :project => "deleted", :repository => "deleted" }

# try again and fail
prepare_request_with_user "Iggy", "asdfasdf"
post "/request/#{iddelete2}?cmd=changestate&newstate=accepted"
assert_response 400
assert_xml_tag( :tag => "status", :attributes => { :code => 'repository_missing' } )

# cleanup
delete "/source/home:Iggy:todo"
assert_response :success
Expand Down

0 comments on commit f34b297

Please sign in to comment.