Commit 973e8c0f authored by Phil Hughes's avatar Phil Hughes

updated service spec

parent e7b4eade
......@@ -26,7 +26,8 @@ gl.issueBoards.ModalFooter = Vue.extend({
},
methods: {
addIssues() {
const list = this.modal.selectedList || this.state.lists[1];
const firstListIndex = 1;
const list = this.modal.selectedList || this.state.lists[firstListIndex];
const selectedIssues = ModalStore.getSelectedIssues();
const issueIds = selectedIssues.map(issue => issue.globalId);
......
......@@ -2,7 +2,7 @@ module Boards
module Lists
class ListService < BaseService
def execute(board)
board.lists.create(list_type: :backlog) unless board.lists.backlog.any?
board.lists.create(list_type: :backlog) unless board.lists.backlog.exists?
board.lists
end
......
require 'spec_helper'
describe Boards::Lists::ListService, services: true do
let(:project) { create(:empty_project) }
let(:board) { create(:board, project: project) }
let(:label) { create(:label, project: project) }
let!(:list) { create(:list, board: board, label: label) }
let(:service) { described_class.new(project, double) }
describe '#execute' do
context 'when the board has a backlog list' do
before do
create(:backlog_list, board: board)
end
it 'does not create a backlog list' do
service.execute(board)
expect(board.lists.merge(List.backlog)).to eq [board.backlog_list]
end
it "returns board's lists" do
project = create(:empty_project)
board = create(:board, project: project)
label = create(:label, project: project)
list = create(:list, board: board, label: label)
expect(service.execute(board)).to eq [board.backlog_list, list, board.closed_list]
end
end
context 'when the board does not have a backlog list' do
it 'creates a backlog list' do
service.execute(board)
service = described_class.new(project, double)
expect(board.backlog_list).not_to be nil
end
it "returns board's lists" do
expect(service.execute(board)).to eq [board.backlog_list, list, board.closed_list]
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