#4962 Allow setting a status as closing even if the project has no close_status
Merged 4 years ago by pingou. Opened 4 years ago by pingou.

file modified
+3 -1
@@ -510,7 +510,9 @@ 

  

          try:

              close_status = data[name].get("close_status") or None

-             close = data[name].get("close") or True if close_status else False

+             close = data[name].get("close") or (

+                 True if close_status else False

+             )

              if close_status not in repo.close_status:

                  close_status = None

  

@@ -801,6 +801,87 @@ 

              },

          )

  

+     def test_api_board_api_board_status_no_close_status(self):

+         headers = {

+             "Authorization": "token aaabbbcccddd",

+             "Content-Type": "application/json",

+         }

+ 

+         data = json.dumps(

+             {

+                 "Backlog": {

+                     "close": False,

+                     "close_status": None,

+                     "bg_color": "#FFB300",

+                     "default": True,

+                     "rank": 1,

+                 },

+                 "Triaged": {

+                     "close": False,

+                     "close_status": None,

+                     "bg_color": "#ca0dcd",

+                     "default": False,

+                     "rank": 2,

+                 },

+                 "Done": {

+                     "close": True,

+                     "close_status": None,

+                     "bg_color": "#34d240",

+                     "default": False,

+                     "rank": 4,

+                 },

+                 "  ": {

+                     "close": True,

+                     "close_status": None,

+                     "bg_color": "#34d240",

+                     "default": False,

+                     "rank": 5,

+                 },

+             }

+         )

+         output = self.app.post(

+             "/api/0/test/boards/dev/status", headers=headers, data=data

+         )

+         self.assertEqual(output.status_code, 200)

+         data = json.loads(output.get_data(as_text=True))

+         self.assertDictEqual(

+             data,

+             {

+                 "board": {

+                     "active": True,

+                     "name": "dev",

+                     "status": [

+                         {

+                             "bg_color": "#FFB300",

+                             "close": False,

+                             "close_status": None,

+                             "default": True,

+                             "name": "Backlog",

+                         },

+                         {

+                             "bg_color": "#ca0dcd",

+                             "close": False,

+                             "close_status": None,

+                             "default": False,

+                             "name": "Triaged",

+                         },

+                         {

+                             "name": "Done",

+                             "close": True,

+                             "close_status": None,

+                             "default": False,

+                             "bg_color": "#34d240",

+                         },

+                     ],

+                     "tag": {

+                         "tag": "dev",

+                         "tag_color": "DeepBlueSky",

+                         "tag_description": "",

+                     },

+                 }

+             },

+         )

+ 

      def test_api_board_api_board_status_adding_removing(self):

          headers = {

              "Authorization": "token aaabbbcccddd",

When determining if a status "closes" tickets or not, we should first
check if it was set to and only if it wasn't then check if there was a
close_status set for it. Otherwise the logic wasn't correctly interpreted.

Fixes https://pagure.io/pagure/issue/4958

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

rebased onto af8a23ad4b0b0c5a31c9125e19b4dec3c69e0017

4 years ago

rebased onto 05a5e46

4 years ago

Pull-Request has been merged by pingou

4 years ago