summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2009-12-24 18:25:49 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2009-12-24 18:25:49 +0000
commit9fb40b1a2f700ce6e5bd31438fe9c9ef737555ab (patch)
tree54d370c97bfc8b13014431ab6f66b802ec9fcc09
parent62c83bdd2e1b06fcd873ba6d638c0bf59e390958 (diff)
downloadredmine-9fb40b1a2f700ce6e5bd31438fe9c9ef737555ab.tar.gz
redmine-9fb40b1a2f700ce6e5bd31438fe9c9ef737555ab.zip
Project#activities should check all overridden activities, not just active ones.
Fixes #4084 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3239 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/project.rb6
-rw-r--r--test/unit/project_test.rb11
2 files changed, 14 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 3f34393b3..4accf5a7c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -626,8 +626,8 @@ class Project < ActiveRecord::Base
# Returns all the active Systemwide and project specific activities
def active_activities
- overridden_activity_ids = self.time_entry_activities.active.collect(&:parent_id)
-
+ overridden_activity_ids = self.time_entry_activities.collect(&:parent_id)
+
if overridden_activity_ids.empty?
return TimeEntryActivity.shared.active
else
@@ -657,7 +657,7 @@ class Project < ActiveRecord::Base
else
return TimeEntryActivity.shared.active.
find(:all,
- :conditions => ["id NOT IN (?)", self.time_entry_activities.active.collect(&:parent_id)]) +
+ :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
self.time_entry_activities.active
end
end
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index e61ab03fc..f1dcb3418 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -521,6 +521,17 @@ class ProjectTest < ActiveSupport::TestCase
assert project.activities(true).include?(overridden_activity), "Inactive Project specific Activity not found"
end
+
+ test 'activities should not include active System activities if the project has an override that is inactive' do
+ project = Project.find(1)
+ system_activity = TimeEntryActivity.find_by_name('Design')
+ assert system_activity.active?
+ overridden_activity = TimeEntryActivity.generate!(:project => project, :parent => system_activity, :active => false)
+ assert overridden_activity.save!
+
+ assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found"
+ assert !project.activities.include?(system_activity), "System activity found when the project has an inactive override"
+ end
def test_close_completed_versions
Version.update_all("status = 'open'")