@@ -350,6 +350,10 class Project < ActiveRecord::Base | |||||
350 | self.status == STATUS_ACTIVE |
|
350 | self.status == STATUS_ACTIVE | |
351 | end |
|
351 | end | |
352 |
|
352 | |||
|
353 | def closed? | |||
|
354 | self.status == STATUS_CLOSED | |||
|
355 | end | |||
|
356 | ||||
353 | def archived? |
|
357 | def archived? | |
354 | self.status == STATUS_ARCHIVED |
|
358 | self.status == STATUS_ARCHIVED | |
355 | end |
|
359 | end | |
@@ -377,8 +381,12 class Project < ActiveRecord::Base | |||||
377 | # Unarchives the project |
|
381 | # Unarchives the project | |
378 | # All its ancestors must be active |
|
382 | # All its ancestors must be active | |
379 | def unarchive |
|
383 | def unarchive | |
380 |
return false if ancestors.detect {|a| |
|
384 | return false if ancestors.detect {|a| a.archived?} | |
381 |
|
|
385 | new_status = STATUS_ACTIVE | |
|
386 | if parent | |||
|
387 | new_status = parent.status | |||
|
388 | end | |||
|
389 | update_attribute :status, new_status | |||
382 | end |
|
390 | end | |
383 |
|
391 | |||
384 | def close |
|
392 | def close |
@@ -205,6 +205,18 class ProjectTest < ActiveSupport::TestCase | |||||
205 | assert @ecookbook_sub1.unarchive |
|
205 | assert @ecookbook_sub1.unarchive | |
206 | end |
|
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 | def test_destroy |
|
220 | def test_destroy | |
209 | # 2 active members |
|
221 | # 2 active members | |
210 | assert_equal 2, @ecookbook.members.size |
|
222 | assert_equal 2, @ecookbook.members.size |
General Comments 0
You need to be logged in to leave comments.
Login now