Commit da378c6b authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Fatih Acet

Move setCurrentBoard() from BoardsStoreEE to core

parent df43b144
...@@ -374,6 +374,10 @@ const boardsStore = { ...@@ -374,6 +374,10 @@ const boardsStore = {
deleteBoard({ id }) { deleteBoard({ id }) {
return axios.delete(this.generateBoardsPath(id)); return axios.delete(this.generateBoardsPath(id));
}, },
setCurrentBoard(board) {
this.state.currentBoard = board;
},
}; };
BoardsStoreEE.initEESpecific(boardsStore); BoardsStoreEE.initEESpecific(boardsStore);
......
...@@ -15,11 +15,17 @@ class BoardsStoreEE { ...@@ -15,11 +15,17 @@ class BoardsStoreEE {
this.addPromotion(); this.addPromotion();
}; };
this.store.loadList = (listPath, listType) => this.loadList(listPath, listType); this.store.loadList = (listPath, listType) => this.loadList(listPath, listType);
this.store.setCurrentBoard = board => this.setCurrentBoard(board);
this.store.removePromotionState = () => { this.store.removePromotionState = () => {
this.removePromotion(); this.removePromotion();
}; };
const superSetCurrentBoard = this.store.setCurrentBoard.bind(this.store);
this.store.setCurrentBoard = board => {
superSetCurrentBoard(board);
this.store.state.assignees = [];
this.store.state.milestones = [];
};
const baseCreate = this.store.create.bind(this.store); const baseCreate = this.store.create.bind(this.store);
this.store.create = () => { this.store.create = () => {
baseCreate(); baseCreate();
...@@ -166,13 +172,6 @@ class BoardsStoreEE { ...@@ -166,13 +172,6 @@ class BoardsStoreEE {
return parseBoolean(Cookies.get('promotion_issue_board_hidden')); return parseBoolean(Cookies.get('promotion_issue_board_hidden'));
} }
setCurrentBoard(board) {
const { state } = this.store;
state.currentBoard = board;
state.assignees = [];
state.milestones = [];
}
updateWeight(newWeight, id) { updateWeight(newWeight, id) {
const { issue } = this.store.detail; const { issue } = this.store.detail;
if (issue.id === id && issue.sidebarInfoEndpoint) { if (issue.id === id && issue.sidebarInfoEndpoint) {
......
...@@ -7,15 +7,19 @@ import { TEST_HOST } from 'helpers/test_constants'; ...@@ -7,15 +7,19 @@ import { TEST_HOST } from 'helpers/test_constants';
jest.mock('~/flash'); jest.mock('~/flash');
describe('BoardsStoreEE', () => { describe('BoardsStoreEE', () => {
let setCurrentBoard;
let axiosMock; let axiosMock;
beforeEach(() => { beforeEach(() => {
axiosMock = new AxiosMockAdapter(axios); axiosMock = new AxiosMockAdapter(axios);
setCurrentBoard = jest.fn();
// mock CE store // mock CE store
const storeMock = { const storeMock = {
state: {}, state: {},
create() {}, create() {},
setCurrentBoard,
}; };
BoardsStoreEE.initEESpecific(storeMock); BoardsStoreEE.initEESpecific(storeMock);
...@@ -60,20 +64,17 @@ describe('BoardsStoreEE', () => { ...@@ -60,20 +64,17 @@ describe('BoardsStoreEE', () => {
describe('setCurrentBoard', () => { describe('setCurrentBoard', () => {
const dummyBoard = 'skateboard'; const dummyBoard = 'skateboard';
it('sets the current board', () => { it('calls setCurrentBoard() of the base store', () => {
const { state } = BoardsStoreEE.store; BoardsStoreEE.store.setCurrentBoard(dummyBoard);
state.currentBoard = null;
BoardsStoreEE.setCurrentBoard(dummyBoard);
expect(state.currentBoard).toEqual(dummyBoard); expect(setCurrentBoard).toHaveBeenCalledWith(dummyBoard);
}); });
it('resets assignees', () => { it('resets assignees', () => {
const { state } = BoardsStoreEE.store; const { state } = BoardsStoreEE.store;
state.assignees = 'some assignees'; state.assignees = 'some assignees';
BoardsStoreEE.setCurrentBoard(dummyBoard); BoardsStoreEE.store.setCurrentBoard(dummyBoard);
expect(state.assignees).toEqual([]); expect(state.assignees).toEqual([]);
}); });
...@@ -82,7 +83,7 @@ describe('BoardsStoreEE', () => { ...@@ -82,7 +83,7 @@ describe('BoardsStoreEE', () => {
const { state } = BoardsStoreEE.store; const { state } = BoardsStoreEE.store;
state.milestones = 'some milestones'; state.milestones = 'some milestones';
BoardsStoreEE.setCurrentBoard(dummyBoard); BoardsStoreEE.store.setCurrentBoard(dummyBoard);
expect(state.milestones).toEqual([]); expect(state.milestones).toEqual([]);
}); });
......
...@@ -365,4 +365,17 @@ describe('Store', () => { ...@@ -365,4 +365,17 @@ describe('Store', () => {
expect(boardsStore.timeTracking.limitToHours).toEqual(true); expect(boardsStore.timeTracking.limitToHours).toEqual(true);
}); });
}); });
describe('setCurrentBoard', () => {
const dummyBoard = 'hoverboard';
it('sets the current board', () => {
const { state } = boardsStore;
state.currentBoard = null;
boardsStore.setCurrentBoard(dummyBoard);
expect(state.currentBoard).toEqual(dummyBoard);
});
});
}); });
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