diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 4a0bb44f..b594d4b8 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -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 } } diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 8d960ccc..09217345 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -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