]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Files without Version aren't visible in the Activity page (#2930).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Mar 2009 14:31:15 +0000 (14:31 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Mar 2009 14:31:15 +0000 (14:31 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2569 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/attachment.rb
test/unit/activity_test.rb

index 2ba75a3fdf9b56162e992cd12043264f7f737ba4..2957b9dd17a8fbea4b24060f9d019170e1ff3b30 100644 (file)
@@ -33,7 +33,7 @@ class Attachment < ActiveRecord::Base
                             :author_key => :author_id,
                             :find_options => {:select => "#{Attachment.table_name}.*", 
                                               :joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
-                                                        "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id"}
+                                                        "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"}
   
   acts_as_activity_provider :type => 'documents',
                             :permission => :view_documents,
index e5bc0d2668d62e7f8125b06b1b0f6d9f69ab6a35..d47694e48fb73463f889187f27b892fc48ef2548 100644 (file)
@@ -18,7 +18,7 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class ActivityTest < Test::Unit::TestCase
-  fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details,
+  fixtures :projects, :versions, :attachments, :users, :roles, :members, :issues, :journals, :journal_details,
            :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages
 
   def setup
@@ -72,6 +72,18 @@ class ActivityTest < Test::Unit::TestCase
     assert_nil(events.detect {|e| e.event_author != user})
   end
   
+  def test_files_activity
+    f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
+    f.scope = ['files']
+    events = f.events
+    
+    assert_kind_of Array, events
+    assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1))
+    assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1))
+    assert_equal [Attachment], events.collect(&:class).uniq
+    assert_equal %w(Project Version), events.collect(&:container_type).uniq.sort
+  end
+  
   private
   
   def find_events(user, options={})