diff --git a/app/models/group.rb b/app/models/group.rb index cdf86a0f84cbf11d3a5cf56e552fd17e1b5612f6..4bb37b93ae013a49ba7cf61c4d1cc5342e391ef5 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -12,7 +12,6 @@ class Group < Namespace include SelectForProjectAuthorization include LoadedInGroupList include GroupDescendant - prepend EE::GeoAwareAvatar has_many :group_members, -> { where(requested_at: nil) }, dependent: :destroy, as: :source # rubocop:disable Cop/ActiveRecordDependent alias_method :members, :group_members diff --git a/app/models/user.rb b/app/models/user.rb index a860aead915cafe8e623b62b72be21580660235c..20f587a68081871d29d83c44754fe6c9c9c4ee86 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -20,7 +20,6 @@ class User < ActiveRecord::Base include BulkMemberAccessLoad include BlocksJsonSerialization - prepend EE::GeoAwareAvatar prepend EE::User DEFAULT_NOTIFICATION_LEVEL = :participating diff --git a/ee/app/models/ee/geo_aware_avatar.rb b/ee/app/models/ee/geo_aware_avatar.rb deleted file mode 100644 index 60ad31bc5be92d2b628abf3ab60bd2406c0162b9..0000000000000000000000000000000000000000 --- a/ee/app/models/ee/geo_aware_avatar.rb +++ /dev/null @@ -1,15 +0,0 @@ -module EE - # Avatars in Geo mixin - # - # This module is intended to encapsulate Geo-specific logic - # and be **prepended** in the `Group`, `User`, `Project` models - module GeoAwareAvatar - def avatar_url(**args) - if ::Gitlab::Geo.secondary? && self[:avatar].present? - File.join(::Gitlab::Geo.primary_node.url, avatar.url) - else - super - end - end - end -end diff --git a/ee/app/models/ee/project.rb b/ee/app/models/ee/project.rb index 81e86f55aa6a7b86e85c5ecba5fc333c0663c70e..db909e923de6d054e1be4168624a5ece55a1867e 100644 --- a/ee/app/models/ee/project.rb +++ b/ee/app/models/ee/project.rb @@ -9,7 +9,6 @@ module EE prepended do include Elastic::ProjectsSearch - prepend GeoAwareAvatar prepend ImportStatusStateMachine before_validation :mark_remote_mirrors_for_removal diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index e97e30c80d7ee4085c2dc0cad8699a0d8fc2a6ff..03e0bf814380f1c758d73e328b634fbbb8f91899 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -32,27 +32,6 @@ describe GroupsHelper do group.save! expect(group_icon_url(group.path)).to match_asset_path('group_avatar.png') end - - context 'in a geo secondary node' do - let(:group) { create(:group) } - let(:geo_url) { 'http://geo.example.com' } - - before do - allow(Gitlab::Geo).to receive(:secondary?) { true } - allow(Gitlab::Geo).to receive_message_chain(:primary_node, :url) { geo_url } - end - - it 'returns an url for the avatar pointing to the primary node base url' do - group.avatar = fixture_file_upload(avatar_file_path) - group.save! - expect(group_icon_url(group.path)).to match("#{geo_url}/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif") - end - - it 'gives default avatar_icon when no avatar is present' do - group.save! - expect(group_icon_url(group.path)).to match_asset_path('no_group_avatar.png') - end - end end describe 'group_lfs_status' do diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 17070e4d0ed2cf72bde59ecf1130193819ea2701..5786478f6335d3a7654a2f505d03269e85eff49d 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -258,26 +258,6 @@ describe Group do expect(group.avatar_url).to eq(group.avatar.url) expect(group.avatar_url(only_path: false)).to eq([Gitlab.config.gitlab.url, group.avatar.url].join) end - - context 'when in a geo secondary node' do - let(:avatar_path) { group.avatar_path(only_path: true) } - let(:geo_host) { 'http://geo.example.com' } - let(:geo_avatar_url) { [geo_host, avatar_path].join } - - before do - allow(Gitlab::Geo).to receive(:secondary?) { true } - allow(Gitlab::Geo).to receive_message_chain(:primary_node, :url) { geo_host } - end - - it 'shows correct avatar url' do - expect(group.avatar_url).to eq(geo_avatar_url) - expect(group.avatar_url(only_path: false)).to eq(geo_avatar_url) - - allow(ActionController::Base).to receive(:asset_host).and_return(geo_host) - - expect(group.avatar_url).to eq(geo_avatar_url) - end - end end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index cd6d276fff7bd6aac26e160524a9f09fb0817cbb..07203721aaec00bc592fdc927c6ed3f64fd68618 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1047,18 +1047,6 @@ describe Project do expect(project.avatar_url).to eq(project.avatar.url) expect(project.avatar_url(only_path: false)).to eq([Gitlab.config.gitlab.url, project.avatar.url].join) end - - context 'When in a geo secondary node' do - let(:geo_url) { 'http://geo.example.com' } - let(:avatar_path) { project.avatar_path(only_path: true) } - - before do - allow(Gitlab::Geo).to receive(:secondary?) { true } - allow(Gitlab::Geo).to receive_message_chain(:primary_node, :url) { geo_url } - end - - it { is_expected.to eq "#{geo_url}#{avatar_path}" } - end end context 'when avatar file in git' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a59dfa96c1dd10941112b134dd7fce7722e152de..44381abe86c610bebb8a2b0df55aa635ccfb33fa 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1191,26 +1191,6 @@ describe User do expect(user.avatar_url).to eq(user.avatar.url) expect(user.avatar_url(only_path: false)).to eq([Gitlab.config.gitlab.url, user.avatar.url].join) end - - context 'when in a geo secondary node' do - let(:avatar_path) { user.avatar_path(only_path: true) } - let(:geo_host) { 'http://geo.example.com' } - let(:geo_avatar_url) { [geo_host, avatar_path].join } - - before do - allow(Gitlab::Geo).to receive(:secondary?) { true } - allow(Gitlab::Geo).to receive_message_chain(:primary_node, :url) { geo_host } - end - - it 'shows correct avatar url' do - expect(user.avatar_url).to eq(geo_avatar_url) - expect(user.avatar_url(only_path: false)).to eq(geo_avatar_url) - - allow(ActionController::Base).to receive(:asset_host).and_return(geo_host) - - expect(user.avatar_url).to eq(geo_avatar_url) - end - end end end