Commit eb185e53 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'remove-avatar-cache-ff' into 'master'

Remove avatar cache feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!58659
parents 63ddf132 c62d9388
......@@ -24,11 +24,7 @@ module AvatarsHelper
def avatar_icon_for_email(email = nil, size = nil, scale = 2, only_path: true)
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
avatar_icon_by_user_email_or_gravatar(email, size, scale, only_path: only_path)
end
else
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
end
......
......@@ -131,7 +131,6 @@ module Avatarable
def clear_avatar_caches
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)
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
end
end
context "when :avatar_cache_for_email flag is enabled" do
before do
stub_feature_flags(avatar_cache_for_email: true)
end
it_behaves_like "returns avatar for email"
it_behaves_like "returns avatar for email"
it "caches the request" do
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 "caches the request" do
expect(User).to receive(:find_by_any_email).once.and_call_original
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
......
......@@ -2521,32 +2521,12 @@ RSpec.describe User do
describe "#clear_avatar_caches" do
let(:user) { create(:user) }
context "when :avatar_cache_for_email flag is enabled" do
before do
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)
it "clears the avatar cache when saving" 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'))
end
user.update(avatar: fixture_file_upload('spec/fixtures/dk.png'))
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