summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-07 18:45:56 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-11-07 18:45:56 +0000
commita17f4c8375d1291e6116e3c40492ebc2ed4cfda2 (patch)
tree104ac98567fb3365bc6ca5e1c80ea2d26b9ba0d3 /test
parent00927f58af92410b52e1cb0f79198807d3888cfe (diff)
downloadredmine-a17f4c8375d1291e6116e3c40492ebc2ed4cfda2.tar.gz
redmine-a17f4c8375d1291e6116e3c40492ebc2ed4cfda2.zip
Make sure that attachments are created in the same order they were selected (#12310).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10793 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/issue_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 777edcf95..a5ab9aa72 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -1888,4 +1888,18 @@ class IssueTest < ActiveSupport::TestCase
assert_include 'priority-8', classes
assert_include 'priority-highest', classes
end
+
+ def test_save_attachments_with_hash_should_save_attachments_in_keys_order
+ set_tmp_attachments_directory
+ issue = Issue.generate!
+ issue.save_attachments({
+ 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')},
+ '3' => {'file' => mock_file_with_options(:original_filename => 'bar')},
+ '1' => {'file' => mock_file_with_options(:original_filename => 'foo')}
+ })
+ issue.attach_saved_attachments
+
+ assert_equal 3, issue.reload.attachments.count
+ assert_equal %w(upload foo bar), issue.attachments.map(&:filename)
+ end
end