summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-02-07 08:36:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-02-07 08:36:49 +0000
commit171581da7e5301470d72efc91e713c375290d7b8 (patch)
tree7c3bc882c7937e2e896930a4b05beb7a5d6ab096 /app
parent8b58c952128860600636ebfb3fa4ebc779dd0bd8 (diff)
downloadredmine-171581da7e5301470d72efc91e713c375290d7b8.tar.gz
redmine-171581da7e5301470d72efc91e713c375290d7b8.zip
Project.activities should always return a ActiveRecord::Relation (#15983).
git-svn-id: http://svn.redmine.org/redmine/trunk@12854 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 3f3e216f9..a25513baf 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -995,15 +995,15 @@ class Project < ActiveRecord::Base
# Returns the systemwide active activities merged with the project specific overrides
def system_activities_and_project_overrides(include_inactive=false)
- if include_inactive
- return TimeEntryActivity.shared.
- where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
- self.time_entry_activities
- else
- return TimeEntryActivity.shared.active.
- where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
- self.time_entry_activities.active
+ t = TimeEntryActivity.table_name
+ scope = TimeEntryActivity.where(
+ "(#{t}.project_id IS NULL AND #{t}.id NOT IN (?)) OR (#{t}.project_id = ?)",
+ time_entry_activities.map(&:parent_id), id
+ )
+ unless include_inactive
+ scope = scope.active
end
+ scope
end
# Archives subprojects recursively