OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[37257] Bust cache on settings name format change (#9276)
Oliver Güntherbb27cf990340
diff --git a/lib/api/v3/users/user_representer.rb b/lib/api/v3/users/user_representer.rbindex fd96edb9076..38b7f55b0d7 100644--- a/lib/api/v3/users/user_representer.rb+++ b/lib/api/v3/users/user_representer.rb@@ -36,7 +36,15 @@ module APIextend ::API::V3::Utilities::CustomFieldInjector::RepresenterClasscached_representer key_parts: %i(auth_source),- dependencies: ->(*) { avatar_cache_dependencies }+ dependencies: ->(*) {+ [+ # For the name rendering+ Setting.user_format,+ # For avatars+ Setting.plugin_openproject_avatars,+ Setting.protocol+ ]+ }self_linkdiff --git a/modules/avatars/lib/open_project/avatars/engine.rb b/modules/avatars/lib/open_project/avatars/engine.rbindex da7f956f05b..4ec5d99a7f4 100644--- a/modules/avatars/lib/open_project/avatars/engine.rb+++ b/modules/avatars/lib/open_project/avatars/engine.rb@@ -66,6 +66,5 @@ module OpenProject::Avatarsendpatches %i[User]- patch_with_namespace :API, :V3, :Users, :UserRepresenterendenddiff --git a/modules/avatars/lib/open_project/avatars/patches/user_representer_patch.rb b/modules/avatars/lib/open_project/avatars/patches/user_representer_patch.rbdeleted file mode 100644index 6b42bf571a8..00000000000--- a/modules/avatars/lib/open_project/avatars/patches/user_representer_patch.rb+++ /dev/null@@ -1,14 +0,0 @@-module OpenProject::Avatars::Patches- module UserRepresenterPatch- extend ActiveSupport::Concern-- included do- ##- # Dependencies required to cache users with avatars- # When the plugin is loaded, depend on its settings- def avatar_cache_dependencies- [Setting.plugin_openproject_avatars, Setting.protocol]- end- end- end-enddiff --git a/spec/lib/api/v3/users/user_representer_spec.rb b/spec/lib/api/v3/users/user_representer_spec.rbindex ef37ce10868..ade816ecc27 100644--- a/spec/lib/api/v3/users/user_representer_spec.rb+++ b/spec/lib/api/v3/users/user_representer_spec.rb@@ -286,11 +286,13 @@ describe ::API::V3::Users::UserRepresenter dodescribe '#json_cache_key' dolet(:auth_source) { FactoryBot.build_stubbed(:auth_source) }+ let(:former_cache_key) { representer.json_cache_key }before douser.auth_source = auth_source++ former_cache_keyend- let!(:former_cache_key) { representer.json_cache_key }it 'includes the name of the representer class' doexpect(representer.json_cache_key)@@ -311,6 +313,33 @@ describe ::API::V3::Users::UserRepresenter do.not_to eql former_cache_keyend+ it 'changes when user format setting changes' do+ allow(Setting)+ .to receive(:user_format)+ .and_return 'something else'++ expect(representer.json_cache_key)+ .not_to eql former_cache_key+ end++ it 'changes when the avatars plugin settings change' do+ allow(Setting)+ .to receive(:plugin_openproject_avatars)+ .and_return 'something else'++ expect(representer.json_cache_key)+ .not_to eql former_cache_key+ end++ it 'changes when the protocol settings change' do+ allow(Setting)+ .to receive(:protocol)+ .and_return 'something else'++ expect(representer.json_cache_key)+ .not_to eql former_cache_key+ end+it 'changes when the user\'s auth_source is updated' douser.auth_source.updated_at = Time.now + 20.seconds