##// END OF EJS Templates
Merged r16071 (#24595)....
Jean-Philippe Lang -
r15718:0453c56b221f
parent child
Show More
@@ -350,6 +350,10 class Project < ActiveRecord::Base
350 350 self.status == STATUS_ACTIVE
351 351 end
352 352
353 def closed?
354 self.status == STATUS_CLOSED
355 end
356
353 357 def archived?
354 358 self.status == STATUS_ARCHIVED
355 359 end
@@ -377,8 +381,12 class Project < ActiveRecord::Base
377 381 # Unarchives the project
378 382 # All its ancestors must be active
379 383 def unarchive
380 return false if ancestors.detect {|a| !a.active?}
381 update_attribute :status, STATUS_ACTIVE
384 return false if ancestors.detect {|a| a.archived?}
385 new_status = STATUS_ACTIVE
386 if parent
387 new_status = parent.status
388 end
389 update_attribute :status, new_status
382 390 end
383 391
384 392 def close
@@ -205,6 +205,18 class ProjectTest < ActiveSupport::TestCase
205 205 assert @ecookbook_sub1.unarchive
206 206 end
207 207
208 def test_unarchive_a_child_of_a_closed_project_should_set_status_to_closed
209 Project.find(1).close
210 child = Project.find(3)
211 assert_equal Project::STATUS_CLOSED, child.status
212
213 child.archive
214 assert_equal Project::STATUS_ARCHIVED, child.status
215
216 child.unarchive
217 assert_equal Project::STATUS_CLOSED, child.status
218 end
219
208 220 def test_destroy
209 221 # 2 active members
210 222 assert_equal 2, @ecookbook.members.size
General Comments 0
You need to be logged in to leave comments. Login now