From 679e260cde87eb7060d96f5a22596bd793829bbf Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 20 Apr 2013 12:06:39 +0200 Subject: [PATCH] Fixed Store/created_by_id handling. --- .../observer/ticket/article/communicate_email.rb | 11 ++++++----- app/models/package.rb | 11 ++++++----- app/models/ticket/article.rb | 11 ++++++----- test/unit/store_test.rb | 11 ++++++----- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/app/models/observer/ticket/article/communicate_email.rb b/app/models/observer/ticket/article/communicate_email.rb index 5f4e0cd6d..1023b2d77 100644 --- a/app/models/observer/ticket/article/communicate_email.rb +++ b/app/models/observer/ticket/article/communicate_email.rb @@ -36,11 +36,12 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer # store mail plain Store.add( - :object => 'Ticket::Article::Mail', - :o_id => record.id, - :data => message.to_s, - :filename => "ticket-#{ticket.number}-#{record.id}.eml", - :preferences => {} + :object => 'Ticket::Article::Mail', + :o_id => record.id, + :data => message.to_s, + :filename => "ticket-#{ticket.number}-#{record.id}.eml", + :preferences => {}, + :created_by_id => record.created_by_id, ) # add history record diff --git a/app/models/package.rb b/app/models/package.rb index 7f4b2a6a9..31685749a 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -216,11 +216,12 @@ class Package < ApplicationModel record = Package.create( meta ) if !data[:reinstall] Store.add( - :object => 'Package', - :o_id => record.id, - :data => package.to_s, - :filename => meta[:name] + '-' + meta[:version] + '.zpm', - :preferences => {}, + :object => 'Package', + :o_id => record.id, + :data => package.to_s, + :filename => meta[:name] + '-' + meta[:version] + '.zpm', + :preferences => {}, + :created_by_id => UserInfo.current_user_id || 1, ) end diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index cf6578e94..eecbf362c 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -18,11 +18,12 @@ class Ticket::Article < ApplicationModel article_store = [] self.attachments.each do |attachment| article_store.push Store.add( - :object => 'Ticket::Article', - :o_id => self.id, - :data => attachment.store_file.data, - :filename => attachment.filename, - :preferences => attachment.preferences + :object => 'Ticket::Article', + :o_id => self.id, + :data => attachment.store_file.data, + :filename => attachment.filename, + :preferences => attachment.preferences, + :created_by_id => self.created_by_id, ) end self.attachments = article_store diff --git a/test/unit/store_test.rb b/test/unit/store_test.rb index e427d5e86..51cd1af2d 100644 --- a/test/unit/store_test.rb +++ b/test/unit/store_test.rb @@ -25,11 +25,12 @@ class StoreTest < ActiveSupport::TestCase # add attachments store = Store.add( - :object => 'Test', - :o_id => 1, - :data => file[:data], - :filename => file[:filename], - :preferences => {} + :object => 'Test', + :o_id => 1, + :data => file[:data], + :filename => file[:filename], + :preferences => {}, + :created_by_id => 1, ) assert store