Project

General

Profile

Patch #14828 » add_support_for_deleting_attachments_via_api_trunk_r15327.patch

Takenori TAKAKI, 2016-04-12 02:51

View differences:

app/controllers/attachments_controller.rb
before_filter :delete_authorize, :only => :destroy
before_filter :authorize_global, :only => :upload
accept_api_auth :show, :download, :thumbnail, :upload
accept_api_auth :show, :download, :thumbnail, :upload, :destroy
def show
respond_to do |format|
......
respond_to do |format|
format.html { redirect_to_referer_or project_path(@project) }
format.js
format.api { render_api_ok }
end
end
test/integration/api_test/attachments_test.rb
assert_response :success
end
test "Destroy /attachments/:id.xml should return ok and deleted Attachment" do
assert_difference 'Attachment.count', -1 do
delete '/attachments/7.xml', {}, credentials('jsmith')
assert_response :ok
assert_equal '', response.body
end
assert_nil Attachment.find_by_id(7)
end
test "Destroy /attachments/:id.json should return ok and deleted Attachment" do
assert_difference 'Attachment.count', -1 do
delete '/attachments/7.json', {}, credentials('jsmith')
assert_response :ok
assert_equal '', response.body
end
assert_nil Attachment.find_by_id(7)
end
test "POST /uploads.xml should return the token" do
set_tmp_attachments_directory
assert_difference 'Attachment.count' do
(2-2/2)