diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/services/labels | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/services/labels')
-rw-r--r-- | spec/services/labels/available_labels_service_spec.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/services/labels/available_labels_service_spec.rb b/spec/services/labels/available_labels_service_spec.rb index 9912f2cf469..9ee0b80edcd 100644 --- a/spec/services/labels/available_labels_service_spec.rb +++ b/spec/services/labels/available_labels_service_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Labels::AvailableLabelsService do let(:other_project_label) { create(:label) } let(:group_label) { create(:group_label, group: group) } let(:other_group_label) { create(:group_label) } - let(:labels) { [project_label, other_project_label, group_label, other_group_label] } + let!(:labels) { [project_label, other_project_label, group_label, other_group_label] } describe '#find_or_create_by_titles' do let(:label_titles) { labels.map(&:title).push('non existing title') } @@ -88,5 +88,33 @@ RSpec.describe Labels::AvailableLabelsService do expect(result).to match_array([group_label.id]) end end + + it 'accepts a single id parameter' do + result = described_class.new(user, project, label_id: project_label.id).filter_labels_ids_in_param(:label_id) + + expect(result).to match_array([project_label.id]) + end + end + + describe '#available_labels' do + context 'when parent is a project' do + it 'returns only relevant labels' do + result = described_class.new(user, project, {}).available_labels + + expect(result.count).to eq(2) + expect(result).to include(project_label, group_label) + expect(result).not_to include(other_project_label, other_group_label) + end + end + + context 'when parent is a group' do + it 'returns only relevant labels' do + result = described_class.new(user, group, {}).available_labels + + expect(result.count).to eq(1) + expect(result).to include(group_label) + expect(result).not_to include(project_label, other_project_label, other_group_label) + end + end end end |