##// END OF EJS Templates
Project.activities should always return a ActiveRecord::Relation (#15983)....
Jean-Philippe Lang -
r12579:171581da7e53
parent child
Show More
@@ -995,15 +995,15 class Project < ActiveRecord::Base
995
995
996 # Returns the systemwide active activities merged with the project specific overrides
996 # Returns the systemwide active activities merged with the project specific overrides
997 def system_activities_and_project_overrides(include_inactive=false)
997 def system_activities_and_project_overrides(include_inactive=false)
998 if include_inactive
998 t = TimeEntryActivity.table_name
999 return TimeEntryActivity.shared.
999 scope = TimeEntryActivity.where(
1000 where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
1000 "(#{t}.project_id IS NULL AND #{t}.id NOT IN (?)) OR (#{t}.project_id = ?)",
1001 self.time_entry_activities
1001 time_entry_activities.map(&:parent_id), id
1002 else
1002 )
1003 return TimeEntryActivity.shared.active.
1003 unless include_inactive
1004 where("id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)).all +
1004 scope = scope.active
1005 self.time_entry_activities.active
1006 end
1005 end
1006 scope
1007 end
1007 end
1008
1008
1009 # Archives subprojects recursively
1009 # Archives subprojects recursively
@@ -730,6 +730,7 class ProjectTest < ActiveSupport::TestCase
730 def test_activities_should_use_the_system_activities
730 def test_activities_should_use_the_system_activities
731 project = Project.find(1)
731 project = Project.find(1)
732 assert_equal project.activities, TimeEntryActivity.where(:active => true).all
732 assert_equal project.activities, TimeEntryActivity.where(:active => true).all
733 assert_kind_of ActiveRecord::Relation, project.activities
733 end
734 end
734
735
735
736
@@ -739,6 +740,7 class ProjectTest < ActiveSupport::TestCase
739 assert overridden_activity.save!
740 assert overridden_activity.save!
740
741
741 assert project.activities.include?(overridden_activity), "Project specific Activity not found"
742 assert project.activities.include?(overridden_activity), "Project specific Activity not found"
743 assert_kind_of ActiveRecord::Relation, project.activities
742 end
744 end
743
745
744 def test_activities_should_not_include_the_inactive_project_specific_activities
746 def test_activities_should_not_include_the_inactive_project_specific_activities
General Comments 0
You need to be logged in to leave comments. Login now