Commits

Anonymous committed fb595ec

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

Comments (0)

Files changed (2)

app/models/attachment.rb

         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 } }

test/unit/attachment_test.rb

 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
       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