[#775] Don't create a new journal on Attachment#increment_download

This commit is contained in:
Holger Just 2012-01-31 14:51:34 +01:00
parent 11b441f745
commit fb595ec7f9
2 changed files with 23 additions and 2 deletions

View File

@ -34,7 +34,8 @@ class Attachment < ActiveRecord::Base
end),
:activity_type => 'files',
:activity_permission => :view_files,
:activity_find_options => { :include => { :version => :project } }
:activity_find_options => { :include => { :version => :project } },
:except => [:downloads]
acts_as_activity :type => 'documents', :permission => :view_documents,
:find_options => { :include => { :document => :project } }

View File

@ -14,7 +14,7 @@
require File.expand_path('../../test_helper', __FILE__)
class AttachmentTest < ActiveSupport::TestCase
fixtures :issues, :users
fixtures :issues, :projects, :users, :issue_statuses, :trackers, :projects_trackers
def setup
end
@ -76,4 +76,24 @@ class AttachmentTest < ActiveSupport::TestCase
end
end
end
context "Attachment#increment_download" do
should "not create a journal entry" do
issue = Issue.generate!(:status_id => 1, :tracker_id => 1, :project_id => 1)
attachment = Attachment.create!(:container => issue,
:file => mock_file,
:author => User.find(1))
assert_equal 0, attachment.downloads
# just the initial journal
assert_equal 1, attachment.journals.count
attachment.reload
attachment.increment_download
assert_equal 1, attachment.downloads
# no added journal
assert_equal 1, attachment.journals.count
end
end
end