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

notes_controller_spec.rb « projects « requests « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9cd8ba364ea99b7c4aa40d84e526c690630e535a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Projects::NotesController, feature_category: :team_planning do
  let_it_be(:project) { create(:project, :public) }
  let_it_be(:issue) { create(:issue, project: project) }

  describe '#index' do
    def get_notes
      get project_noteable_notes_path(project, target_type: 'issue', target_id: issue.id, format: :json),
        headers: { 'X-Last-Fetched-At': 0 }
    end

    it 'does not execute N+1 queries' do
      get_notes

      create(:note_on_issue, project: project, noteable: issue)

      control = ActiveRecord::QueryRecorder.new { get_notes }

      create(:note_on_issue, project: project, noteable: issue)

      expect { get_notes }.not_to exceed_query_limit(control)
    end
  end
end