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

abuse_reports_menu_spec.rb « menus « admin « sidebars « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ef5b8055becec6076a3001dffdc9819f445cdfea (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Sidebars::Admin::Menus::AbuseReportsMenu, feature_category: :navigation do
  it_behaves_like 'Admin menu',
    link: '/admin/abuse_reports',
    title: _('Abuse Reports'),
    icon: 'slight-frown'

  it_behaves_like 'Admin menu without sub menus', active_routes: { controller: :abuse_reports }

  describe '#pill_count' do
    let(:user) { build_stubbed(:user, :admin) }

    let(:context) { Sidebars::Context.new(current_user: user, container: nil) }

    subject { described_class.new(context) }

    it 'returns zero when there are no abuse reports' do
      expect(subject.pill_count).to eq 0
    end

    it 'memoizes the query' do
      subject.pill_count

      control = ActiveRecord::QueryRecorder.new do
        subject.pill_count
      end

      expect(control.count).to eq 0
    end

    context 'when there are abuse reports' do
      it 'returns the number of abuse reports' do
        create_list(:abuse_report, 2)

        expect(subject.pill_count).to eq 2
      end
    end
  end
end