Create backlog list with board factory
What does this MR do and why?
This MR modifies the factory for issue boards so a backlog list is created for each new board.
Given that new boards created with Boards::CreateService
include the backlog
and closed
lists by default but the factory only created a closed
lists, we had to manually create the backlog list in several tests (mainly feature tests).
By creating this list in the factory we can avoid having to create the list manually and prevents unexpected failures (Re: !124674 (comment 1455943959))
We may still have cases where the backlog list is not present because boards didn't use to include it by default, so the tests for these cases will now delete the list created by the factory.
How to set up and validate locally
These changes only affect the boards factory. To validate follow these steps:
- Using
master
branch open the Rails console and verify that 2 lists are created with a board when using theBoards::CreateService
:
Click to expand
[1] pry(main)> group, user = Group.first, User.first
[2] pry(main)> service_board = Boards::CreateService.new(group, user).execute.payload
[3] pry(main)> service_board.lists
=> [#<List:0x000000028419e930
id: 43,
board_id: 19,
label_id: nil,
list_type: "backlog",
position: nil,
created_at: Thu, 13 Jul 2023 09:38:54.218277000 UTC +00:00,
updated_at: Thu, 13 Jul 2023 09:38:54.218277000 UTC +00:00,
user_id: nil,
milestone_id: nil,
max_issue_count: 0,
max_issue_weight: 0,
limit_metric: nil,
iteration_id: nil>,
#<List:0x000000028432c5b8
id: 44,
board_id: 19,
label_id: nil,
list_type: "closed",
position: nil,
created_at: Thu, 13 Jul 2023 09:38:54.219652000 UTC +00:00,
updated_at: Thu, 13 Jul 2023 09:38:54.219652000 UTC +00:00,
user_id: nil,
milestone_id: nil,
max_issue_count: 0,
max_issue_weight: 0,
limit_metric: nil,
iteration_id: nil>]
- Verify that only 1 list is created when using the factory:
Click to expand
[1] pry(main)> group, user = Group.first, User.first
[2] pry(main)> factory_board = FactoryBot.create(:board, group: group)
[3] pry(main)> factory_board.lists
=> #<List:0x0000000284786cf8
id: 45,
board_id: 20,
label_id: nil,
list_type: "closed",
position: nil,
created_at: Thu, 13 Jul 2023 09:40:08.663592000 UTC +00:00,
updated_at: Thu, 13 Jul 2023 09:40:08.663592000 UTC +00:00,
user_id: nil,
milestone_id: nil,
max_issue_count: 0,
max_issue_weight: 0,
limit_metric: nil,
iteration_id: nil>]
- Checkout the
egrieff-add-backlog-list-to-board-factories
branch and verify that 2 list are created when using the factory:
Click to expand
[1] pry(main)> group, user = Group.first, User.first
[2] pry(main)> factory_board = FactoryBot.create(:board, group: group)
[3] pry(main)> factory_board.lists
=> [#<List:0x0000000165b15e48
id: 46,
board_id: 21,
label_id: nil,
list_type: "backlog",
position: nil,
created_at: Thu, 13 Jul 2023 09:42:25.481696000 UTC +00:00,
updated_at: Thu, 13 Jul 2023 09:42:25.481696000 UTC +00:00,
user_id: nil,
milestone_id: nil,
max_issue_count: 0,
max_issue_weight: 0,
limit_metric: nil,
iteration_id: nil>,
#<List:0x000000016689f118
id: 47,
board_id: 21,
label_id: nil,
list_type: "closed",
position: nil,
created_at: Thu, 13 Jul 2023 09:42:25.483997000 UTC +00:00,
updated_at: Thu, 13 Jul 2023 09:42:25.483997000 UTC +00:00,
user_id: nil,
milestone_id: nil,
max_issue_count: 0,
max_issue_weight: 0,
limit_metric: nil,
iteration_id: nil>]
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.