Commit b5f388cc authored by Mark Chao's avatar Mark Chao

Refactor code around transaction

Extract transaction
parent d79b7d3f
......@@ -98,6 +98,7 @@ module Gitlab
raise "Incorrect target_type #{target_type}" unless ALLOWED_TARGET_TYPES.include?(@target_type)
ActiveRecord::Base.transaction do
case target
when MergeRequest
handle_merge_request
......@@ -105,24 +106,21 @@ module Gitlab
handle_project
end
end
end
private
def handle_merge_request
ActiveRecord::Base.transaction do
if rule = sync_rule
rule.approval_project_rule = target.target_project.approval_rules.regular.first
end
target.sync_code_owners_with_approvers
end
end
def handle_project
ActiveRecord::Base.transaction do
sync_rule
end
end
def sync_rule
unless approvers_exists?
......
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