Commit b5f388cc authored by Mark Chao's avatar Mark Chao

Refactor code around transaction

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