Commit ce418036 authored by James Lopez's avatar James Lopez

add callbacks in bulk

parent 606584c1
......@@ -35,12 +35,12 @@ module Projects
service_hash.merge('project_id' => project_id).values
end
# Project.transaction do
# Service.create!(service_hash_list)
# end
Gitlab::SQL::BulkInsert.new(service_hash.keys + ['project_id'],
service_list,
'services').execute
Project.transaction do
Gitlab::SQL::BulkInsert.new(service_hash.keys + ['project_id'],
service_list,
'services').execute
run_callbacks(batch)
end
end
def project_ids_batch
......@@ -72,5 +72,23 @@ module Projects
end
end
end
def run_callbacks(batch)
if active_external_issue_tracker?
Project.where(id: batch).update_all(has_external_issue_tracker: true)
end
if active_external_wiki?
Project.where(id: batch).update_all(has_external_wiki: true)
end
end
def active_external_issue_tracker?
@template['category'] == 'issue_tracker' && @template['active'] && !@template['default']
end
def active_external_wiki?
@template['type'] == 'ExternalWikiService' && @template['active']
end
end
end
......@@ -78,5 +78,23 @@ describe Projects::PropagateService, services: true do
to change { Service.count }.by(project_total + 1)
end
end
describe 'external tracker' do
it 'updates the project external tracker' do
service_template.update(category: 'issue_tracker', default: false)
expect { described_class.propagate(service_template) }.
to change { project.reload.has_external_issue_tracker }.to(true)
end
end
describe 'external wiki' do
it 'updates the project external tracker' do
service_template.update(type: 'ExternalWikiService')
expect { described_class.propagate(service_template) }.
to change { project.reload.has_external_wiki }.to(true)
end
end
end
end
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