Refactoring Geo::ScheduleWikiRepoUpdateService

parent a5dd3dd4
......@@ -8,18 +8,10 @@ module Geo
def execute
@projects.each do |project|
next unless can_update?(project['id'])
next unless Gitlab::Geo.current_node&.projects_include?(project['id'].to_i)
GeoWikiRepositoryUpdateWorker.perform_async(project['id'], project['clone_url'])
end
end
private
def can_update?(project_id)
return true if Gitlab::Geo.current_node&.restricted_project_ids.nil?
Gitlab::Geo.current_node.restricted_project_ids.include?(project_id)
end
end
end
......@@ -16,6 +16,8 @@ describe Geo::ScheduleWikiRepoUpdateService do
subject { described_class.new(projects) }
it "enqueues a batch of IDs of wiki's projects to have their wiki repositories updated" do
create(:geo_node, :current)
expect(GeoWikiRepositoryUpdateWorker).to receive(:perform_async)
.once.with(project_1.id, 'git@example.com:mike/diaspora.git').and_return(spy)
expect(GeoWikiRepositoryUpdateWorker).to receive(:perform_async)
......
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