Commit 22e000ec authored by Stan Hu's avatar Stan Hu

Merge branch 'rs-remove_jid' into 'master'

Remove `remove_jid` method from ProjectImportState

See merge request gitlab-org/gitlab!20500
parents 14eb7a47 7c13836f
......@@ -1773,7 +1773,6 @@ class Project < ApplicationRecord
InternalId.flush_records!(project: self)
import_state.finish
import_state.remove_jid
update_project_counter_caches
after_create_default_branch
join_pool_repository
......
......@@ -42,6 +42,14 @@ class ProjectImportState < ApplicationRecord
end
end
after_transition any => :finished do |state, _|
if state.jid.present?
Gitlab::SidekiqStatus.unset(state.jid)
state.update_column(:jid, nil)
end
end
after_transition started: :finished do |state, _|
project = state.project
......@@ -81,14 +89,6 @@ class ProjectImportState < ApplicationRecord
status == 'started' && project.import?
end
def remove_jid
return unless jid
Gitlab::SidekiqStatus.unset(jid)
update_column(:jid, nil)
end
# Refreshes the expiration time of the associated import job ID.
#
# This method can be used by asynchronous importers to refresh the status,
......
......@@ -95,30 +95,28 @@ describe ProjectImportState, type: :model do
end
end
describe '#remove_jid', :clean_gitlab_redis_cache do
let(:project) { }
describe 'clearing `jid` after finish', :clean_gitlab_redis_cache do
context 'without an JID' do
it 'does nothing' do
import_state = create(:import_state)
import_state = create(:import_state, :started)
expect(Gitlab::SidekiqStatus)
.not_to receive(:unset)
import_state.remove_jid
import_state.finish!
end
end
context 'with an JID' do
it 'unsets the JID' do
import_state = create(:import_state, jid: '123')
import_state = create(:import_state, :started, jid: '123')
expect(Gitlab::SidekiqStatus)
.to receive(:unset)
.with('123')
.and_call_original
import_state.remove_jid
import_state.finish!
expect(import_state.jid).to be_nil
end
......
......@@ -4335,7 +4335,6 @@ describe Project do
expect(project.wiki.repository).to receive(:after_import)
expect(import_state).to receive(:finish)
expect(project).to receive(:update_project_counter_caches)
expect(import_state).to receive(:remove_jid)
expect(project).to receive(:after_create_default_branch)
expect(project).to receive(:refresh_markdown_cache!)
expect(InternalId).to receive(:flush_records!).with(project: project)
......
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