gitlab-org--gitlab-foss/spec/models/merge_request/metrics_spec.rb
Nick Thomas bfb20200e9 Add a be_like_time matcher and use it in specs
The amount of precision times have in databases is variable, so we need
tolerances when comparing in specs. It's better to have the tolerance defined
in one place than several.
2016-10-17 14:44:20 +01:00

18 lines
504 B
Ruby

require 'spec_helper'
describe MergeRequest::Metrics, models: true do
let(:project) { create(:project) }
subject { create(:merge_request, source_project: project) }
describe "when recording the default set of metrics on merge request save" do
it "records the merge time" do
time = Time.now
Timecop.freeze(time) { subject.mark_as_merged }
metrics = subject.metrics
expect(metrics).to be_present
expect(metrics.merged_at).to be_like_time(time)
end
end
end