aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-02-03 21:04:31 +0000
committerRobin Houston <robin.houston@gmail.com>2012-02-03 21:04:31 +0000
commit37bbce024b1ea731fe964b9eaddfd75dd548daee (patch)
tree4fdf38fcccd51b6c4109455def734372a0bbb6a1
parent8a383599e411fcbfeb1d2c19a972845f1daa524b (diff)
Specify attachment ordering
So it turns out that issue #408 is a real and potentially nasty bug. The code was assuming that attachments are returned in the order they were created, which is a) not guaranteed to be the case, and b) sometimes actually not the case, hence the occasional test failures. This trivial patch corrects the issue by sorting attachments by id. The effect of this is to return them in the order they were added to the database, since all were added using the same sequence in a single database session. Fixes #408.
-rw-r--r--app/models/incoming_message.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 421d79039..cbbcf5aa6 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -57,7 +57,7 @@ class IncomingMessage < ActiveRecord::Base
validates_presence_of :raw_email
has_many :outgoing_message_followups, :foreign_key => 'incoming_message_followup_id', :class_name => 'OutgoingMessage'
- has_many :foi_attachments
+ has_many :foi_attachments, :order => 'id'
has_many :info_request_events # never really has many, but could in theory
belongs_to :raw_email