2018-09-07 09:39:20 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe LabelNote do
|
2022-02-08 07:15:38 -05:00
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
2020-02-05 07:09:15 -05:00
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:label) { create(:label, project: project) }
|
|
|
|
let_it_be(:label2) { create(:label, project: project) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2018-09-07 09:39:20 -04:00
|
|
|
let(:resource_parent) { project }
|
|
|
|
|
|
|
|
context 'when resource is issue' do
|
2020-02-05 07:09:15 -05:00
|
|
|
let_it_be(:resource) { create(:issue, project: project) }
|
2018-09-07 09:39:20 -04:00
|
|
|
|
|
|
|
it_behaves_like 'label note created from events'
|
2022-02-08 07:15:38 -05:00
|
|
|
|
|
|
|
it 'includes a link to the list of issues filtered by the label' do
|
2022-09-29 08:08:49 -04:00
|
|
|
note = described_class.from_events(
|
|
|
|
[
|
|
|
|
create(:resource_label_event, label: label, issue: resource)
|
|
|
|
])
|
2022-02-08 07:15:38 -05:00
|
|
|
|
|
|
|
expect(note.note_html).to include(project_issues_path(project, label_name: label.title))
|
|
|
|
end
|
2018-09-07 09:39:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when resource is merge request' do
|
2020-02-05 07:09:15 -05:00
|
|
|
let_it_be(:resource) { create(:merge_request, source_project: project, target_project: project) }
|
2018-09-07 09:39:20 -04:00
|
|
|
|
|
|
|
it_behaves_like 'label note created from events'
|
2022-02-08 07:15:38 -05:00
|
|
|
|
|
|
|
it 'includes a link to the list of merge requests filtered by the label' do
|
2022-09-29 08:08:49 -04:00
|
|
|
note = described_class.from_events(
|
|
|
|
[
|
|
|
|
create(:resource_label_event, label: label, merge_request: resource)
|
|
|
|
])
|
2022-02-08 07:15:38 -05:00
|
|
|
|
|
|
|
expect(note.note_html).to include(project_merge_requests_path(project, label_name: label.title))
|
|
|
|
end
|
2018-09-07 09:39:20 -04:00
|
|
|
end
|
|
|
|
end
|