diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-29 13:41:53 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-29 13:41:53 +0000 |
commit | 288c014aa7aa608751dbafeb2c8b358f2fec5c22 (patch) | |
tree | 68a5705092edc501641630fa960cee368d27ca88 /test/functional/attachments_controller_test.rb | |
parent | 3c7f638a834d6d9717e3d8babe3bab6af5100994 (diff) | |
download | redmine-288c014aa7aa608751dbafeb2c8b358f2fec5c22.tar.gz redmine-288c014aa7aa608751dbafeb2c8b358f2fec5c22.zip |
Edit attachments after upload (#1326).
git-svn-id: http://svn.redmine.org/redmine/trunk@13665 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/attachments_controller_test.rb')
-rw-r--r-- | test/functional/attachments_controller_test.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 19e4d0c09..c1b27c64e 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -327,6 +327,64 @@ class AttachmentsControllerTest < ActionController::TestCase puts '(ImageMagick convert not available)' end + def test_edit + @request.session[:user_id] = 2 + get :edit, :object_type => 'issues', :object_id => '3' + assert_response :success + assert_template 'edit' + + container = Issue.find(3) + assert_equal container, assigns(:container) + assert_equal container.attachments.size, assigns(:attachments).size + + assert_select 'form[action=?]', '/attachments/issues/3' do + assert_select 'tr#attachment-4' do + assert_select 'input[name=?][value=?]', 'attachments[4][filename]', 'source.rb' + assert_select 'input[name=?][value=?]', 'attachments[4][description]', 'This is a Ruby source file' + end + end + end + + def test_edit_invalid_container_class_should_return_404 + get :edit, :object_type => 'nuggets', :object_id => '3' + assert_response 404 + end + + def test_edit_for_object_that_is_not_visible_should_return_403 + get :edit, :object_type => 'issues', :object_id => '4' + assert_response 403 + end + + def test_update + @request.session[:user_id] = 2 + patch :update, :object_type => 'issues', :object_id => '3', :attachments => { + '1' => {:filename => 'newname.text', :description => ''}, + '4' => {:filename => 'newname.rb', :description => 'Renamed'}, + } + + assert_response 302 + attachment = Attachment.find(4) + assert_equal 'newname.rb', attachment.filename + assert_equal 'Renamed', attachment.description + end + + def test_update_with_failure + @request.session[:user_id] = 2 + patch :update, :object_type => 'issues', :object_id => '3', :attachments => { + '1' => {:filename => '', :description => ''}, + '4' => {:filename => 'newname.rb', :description => 'Renamed'}, + } + + assert_response :success + assert_template 'edit' + assert_select_error /file #{ESCAPED_CANT} be blank/i + + # The other attachment should not be updated + attachment = Attachment.find(4) + assert_equal 'source.rb', attachment.filename + assert_equal 'This is a Ruby source file', attachment.description + end + def test_destroy_issue_attachment set_tmp_attachments_directory issue = Issue.find(3) |