2020-07-23 05:09:18 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Projects::IncidentsHelper do
|
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
let(:user) { build_stubbed(:user) }
|
|
|
|
let(:project) { build_stubbed(:project) }
|
2020-07-23 05:09:18 -04:00
|
|
|
let(:project_path) { project.full_path }
|
2020-07-24 20:09:23 -04:00
|
|
|
let(:new_issue_path) { new_project_issue_path(project) }
|
2020-07-27 11:09:25 -04:00
|
|
|
let(:issue_path) { project_issues_path(project) }
|
2020-09-21 08:09:34 -04:00
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
search: 'search text',
|
|
|
|
author_username: 'root',
|
|
|
|
assignee_username: 'max.power'
|
|
|
|
}
|
|
|
|
end
|
2020-07-23 05:09:18 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
before do
|
|
|
|
allow(helper).to receive(:current_user).and_return(user)
|
|
|
|
allow(helper).to receive(:can?)
|
|
|
|
.with(user, :create_incident, project)
|
|
|
|
.and_return(can_create_incident)
|
|
|
|
end
|
|
|
|
|
2020-07-23 05:09:18 -04:00
|
|
|
describe '#incidents_data' do
|
2020-09-21 08:09:34 -04:00
|
|
|
subject(:data) { helper.incidents_data(project, params) }
|
2020-07-23 05:09:18 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
shared_examples 'frontend configuration' do
|
|
|
|
it 'returns frontend configuration' do
|
|
|
|
expect(data).to include(
|
|
|
|
'project-path' => project_path,
|
|
|
|
'new-issue-path' => new_issue_path,
|
|
|
|
'incident-template-name' => 'incident',
|
|
|
|
'incident-type' => 'incident',
|
|
|
|
'issue-path' => issue_path,
|
|
|
|
'empty-list-svg-path' => match_asset_path('/assets/illustrations/incident-empty-state.svg'),
|
|
|
|
'text-query': 'search text',
|
|
|
|
'author-username-query': 'root',
|
|
|
|
'assignee-username-query': 'max.power',
|
|
|
|
'can-create-incident': can_create_incident.to_s
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user can create incidents' do
|
|
|
|
let(:can_create_incident) { true }
|
|
|
|
|
|
|
|
include_examples 'frontend configuration'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user cannot create incidents' do
|
|
|
|
let(:can_create_incident) { false }
|
|
|
|
|
|
|
|
include_examples 'frontend configuration'
|
2020-07-23 05:09:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|