From 4f4d447224a404919441371d71533bcfed78d853 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 8 Mar 2009 14:31:15 +0000 Subject: [PATCH] Fixed: Files without Version aren't visible in the Activity page (#2930). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2569 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/attachment.rb | 2 +- test/unit/activity_test.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 2ba75a3f..2957b9dd 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -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, diff --git a/test/unit/activity_test.rb b/test/unit/activity_test.rb index e5bc0d26..d47694e4 100644 --- a/test/unit/activity_test.rb +++ b/test/unit/activity_test.rb @@ -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={})