debian-mirror-gitlab/spec/helpers/projects/incidents_helper_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.7 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::IncidentsHelper do
include Gitlab::Routing.url_helpers
2021-12-11 22:18:48 +05:30
let(:user) { build_stubbed(:user) }
let(:project) { build_stubbed(:project) }
2020-10-24 23:57:45 +05:30
let(:project_path) { project.full_path }
let(:new_issue_path) { new_project_issue_path(project) }
let(:issue_path) { project_issues_path(project) }
2021-01-03 14:25:43 +05:30
let(:params) do
{
search: 'search text',
author_username: 'root',
assignee_username: 'max.power'
}
end
2020-10-24 23:57:45 +05:30
2021-12-11 22:18:48 +05:30
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-10-24 23:57:45 +05:30
describe '#incidents_data' do
2021-01-03 14:25:43 +05:30
subject(:data) { helper.incidents_data(project, params) }
2020-10-24 23:57:45 +05:30
2021-12-11 22:18:48 +05:30
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-10-24 23:57:45 +05:30
end
end
end