summaryrefslogtreecommitdiff
path: root/spec/controllers/profiles/notifications_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/profiles/notifications_controller_spec.rb')
-rw-r--r--spec/controllers/profiles/notifications_controller_spec.rb50
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