Commit c62d9388 authored by Robert May's avatar Robert May

Enable avatar cache feature

Removes the avatar_cache_for_email feature flag.
parent 3d93021f
...@@ -24,11 +24,7 @@ module AvatarsHelper ...@@ -24,11 +24,7 @@ module AvatarsHelper
def avatar_icon_for_email(email = nil, size = nil, scale = 2, only_path: true) def avatar_icon_for_email(email = nil, size = nil, scale = 2, only_path: true)
return gravatar_icon(email, size, scale) if email.nil? return gravatar_icon(email, size, scale) if email.nil?
if Feature.enabled?(:avatar_cache_for_email, @current_user, type: :development) Gitlab::AvatarCache.by_email(email, size, scale, only_path) do
Gitlab::AvatarCache.by_email(email, size, scale, only_path) do
avatar_icon_by_user_email_or_gravatar(email, size, scale, only_path: only_path)
end
else
avatar_icon_by_user_email_or_gravatar(email, size, scale, only_path: only_path) avatar_icon_by_user_email_or_gravatar(email, size, scale, only_path: only_path)
end end
end end
......
...@@ -131,7 +131,6 @@ module Avatarable ...@@ -131,7 +131,6 @@ module Avatarable
def clear_avatar_caches def clear_avatar_caches
return unless respond_to?(:verified_emails) && verified_emails.any? && avatar_changed? return unless respond_to?(:verified_emails) && verified_emails.any? && avatar_changed?
return unless Feature.enabled?(:avatar_cache_for_email, self, type: :development)
Gitlab::AvatarCache.delete_by_email(*verified_emails) Gitlab::AvatarCache.delete_by_email(*verified_emails)
end end
......
---
title: Enable cached avatar lookups by email
merge_request: 58659
author:
type: performance
---
name: avatar_cache_for_email
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55184
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/323185
milestone: '13.10'
type: development
group: group::source code
default_enabled: false
...@@ -121,27 +121,13 @@ RSpec.describe AvatarsHelper do ...@@ -121,27 +121,13 @@ RSpec.describe AvatarsHelper do
end end
end end
context "when :avatar_cache_for_email flag is enabled" do it_behaves_like "returns avatar for email"
before do
stub_feature_flags(avatar_cache_for_email: true)
end
it_behaves_like "returns avatar for email"
it "caches the request" do it "caches the request" do
expect(User).to receive(:find_by_any_email).once.and_call_original expect(User).to receive(:find_by_any_email).once.and_call_original
expect(helper.avatar_icon_for_email(user.email).to_s).to eq(user.avatar.url)
expect(helper.avatar_icon_for_email(user.email).to_s).to eq(user.avatar.url)
end
end
context "when :avatar_cache_for_email flag is disabled" do
before do
stub_feature_flags(avatar_cache_for_email: false)
end
it_behaves_like "returns avatar for email" expect(helper.avatar_icon_for_email(user.email).to_s).to eq(user.avatar.url)
expect(helper.avatar_icon_for_email(user.email).to_s).to eq(user.avatar.url)
end end
end end
......
...@@ -2521,32 +2521,12 @@ RSpec.describe User do ...@@ -2521,32 +2521,12 @@ RSpec.describe User do
describe "#clear_avatar_caches" do describe "#clear_avatar_caches" do
let(:user) { create(:user) } let(:user) { create(:user) }
context "when :avatar_cache_for_email flag is enabled" do it "clears the avatar cache when saving" do
before do allow(user).to receive(:avatar_changed?).and_return(true)
stub_feature_flags(avatar_cache_for_email: true)
end
it "clears the avatar cache when saving" do
allow(user).to receive(:avatar_changed?).and_return(true)
expect(Gitlab::AvatarCache).to receive(:delete_by_email).with(*user.verified_emails)
user.update(avatar: fixture_file_upload('spec/fixtures/dk.png'))
end
end
context "when :avatar_cache_for_email flag is disabled" do
before do
stub_feature_flags(avatar_cache_for_email: false)
end
it "doesn't attempt to clear the avatar cache" do
allow(user).to receive(:avatar_changed?).and_return(true)
expect(Gitlab::AvatarCache).not_to receive(:delete_by_email) expect(Gitlab::AvatarCache).to receive(:delete_by_email).with(*user.verified_emails)
user.update(avatar: fixture_file_upload('spec/fixtures/dk.png')) user.update(avatar: fixture_file_upload('spec/fixtures/dk.png'))
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment