2019-04-23 15:58:20 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe LabelPresenter do
|
2019-04-23 15:58:20 -04:00
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
2020-02-16 22:09:00 -05:00
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:project) { create(:project, group: group) }
|
2021-04-21 05:09:15 -04:00
|
|
|
|
2019-04-23 15:58:20 -04:00
|
|
|
let(:label) { build_stubbed(:label, project: project).present(issuable_subject: project) }
|
|
|
|
let(:group_label) { build_stubbed(:group_label, group: group).present(issuable_subject: project) }
|
|
|
|
|
|
|
|
describe '#edit_path' do
|
|
|
|
context 'with group label' do
|
|
|
|
subject { group_label.edit_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(edit_group_label_path(group, group_label)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with project label' do
|
|
|
|
subject { label.edit_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(edit_project_label_path(project, label)) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#destroy_path' do
|
|
|
|
context 'with group label' do
|
|
|
|
subject { group_label.destroy_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(group_label_path(group, group_label)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with project label' do
|
|
|
|
subject { label.destroy_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(project_label_path(project, label)) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#filter_path' do
|
|
|
|
context 'with group as context subject' do
|
|
|
|
let(:label_in_group) { build_stubbed(:label, project: project).present(issuable_subject: group) }
|
2019-12-17 13:07:48 -05:00
|
|
|
|
2019-04-23 15:58:20 -04:00
|
|
|
subject { label_in_group.filter_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(issues_group_path(group, label_name: [label_in_group.title])) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with project as context subject' do
|
|
|
|
subject { label.filter_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(namespace_project_issues_path(group, project, label_name: [label.title])) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#can_subscribe_to_label_in_different_levels?' do
|
|
|
|
it 'returns true for group labels in project context' do
|
|
|
|
expect(group_label.can_subscribe_to_label_in_different_levels?).to be_truthy
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns false for project labels in project context' do
|
|
|
|
expect(label.can_subscribe_to_label_in_different_levels?).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
2019-05-28 06:05:20 -04:00
|
|
|
|
|
|
|
describe '#project_label?' do
|
|
|
|
context 'with group label' do
|
|
|
|
subject { group_label.project_label? }
|
|
|
|
|
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with project label' do
|
|
|
|
subject { label.project_label? }
|
|
|
|
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#subject_name' do
|
|
|
|
context 'with group label' do
|
|
|
|
subject { group_label.subject_name }
|
|
|
|
|
|
|
|
it { is_expected.to eq(group_label.group.name) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with project label' do
|
|
|
|
subject { label.subject_name }
|
|
|
|
|
|
|
|
it { is_expected.to eq(label.project.name) }
|
|
|
|
end
|
|
|
|
end
|
2020-10-13 02:09:09 -04:00
|
|
|
|
|
|
|
describe '#subject_full_name' do
|
|
|
|
context 'with group label' do
|
|
|
|
subject { group_label.subject_full_name }
|
|
|
|
|
|
|
|
it { is_expected.to eq(group_label.group.full_name) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with project label' do
|
|
|
|
subject { label.subject_full_name }
|
|
|
|
|
|
|
|
it { is_expected.to eq(label.project.full_name) }
|
|
|
|
end
|
|
|
|
end
|
2019-04-23 15:58:20 -04:00
|
|
|
end
|