diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-01 13:22:35 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-01 13:22:35 +0000 |
commit | 696c51085246058408c5f709927df8db07b90d54 (patch) | |
tree | 782cdb47dbff4378ccbdd0ca861ea179be8cb8e4 /test/integration | |
parent | a2bcc9c40eb99b901f2f92b2f4fa1f840583c6b8 (diff) | |
download | redmine-696c51085246058408c5f709927df8db07b90d54.tar.gz redmine-696c51085246058408c5f709927df8db07b90d54.zip |
Add support for updating attachments over REST API (#22356).
git-svn-id: http://svn.redmine.org/redmine/trunk@15861 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/api_test/api_routing_test.rb | 1 | ||||
-rw-r--r-- | test/integration/api_test/attachments_test.rb | 23 | ||||
-rw-r--r-- | test/integration/routing/attachments_test.rb | 4 |
3 files changed, 26 insertions, 2 deletions
diff --git a/test/integration/api_test/api_routing_test.rb b/test/integration/api_test/api_routing_test.rb index ccdb93307..5e686a9e2 100644 --- a/test/integration/api_test/api_routing_test.rb +++ b/test/integration/api_test/api_routing_test.rb @@ -21,6 +21,7 @@ class Redmine::ApiTest::ApiRoutingTest < Redmine::ApiTest::Routing def test_attachments should_route 'GET /attachments/1' => 'attachments#show', :id => '1' + should_route 'PATCH /attachments/1' => 'attachments#update', :id => '1' should_route 'POST /uploads' => 'attachments#upload' end diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb index c7d2869ee..312920922 100644 --- a/test/integration/api_test/attachments_test.rb +++ b/test/integration/api_test/attachments_test.rb @@ -99,6 +99,29 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base assert_nil Attachment.find_by_id(7) end + test "PATCH /attachments/:id.json should update the attachment" do + patch '/attachments/7.json', + {:attachment => {:filename => 'renamed.zip', :description => 'updated'}}, + credentials('jsmith') + + assert_response :ok + assert_equal 'application/json', response.content_type + attachment = Attachment.find(7) + assert_equal 'renamed.zip', attachment.filename + assert_equal 'updated', attachment.description + end + + test "PATCH /attachments/:id.json with failure should return the errors" do + patch '/attachments/7.json', + {:attachment => {:filename => '', :description => 'updated'}}, + credentials('jsmith') + + assert_response 422 + assert_equal 'application/json', response.content_type + json = ActiveSupport::JSON.decode(response.body) + assert_include "File cannot be blank", json['errors'] + end + test "POST /uploads.xml should return the token" do set_tmp_attachments_directory assert_difference 'Attachment.count' do diff --git a/test/integration/routing/attachments_test.rb b/test/integration/routing/attachments_test.rb index a29a0073c..4c46e9d96 100644 --- a/test/integration/routing/attachments_test.rb +++ b/test/integration/routing/attachments_test.rb @@ -30,7 +30,7 @@ class RoutingAttachmentsTest < Redmine::RoutingTest should_route 'DELETE /attachments/1' => 'attachments#destroy', :id => '1' - should_route 'GET /attachments/issues/1/edit' => 'attachments#edit', :object_type => 'issues', :object_id => '1' - should_route 'PATCH /attachments/issues/1' => 'attachments#update', :object_type => 'issues', :object_id => '1' + should_route 'GET /attachments/issues/1/edit' => 'attachments#edit_all', :object_type => 'issues', :object_id => '1' + should_route 'PATCH /attachments/issues/1' => 'attachments#update_all', :object_type => 'issues', :object_id => '1' end end |