Commit e7b4eade authored by Phil Hughes's avatar Phil Hughes

moved creating backlog list into list service

parent a980a4f6
...@@ -5,9 +5,9 @@ module Projects ...@@ -5,9 +5,9 @@ module Projects
before_action :authorize_read_list!, only: [:index] before_action :authorize_read_list!, only: [:index]
def index def index
board.lists.create(list_type: :backlog) unless board.lists.backlog.any? lists = ::Boards::Lists::ListService.new(project, current_user).execute(board)
render json: serialize_as_json(board.lists) render json: serialize_as_json(lists)
end end
def create def create
......
...@@ -2,6 +2,8 @@ module Boards ...@@ -2,6 +2,8 @@ module Boards
module Lists module Lists
class ListService < BaseService class ListService < BaseService
def execute(board) def execute(board)
board.lists.create(list_type: :backlog) unless board.lists.backlog.any?
board.lists board.lists
end end
end end
......
...@@ -67,7 +67,7 @@ describe Boards::Issues::ListService, services: true do ...@@ -67,7 +67,7 @@ describe Boards::Issues::ListService, services: true do
issues = described_class.new(project, user, params).execute issues = described_class.new(project, user, params).execute
expect(issues).to eq [closed_issue4, closed_issue2, closed_issue5, closed_issue3, closed_issue1] expect(issues).to eq [closed_issue4, closed_issue2, closed_issue3, closed_issue1]
end end
it 'returns opened issues that have label list applied when listing issues from a label list' do it 'returns opened issues that have label list applied when listing issues from a label list' do
......
...@@ -10,7 +10,7 @@ describe Boards::Lists::ListService, services: true do ...@@ -10,7 +10,7 @@ describe Boards::Lists::ListService, services: true do
service = described_class.new(project, double) service = described_class.new(project, double)
expect(service.execute(board)).to eq [list, board.closed_list] expect(service.execute(board)).to eq [board.backlog_list, list, board.closed_list]
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment