]> source.dussan.org Git - redmine.git/commitdiff
Merged r16071 (#24595).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 20 Dec 2016 09:05:23 +0000 (09:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 20 Dec 2016 09:05:23 +0000 (09:05 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@16099 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
test/unit/project_test.rb

index 51531a5d9b4899e94d6f39bcbc21fd9d7a3344b2..42413924a625ff102ac891bcc464ff55afcc70b7 100644 (file)
@@ -350,6 +350,10 @@ class Project < ActiveRecord::Base
     self.status == STATUS_ACTIVE
   end
 
+  def closed?
+    self.status == STATUS_CLOSED
+  end
+
   def archived?
     self.status == STATUS_ARCHIVED
   end
@@ -377,8 +381,12 @@ class Project < ActiveRecord::Base
   # 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
index 5c305f7bf6213034a51602d1f7d106654c011be5..a3f2b7d45438b392c54669c96e7eef15fc109a78 100644 (file)
@@ -205,6 +205,18 @@ class ProjectTest < ActiveSupport::TestCase
     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