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

notifications_controller_spec.rb « profiles « requests « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 21e166e04d3c9184e45a1f85a50cd1df99e65c13 (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 'view user notifications', feature_category: :team_planning do
  let(:user) do
    create(:user) do |user|
      user.emails.create!(email: 'original@example.com', confirmed_at: Time.current)
      user.emails.create!(email: 'new@example.com', confirmed_at: Time.current)
      user.notification_email = 'original@example.com'
      user.save!
    end
  end

  before do
    login_as(user)

    create_list(:group, 2) do |group|
      group.add_developer(user)
    end
  end

  def get_profile_notifications
    get profile_notifications_path
  end

  describe 'GET /-/profile/notifications' do
    it 'does not have an N+1 due to an additional groups (with no parent group)' do
      get_profile_notifications

      control = ActiveRecord::QueryRecorder.new do
        get_profile_notifications
      end

      create_list(:group, 2) { |group| group.add_developer(user) }

      expect do
        get_profile_notifications
      end.not_to exceed_query_limit(control)
    end
  end
end