Commit b3d648b4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Prevent duplicate merge events

parent 3c5954b8
......@@ -177,15 +177,8 @@ class MergeRequest < ActiveRecord::Base
end
def merge!(user_id)
self.author_id_of_changes = user_id
self.merge
Event.create(
project: self.project,
action: Event::MERGED,
target_id: self.id,
target_type: "MergeRequest",
author_id: user_id
)
end
def automerge!(current_user)
......
......@@ -39,4 +39,18 @@ class ActivityObserver < ActiveRecord::Observer
author_id: record.author_id_of_changes
)
end
def after_merge(record, transition)
# Since MR can be merged via sidekiq
# to prevent event duplication do this check
return true if record.merge_event
Event.create(
project: record.project,
target_id: record.id,
target_type: record.class.name,
action: Event::MERGED,
author_id: record.author_id_of_changes
)
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