diff options
Diffstat (limited to 'spec/services/labels/available_labels_service_spec.rb')
-rw-r--r-- | spec/services/labels/available_labels_service_spec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/services/labels/available_labels_service_spec.rb b/spec/services/labels/available_labels_service_spec.rb index 9ee0b80edcd..355dbd0c712 100644 --- a/spec/services/labels/available_labels_service_spec.rb +++ b/spec/services/labels/available_labels_service_spec.rb @@ -36,6 +36,15 @@ RSpec.describe Labels::AvailableLabelsService do expect(result).to include(project_label, group_label) expect(result).not_to include(other_project_label, other_group_label) end + + it 'do not cause additional query for finding labels' do + label_titles = [project_label.title] + control_count = ActiveRecord::QueryRecorder.new { described_class.new(user, project, labels: label_titles).find_or_create_by_titles } + + new_label = create(:label, project: project) + label_titles = [project_label.title, new_label.title] + expect { described_class.new(user, project, labels: label_titles).find_or_create_by_titles }.not_to exceed_query_limit(control_count) + end end end |