Project.activities should always return a ActiveRecord::Relation (#15983).
git-svn-id: http://svn.redmine.org/redmine/trunk@12854 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8b58c95212
commit
171581da7e
|
@ -995,15 +995,15 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
# Returns the systemwide active activities merged with the project specific overrides
|
# Returns the systemwide active activities merged with the project specific overrides
|
||||||
def system_activities_and_project_overrides(include_inactive=false)
|
def system_activities_and_project_overrides(include_inactive=false)
|
||||||
if include_inactive
|
t = TimeEntryActivity.table_name
|
||||||
return TimeEntryActivity.shared.
|
scope = TimeEntryActivity.where(
|
||||||
where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
|
"(#{t}.project_id IS NULL AND #{t}.id NOT IN (?)) OR (#{t}.project_id = ?)",
|
||||||
self.time_entry_activities
|
time_entry_activities.map(&:parent_id), id
|
||||||
else
|
)
|
||||||
return TimeEntryActivity.shared.active.
|
unless include_inactive
|
||||||
where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
|
scope = scope.active
|
||||||
self.time_entry_activities.active
|
|
||||||
end
|
end
|
||||||
|
scope
|
||||||
end
|
end
|
||||||
|
|
||||||
# Archives subprojects recursively
|
# Archives subprojects recursively
|
||||||
|
|
|
@ -730,6 +730,7 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
def test_activities_should_use_the_system_activities
|
def test_activities_should_use_the_system_activities
|
||||||
project = Project.find(1)
|
project = Project.find(1)
|
||||||
assert_equal project.activities, TimeEntryActivity.where(:active => true).all
|
assert_equal project.activities, TimeEntryActivity.where(:active => true).all
|
||||||
|
assert_kind_of ActiveRecord::Relation, project.activities
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -739,6 +740,7 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
assert overridden_activity.save!
|
assert overridden_activity.save!
|
||||||
|
|
||||||
assert project.activities.include?(overridden_activity), "Project specific Activity not found"
|
assert project.activities.include?(overridden_activity), "Project specific Activity not found"
|
||||||
|
assert_kind_of ActiveRecord::Relation, project.activities
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_activities_should_not_include_the_inactive_project_specific_activities
|
def test_activities_should_not_include_the_inactive_project_specific_activities
|
||||||
|
|
Loading…
Reference in New Issue