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
This commit is contained in:
Eric Davis 2009-12-24 18:25:49 +00:00
parent 62c83bdd2e
commit 9fb40b1a2f
2 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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'")