@@ -626,8 +626,8 class Project < ActiveRecord::Base | |||||
626 |
|
626 | |||
627 | # Returns all the active Systemwide and project specific activities |
|
627 | # Returns all the active Systemwide and project specific activities | |
628 | def active_activities |
|
628 | def active_activities | |
629 |
overridden_activity_ids = self.time_entry_activities. |
|
629 | overridden_activity_ids = self.time_entry_activities.collect(&:parent_id) | |
630 |
|
630 | |||
631 | if overridden_activity_ids.empty? |
|
631 | if overridden_activity_ids.empty? | |
632 | return TimeEntryActivity.shared.active |
|
632 | return TimeEntryActivity.shared.active | |
633 | else |
|
633 | else | |
@@ -657,7 +657,7 class Project < ActiveRecord::Base | |||||
657 | else |
|
657 | else | |
658 | return TimeEntryActivity.shared.active. |
|
658 | return TimeEntryActivity.shared.active. | |
659 | find(:all, |
|
659 | find(:all, | |
660 |
:conditions => ["id NOT IN (?)", self.time_entry_activities. |
|
660 | :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) + | |
661 | self.time_entry_activities.active |
|
661 | self.time_entry_activities.active | |
662 | end |
|
662 | end | |
663 | end |
|
663 | end |
@@ -521,6 +521,17 class ProjectTest < ActiveSupport::TestCase | |||||
521 |
|
521 | |||
522 | assert project.activities(true).include?(overridden_activity), "Inactive Project specific Activity not found" |
|
522 | assert project.activities(true).include?(overridden_activity), "Inactive Project specific Activity not found" | |
523 | end |
|
523 | end | |
|
524 | ||||
|
525 | test 'activities should not include active System activities if the project has an override that is inactive' do | |||
|
526 | project = Project.find(1) | |||
|
527 | system_activity = TimeEntryActivity.find_by_name('Design') | |||
|
528 | assert system_activity.active? | |||
|
529 | overridden_activity = TimeEntryActivity.generate!(:project => project, :parent => system_activity, :active => false) | |||
|
530 | assert overridden_activity.save! | |||
|
531 | ||||
|
532 | assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found" | |||
|
533 | assert !project.activities.include?(system_activity), "System activity found when the project has an inactive override" | |||
|
534 | end | |||
524 |
|
535 | |||
525 | def test_close_completed_versions |
|
536 | def test_close_completed_versions | |
526 | Version.update_all("status = 'open'") |
|
537 | Version.update_all("status = 'open'") |
General Comments 0
You need to be logged in to leave comments.
Login now