summaryrefslogtreecommitdiffstats
path: root/lib/plugins
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 /lib/plugins
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 'lib/plugins')
-rw-r--r--lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index 626023b1b..344ff0866 100644
--- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -62,7 +62,19 @@ module Redmine
def save_attachments(attachments, author=User.current)
if attachments.is_a?(Hash)
- attachments = attachments.values
+ attachments = attachments.stringify_keys
+ attachments = attachments.to_a.sort {|a, b|
+ if a.first.to_i > 0 && b.first.to_i > 0
+ a.first.to_i <=> b.first.to_i
+ elsif a.first.to_i > 0
+ 1
+ elsif b.first.to_i > 0
+ -1
+ else
+ a.first <=> b.first
+ end
+ }
+ attachments = attachments.map(&:last)
end
if attachments.is_a?(Array)
attachments.each do |attachment|