debian-mirror-gitlab/spec/helpers/boards_helper_spec.rb

64 lines
1.7 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
describe BoardsHelper do
2020-04-08 14:13:33 +05:30
let_it_be(:project) { create(:project) }
2019-09-30 21:07:59 +05:30
2018-03-27 19:54:05 +05:30
describe '#build_issue_link_base' do
context 'project board' do
it 'returns correct path for project board' do
2019-09-30 21:07:59 +05:30
@project = project
2018-03-27 19:54:05 +05:30
@board = create(:board, project: @project)
2020-04-08 14:13:33 +05:30
expect(build_issue_link_base).to eq("/#{@project.namespace.path}/#{@project.path}/-/issues")
2018-03-27 19:54:05 +05:30
end
end
context 'group board' do
let(:base_group) { create(:group, path: 'base') }
it 'returns correct path for base group' do
@board = create(:board, group: base_group)
expect(build_issue_link_base).to eq('/base/:project_path/issues')
end
it 'returns correct path for subgroup' do
subgroup = create(:group, parent: base_group, path: 'sub')
@board = create(:board, group: subgroup)
expect(build_issue_link_base).to eq('/base/sub/:project_path/issues')
end
end
end
2018-03-17 18:26:18 +05:30
describe '#board_data' do
let(:user) { create(:user) }
let(:board) { create(:board, project: project) }
before do
assign(:board, board)
assign(:project, project)
allow(helper).to receive(:current_user) { user }
2019-12-04 20:38:33 +05:30
allow(helper).to receive(:can?).with(user, :create_non_backlog_issues, board).and_return(true)
2018-03-17 18:26:18 +05:30
end
it 'returns a board_lists_path as lists_endpoint' do
expect(helper.board_data[:lists_endpoint]).to eq(board_lists_path(board))
end
end
2019-09-30 21:07:59 +05:30
describe '#current_board_json' do
let(:board_json) { helper.current_board_json }
it 'can serialise with a basic set of attributes' do
board = create(:board, project: project)
assign(:board, board)
expect(board_json).to match_schema('current-board')
end
end
2018-03-17 18:26:18 +05:30
end