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

updated service spec

parent e7b4eade
...@@ -26,7 +26,8 @@ gl.issueBoards.ModalFooter = Vue.extend({ ...@@ -26,7 +26,8 @@ gl.issueBoards.ModalFooter = Vue.extend({
}, },
methods: { methods: {
addIssues() { 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 selectedIssues = ModalStore.getSelectedIssues();
const issueIds = selectedIssues.map(issue => issue.globalId); const issueIds = selectedIssues.map(issue => issue.globalId);
......
...@@ -2,7 +2,7 @@ module Boards ...@@ -2,7 +2,7 @@ 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.create(list_type: :backlog) unless board.lists.backlog.exists?
board.lists board.lists
end end
......
require 'spec_helper' require 'spec_helper'
describe Boards::Lists::ListService, services: true do 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 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 it "returns board's lists" do
project = create(:empty_project) expect(service.execute(board)).to eq [board.backlog_list, list, board.closed_list]
board = create(:board, project: project) end
label = create(:label, project: project) end
list = create(:list, board: board, label: label)
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] expect(service.execute(board)).to eq [board.backlog_list, list, board.closed_list]
end 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