summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-01-09 07:45:46 -0800
committerStan Hu <stanhu@gmail.com>2019-01-09 07:50:37 -0800
commit19e57399ca1345e3661243f820d2404e8abc60df (patch)
treefe496bb2d8ff3a47f98396a2e1131ddd7302caa3
parent1b3affafab0f28c690ce93cc98ac6bd09cbda59f (diff)
downloadgitlab-ce-sh-add-project-creator-to-cache-key.tar.gz
Fix stale project list if creator changes his/her namesh-add-project-creator-to-cache-key
If the creator updates his/her username, the project list would not be refreshed properly. Add this to the cache key to ensure changes get reflected automatically. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56136
-rw-r--r--app/helpers/projects_helper.rb1
-rw-r--r--changelogs/unreleased/sh-add-project-creator-to-cache-key.yml5
-rw-r--r--spec/helpers/projects_helper_spec.rb6
3 files changed, 11 insertions, 1 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index e67c327f7f8..85dc875ba65 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -174,6 +174,7 @@ module ProjectsHelper
project.route.cache_key,
project.cache_key,
project.last_activity_date,
+ project.creator&.cache_key,
controller.controller_name,
controller.action_name,
Gitlab::CurrentSettings.cache_key,
diff --git a/changelogs/unreleased/sh-add-project-creator-to-cache-key.yml b/changelogs/unreleased/sh-add-project-creator-to-cache-key.yml
new file mode 100644
index 00000000000..6cae30160cb
--- /dev/null
+++ b/changelogs/unreleased/sh-add-project-creator-to-cache-key.yml
@@ -0,0 +1,5 @@
+---
+title: Fix stale project list if creator changes his/her name
+merge_request: 24272
+author:
+type: fixed
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 88b5d87f087..a2be3dd5b58 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -62,7 +62,7 @@ describe ProjectsHelper do
helper.instance_variable_set(:@project, project)
end
- it "returns a valid cach key" do
+ it "returns a valid cache key" do
expect(helper.send(:readme_cache_key)).to eq("#{project.full_path}-#{project.commit.id}-readme")
end
@@ -91,6 +91,10 @@ describe ProjectsHelper do
expect(helper.project_list_cache_key(project)).to include(project.cache_key)
end
+ it "includes the project creator" do
+ expect(helper.project_list_cache_key(project)).to include(project.creator.cache_key)
+ end
+
it "includes the last activity date" do
expect(helper.project_list_cache_key(project)).to include(project.last_activity_date)
end