diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/controllers/profiles | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/controllers/profiles')
-rw-r--r-- | spec/controllers/profiles/notifications_controller_spec.rb | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/spec/controllers/profiles/notifications_controller_spec.rb b/spec/controllers/profiles/notifications_controller_spec.rb index 03749366703..1ebf4363ba6 100644 --- a/spec/controllers/profiles/notifications_controller_spec.rb +++ b/spec/controllers/profiles/notifications_controller_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe Profiles::NotificationsController 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.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 @@ -21,6 +21,30 @@ RSpec.describe Profiles::NotificationsController do expect(response).to render_template :show end + context 'when personal projects are present', :request_store do + let!(:personal_project_1) { create(:project, namespace: user.namespace) } + + context 'N+1 query check' do + render_views + + it 'does not have an N+1' do + sign_in(user) + + get :show + + control = ActiveRecord::QueryRecorder.new do + get :show + end + + create_list(:project, 2, namespace: user.namespace) + + expect do + get :show + end.not_to exceed_query_limit(control) + end + end + end + context 'with groups that do not have notification preferences' do let_it_be(:group) { create(:group) } let_it_be(:subgroup) { create(:group, parent: group) } @@ -37,18 +61,24 @@ RSpec.describe Profiles::NotificationsController do expect(assigns(:group_notifications).map(&:source_id)).to include(subgroup.id) end - it 'does not have an N+1' do - sign_in(user) + context 'N+1 query check' do + render_views + + it 'does not have an N+1' do + sign_in(user) - control = ActiveRecord::QueryRecorder.new do get :show - end - create_list(:group, 2, parent: group) + control = ActiveRecord::QueryRecorder.new do + get :show + end - expect do - get :show - end.not_to exceed_query_limit(control) + create_list(:group, 2, parent: group) + + expect do + get :show + end.not_to exceed_query_limit(control) + end end end |