BigW Consortium Gitlab

issues_finder_spec.rb 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
require 'spec_helper'

describe IssuesFinder, benchmark: true do
  describe '#execute' do
    let(:user) { create(:user) }
    let(:project) { create(:project, :public) }

    let(:label1) { create(:label, project: project, title: 'A') }
    let(:label2) { create(:label, project: project, title: 'B') }

    before do
      10.times do |n|
        issue = create(:issue, author: user, project: project)

        if n > 4
          create(:label_link, label: label1, target: issue)
          create(:label_link, label: label2, target: issue)
        end
      end
    end

    describe 'retrieving issues without labels' do
      let(:finder) do
        IssuesFinder.new(user, scope: 'all', label_name: Label::None.title,
25
                               state: 'opened')
26 27 28 29 30 31 32 33 34 35
      end

      benchmark_subject { finder.execute }

      it { is_expected.to iterate_per_second(2000) }
    end

    describe 'retrieving issues with labels' do
      let(:finder) do
        IssuesFinder.new(user, scope: 'all', label_name: label1.title,
36
                               state: 'opened')
37 38 39 40 41 42 43 44 45 46
      end

      benchmark_subject { finder.execute }

      it { is_expected.to iterate_per_second(1000) }
    end

    describe 'retrieving issues for a single project' do
      let(:finder) do
        IssuesFinder.new(user, scope: 'all', label_name: Label::None.title,
47
                               state: 'opened', project_id: project.id)
48 49 50 51 52 53 54 55
      end

      benchmark_subject { finder.execute }

      it { is_expected.to iterate_per_second(2000) }
    end
  end
end