@@ -33,7 +33,7 class Attachment < ActiveRecord::Base | |||
|
33 | 33 | :author_key => :author_id, |
|
34 | 34 | :find_options => {:select => "#{Attachment.table_name}.*", |
|
35 | 35 | :joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " + |
|
36 | "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id"} | |
|
36 | "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 )"} | |
|
37 | 37 | |
|
38 | 38 | acts_as_activity_provider :type => 'documents', |
|
39 | 39 | :permission => :view_documents, |
@@ -18,7 +18,7 | |||
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | |
|
20 | 20 | class ActivityTest < Test::Unit::TestCase |
|
21 | fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details, | |
|
21 | fixtures :projects, :versions, :attachments, :users, :roles, :members, :issues, :journals, :journal_details, | |
|
22 | 22 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages |
|
23 | 23 | |
|
24 | 24 | def setup |
@@ -72,6 +72,18 class ActivityTest < Test::Unit::TestCase | |||
|
72 | 72 | assert_nil(events.detect {|e| e.event_author != user}) |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | def test_files_activity | |
|
76 | f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) | |
|
77 | f.scope = ['files'] | |
|
78 | events = f.events | |
|
79 | ||
|
80 | assert_kind_of Array, events | |
|
81 | assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1)) | |
|
82 | assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1)) | |
|
83 | assert_equal [Attachment], events.collect(&:class).uniq | |
|
84 | assert_equal %w(Project Version), events.collect(&:container_type).uniq.sort | |
|
85 | end | |
|
86 | ||
|
75 | 87 | private |
|
76 | 88 | |
|
77 | 89 | def find_events(user, options={}) |
General Comments 0
You need to be logged in to leave comments.
Login now