diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-06 03:08:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-06 03:08:47 +0000 |
commit | cfbaef3f1c28cdb9b15615215b87167181cb210f (patch) | |
tree | 8713f67e889a9b6d89fd35584ec7405f5a379565 /spec/requests/profiles | |
parent | a97acfe57aac7d8206e99e5ffdfe9c5fb5b69544 (diff) | |
download | gitlab-ce-cfbaef3f1c28cdb9b15615215b87167181cb210f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/profiles')
-rw-r--r-- | spec/requests/profiles/notifications_controller_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/requests/profiles/notifications_controller_spec.rb b/spec/requests/profiles/notifications_controller_spec.rb new file mode 100644 index 00000000000..41349d6c12d --- /dev/null +++ b/spec/requests/profiles/notifications_controller_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'view user notifications' do + let(:user) do + create(:user) do |user| + user.emails.create(email: 'original@example.com') + user.emails.create(email: 'new@example.com') + 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 'avoid 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 |