From 6defeb0a7d6928ad32d4d7a2fa35d0d71dbb9dea Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 9 Jun 2018 22:35:06 -0700 Subject: Expire Wiki content cache after importing a repository The cache state for Wikis that were imported via GitHub or Bitbucket does not appear to have been flushed after a successful import. Closes #47546 --- app/models/project.rb | 1 + changelogs/unreleased/sh-expire-content-cache-after-import.yml | 5 +++++ lib/gitlab/github_import/sequential_importer.rb | 2 -- lib/tasks/import.rake | 2 +- spec/lib/gitlab/github_import/sequential_importer_spec.rb | 1 - spec/models/project_spec.rb | 3 ++- 6 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/sh-expire-content-cache-after-import.yml diff --git a/app/models/project.rb b/app/models/project.rb index 60cd13b371f..bc91b0aa1b0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1615,6 +1615,7 @@ class Project < ActiveRecord::Base def after_import repository.after_import + wiki.repository.after_import import_finish remove_import_jid update_project_counter_caches diff --git a/changelogs/unreleased/sh-expire-content-cache-after-import.yml b/changelogs/unreleased/sh-expire-content-cache-after-import.yml new file mode 100644 index 00000000000..8876a487b86 --- /dev/null +++ b/changelogs/unreleased/sh-expire-content-cache-after-import.yml @@ -0,0 +1,5 @@ +--- +title: Expire Wiki content cache after importing a repository +merge_request: +author: +type: fixed diff --git a/lib/gitlab/github_import/sequential_importer.rb b/lib/gitlab/github_import/sequential_importer.rb index 3cad919b4eb..6a181caf65d 100644 --- a/lib/gitlab/github_import/sequential_importer.rb +++ b/lib/gitlab/github_import/sequential_importer.rb @@ -42,8 +42,6 @@ module Gitlab klass.new(project, client, parallel: false).execute end - project.repository.after_import - true end end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index aafbe52e5f8..0fd184d243f 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -50,7 +50,7 @@ class GithubImport end if import_success - @project.import_finish + @project.after_import puts "Import finished. Timings: #{timings}".color(:green) else puts "Import was not successful. Errors were as follows:" diff --git a/spec/lib/gitlab/github_import/sequential_importer_spec.rb b/spec/lib/gitlab/github_import/sequential_importer_spec.rb index 6089b0b751f..05d3243f806 100644 --- a/spec/lib/gitlab/github_import/sequential_importer_spec.rb +++ b/spec/lib/gitlab/github_import/sequential_importer_spec.rb @@ -30,7 +30,6 @@ describe Gitlab::GithubImport::SequentialImporter do expect(instance).to receive(:execute) end - expect(repository).to receive(:after_import) expect(importer.execute).to eq(true) end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 1a6ad3edd78..d385d617731 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -3391,10 +3391,11 @@ describe Project do end describe '#after_import' do - let(:project) { build(:project) } + let(:project) { create(:project) } it 'runs the correct hooks' do expect(project.repository).to receive(:after_import) + expect(project.wiki.repository).to receive(:after_import) expect(project).to receive(:import_finish) expect(project).to receive(:update_project_counter_caches) expect(project).to receive(:remove_import_jid) -- cgit v1.2.1