Commit 17ab745e authored by Douwe Maan's avatar Douwe Maan

Add Timeless helper module to prevent updated_at from being updated

parent a9fa45f0
...@@ -85,12 +85,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -85,12 +85,7 @@ class MergeRequest < ActiveRecord::Base
state :cannot_be_merged state :cannot_be_merged
around_transition do |merge_request, transition, block| around_transition do |merge_request, transition, block|
merge_request.record_timestamps = false Gitlab::Timeless.timeless(merge_request, &block)
begin
block.call
ensure
merge_request.record_timestamps = true
end
end end
end end
......
module Gitlab
module Timeless
def self.timeless(model, &block)
original_record_timestamps = model.record_timestamps
model.record_timestamps = false
if block.arity.abs == 1
block.call(model)
else
block.call
end
ensure
model.record_timestamps = original_record_timestamps
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