Patch #14828 » add_support_for_deleting_attachments_via_api_trunk_r15327.patch
| app/controllers/attachments_controller.rb | ||
|---|---|---|
| 22 | 22 |
before_filter :delete_authorize, :only => :destroy |
| 23 | 23 |
before_filter :authorize_global, :only => :upload |
| 24 | 24 | |
| 25 |
accept_api_auth :show, :download, :thumbnail, :upload |
|
| 25 |
accept_api_auth :show, :download, :thumbnail, :upload, :destroy
|
|
| 26 | 26 | |
| 27 | 27 |
def show |
| 28 | 28 |
respond_to do |format| |
| ... | ... | |
| 130 | 130 |
respond_to do |format| |
| 131 | 131 |
format.html { redirect_to_referer_or project_path(@project) }
|
| 132 | 132 |
format.js |
| 133 |
format.api { render_api_ok }
|
|
| 133 | 134 |
end |
| 134 | 135 |
end |
| 135 | 136 | |
| test/integration/api_test/attachments_test.rb | ||
|---|---|---|
| 81 | 81 |
assert_response :success |
| 82 | 82 |
end |
| 83 | 83 | |
| 84 |
test "Destroy /attachments/:id.xml should return ok and deleted Attachment" do |
|
| 85 |
assert_difference 'Attachment.count', -1 do |
|
| 86 |
delete '/attachments/7.xml', {}, credentials('jsmith')
|
|
| 87 |
assert_response :ok |
|
| 88 |
assert_equal '', response.body |
|
| 89 |
end |
|
| 90 |
assert_nil Attachment.find_by_id(7) |
|
| 91 |
end |
|
| 92 | ||
| 93 |
test "Destroy /attachments/:id.json should return ok and deleted Attachment" do |
|
| 94 |
assert_difference 'Attachment.count', -1 do |
|
| 95 |
delete '/attachments/7.json', {}, credentials('jsmith')
|
|
| 96 |
assert_response :ok |
|
| 97 |
assert_equal '', response.body |
|
| 98 |
end |
|
| 99 |
assert_nil Attachment.find_by_id(7) |
|
| 100 |
end |
|
| 101 | ||
| 84 | 102 |
test "POST /uploads.xml should return the token" do |
| 85 | 103 |
set_tmp_attachments_directory |
| 86 | 104 |
assert_difference 'Attachment.count' do |
- « Previous
- 1
- 2
- Next »