Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/incident_management/timeline_event_tag_spec.rb')
-rw-r--r--spec/models/incident_management/timeline_event_tag_spec.rb37
1 files changed, 36 insertions, 1 deletions
diff --git a/spec/models/incident_management/timeline_event_tag_spec.rb b/spec/models/incident_management/timeline_event_tag_spec.rb
index cff8ad8469f..1ec4fa30fb5 100644
--- a/spec/models/incident_management/timeline_event_tag_spec.rb
+++ b/spec/models/incident_management/timeline_event_tag_spec.rb
@@ -18,11 +18,46 @@ RSpec.describe IncidentManagement::TimelineEventTag do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_most(255) }
- it { is_expected.to validate_uniqueness_of(:name).scoped_to([:project_id]) }
+ it { is_expected.to validate_uniqueness_of(:name).scoped_to([:project_id]).ignoring_case_sensitivity }
it { is_expected.to allow_value('Test tag 1').for(:name) }
it { is_expected.not_to allow_value('Test tag, 1').for(:name) }
it { is_expected.not_to allow_value('').for(:name) }
it { is_expected.not_to allow_value('s' * 256).for(:name) }
end
+
+ describe '.pluck_names' do
+ it 'returns the names of the tags' do
+ tag1 = create(:incident_management_timeline_event_tag)
+ tag2 = create(:incident_management_timeline_event_tag)
+
+ expect(described_class.pluck_names).to contain_exactly(tag1.name, tag2.name)
+ end
+ end
+
+ describe 'constants' do
+ it { expect(described_class::START_TIME_TAG_NAME).to eq('Start time') }
+ it { expect(described_class::END_TIME_TAG_NAME).to eq('End time') }
+ end
+
+ describe '#by_names scope' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:project2) { create(:project) }
+ let_it_be(:tag1) { create(:incident_management_timeline_event_tag, name: 'Test tag 1', project: project) }
+ let_it_be(:tag2) { create(:incident_management_timeline_event_tag, name: 'Test tag 2', project: project) }
+ let_it_be(:tag3) { create(:incident_management_timeline_event_tag, name: 'Test tag 3', project: project2) }
+
+ it 'returns two matching tags' do
+ expect(described_class.by_names(['Test tag 1', 'Test tag 2'])).to contain_exactly(tag1, tag2)
+ end
+
+ it 'returns tags on the project' do
+ expect(project2.incident_management_timeline_event_tags.by_names(['Test tag 1',
+ 'Test tag 3'])).to contain_exactly(tag3)
+ end
+
+ it 'returns one matching tag with case insensitive' do
+ expect(described_class.by_names(['tESt tAg 2'])).to contain_exactly(tag2)
+ end
+ end
end