self.status == STATUS_ACTIVE
end
+ def closed?
+ self.status == STATUS_CLOSED
+ end
+
def archived?
self.status == STATUS_ARCHIVED
end
# Unarchives the project
# All its ancestors must be active
def unarchive
- return false if ancestors.detect {|a| !a.active?}
- update_attribute :status, STATUS_ACTIVE
+ return false if ancestors.detect {|a| a.archived?}
+ new_status = STATUS_ACTIVE
+ if parent
+ new_status = parent.status
+ end
+ update_attribute :status, new_status
end
def close
assert @ecookbook_sub1.unarchive
end
+ def test_unarchive_a_child_of_a_closed_project_should_set_status_to_closed
+ Project.find(1).close
+ child = Project.find(3)
+ assert_equal Project::STATUS_CLOSED, child.status
+
+ child.archive
+ assert_equal Project::STATUS_ARCHIVED, child.status
+
+ child.unarchive
+ assert_equal Project::STATUS_CLOSED, child.status
+ end
+
def test_destroy
# 2 active members
assert_equal 2, @ecookbook.members.size