2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
2019-07-31 22:56:46 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe 'shared/_label_row.html.haml' do
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:group) { create(:group) }
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let(:label) { build_stubbed(:group_label, group: group).present(issuable_subject: group) }
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
before do
|
|
|
|
allow(view).to receive(:label) { label }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a project context' do
|
|
|
|
let_it_be(:project) { create(:project, group: group) }
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let(:label) { build_stubbed(:label, project: project).present(issuable_subject: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:project, label.project)
|
|
|
|
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has label title' do
|
|
|
|
expect(rendered).to have_text(label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a non-linked label title' do
|
|
|
|
expect(rendered).not_to have_link(label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has Issues link' do
|
|
|
|
expect(rendered).to have_link('Issues')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has Merge request link' do
|
|
|
|
expect(rendered).to have_link('Merge requests')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the path from where the label was created' do
|
|
|
|
expect(rendered).to have_css('.label-badge', text: project.full_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a subgroup context' do
|
|
|
|
let_it_be(:subgroup) { create(:group, parent: group) }
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let(:label) { build_stubbed(:group_label, group: subgroup).present(issuable_subject: subgroup) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:group, label.group)
|
|
|
|
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has label title' do
|
|
|
|
expect(rendered).to have_text(label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a non-linked label title' do
|
|
|
|
expect(rendered).not_to have_link(label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has Issues link' do
|
|
|
|
expect(rendered).to have_link('Issues')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has Merge request link' do
|
|
|
|
expect(rendered).to have_link('Merge requests')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the path from where the label was created' do
|
|
|
|
expect(rendered).to have_css('.label-badge', text: subgroup.full_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a group context' do
|
|
|
|
before do
|
|
|
|
assign(:group, label.group)
|
|
|
|
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has label title' do
|
|
|
|
expect(rendered).to have_text(label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a non-linked label title' do
|
|
|
|
expect(rendered).not_to have_link(label.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has Issues link' do
|
|
|
|
expect(rendered).to have_link('Issues')
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'has Merge request link' do
|
|
|
|
expect(rendered).to have_link('Merge requests')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show a path from where the label was created' do
|
|
|
|
expect(rendered).not_to have_css('.label-badge')
|
|
|
|
end
|
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
context 'with an admin context' do
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'has label title' do
|
|
|
|
expect(rendered).to have_text(label.title)
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'has a non-linked label title' do
|
|
|
|
expect(rendered).not_to have_link(label.title)
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'does not show Issues link' do
|
|
|
|
expect(rendered).not_to have_link('Issues')
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'does not show Merge request link' do
|
|
|
|
expect(rendered).not_to have_link('Merge requests')
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'does not show a path from where the label was created' do
|
|
|
|
expect(rendered).not_to have_css('.label-badge')
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|