Commit fb595ec7 authored by Holger Just's avatar Holger Just

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

parent 11b441f7
...@@ -34,7 +34,8 @@ class Attachment < ActiveRecord::Base ...@@ -34,7 +34,8 @@ class Attachment < ActiveRecord::Base
end), end),
:activity_type => 'files', :activity_type => 'files',
:activity_permission => :view_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, acts_as_activity :type => 'documents', :permission => :view_documents,
:find_options => { :include => { :document => :project } } :find_options => { :include => { :document => :project } }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
require File.expand_path('../../test_helper', __FILE__) require File.expand_path('../../test_helper', __FILE__)
class AttachmentTest < ActiveSupport::TestCase class AttachmentTest < ActiveSupport::TestCase
fixtures :issues, :users fixtures :issues, :projects, :users, :issue_statuses, :trackers, :projects_trackers
def setup def setup
end end
...@@ -76,4 +76,24 @@ class AttachmentTest < ActiveSupport::TestCase ...@@ -76,4 +76,24 @@ class AttachmentTest < ActiveSupport::TestCase
end end
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 end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment