: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,
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
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={})