2020-02-05 22:08:47 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe 'view user notifications' do
|
2020-02-05 22:08:47 -05:00
|
|
|
let(:user) do
|
|
|
|
create(:user) do |user|
|
2020-09-08 05:08:31 -04:00
|
|
|
user.emails.create!(email: 'original@example.com', confirmed_at: Time.current)
|
|
|
|
user.emails.create!(email: 'new@example.com', confirmed_at: Time.current)
|
2020-02-05 22:08:47 -05:00
|
|
|
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
|
|
|
|
|
2021-01-18 10:10:42 -05:00
|
|
|
describe 'GET /-/profile/notifications' do
|
2020-09-04 05:08:38 -04:00
|
|
|
it 'does not have an N+1 due to an additional groups (with no parent group)' do
|
2020-02-05 22:08:47 -05:00
|
|
|
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
|
2020-09-04 05:08:38 -04:00
|
|
|
end.not_to exceed_query_limit(control)
|
2020-02-05 22:08:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|