Rails5 fix MySQL milliseconds problem in specs
This commit is contained in:
parent
07de43a7e0
commit
f0eaf22553
7 changed files with 18 additions and 13 deletions
5
changelogs/unreleased/rails5-fix-48430.yml
Normal file
5
changelogs/unreleased/rails5-fix-48430.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Rails5 fix MySQL milliseconds problem in specs
|
||||
merge_request: 20221
|
||||
author: Jasper Maes
|
||||
type: fixed
|
|
@ -52,7 +52,7 @@ describe Gitlab::DataBuilder::Note do
|
|||
expect(data[:issue].except('updated_at'))
|
||||
.to eq(issue.reload.hook_attrs.except('updated_at'))
|
||||
expect(data[:issue]['updated_at'])
|
||||
.to be > issue.hook_attrs['updated_at']
|
||||
.to be >= issue.hook_attrs['updated_at']
|
||||
end
|
||||
|
||||
context 'with confidential issue' do
|
||||
|
@ -84,7 +84,7 @@ describe Gitlab::DataBuilder::Note do
|
|||
expect(data[:merge_request].except('updated_at'))
|
||||
.to eq(merge_request.reload.hook_attrs.except('updated_at'))
|
||||
expect(data[:merge_request]['updated_at'])
|
||||
.to be > merge_request.hook_attrs['updated_at']
|
||||
.to be >= merge_request.hook_attrs['updated_at']
|
||||
end
|
||||
|
||||
include_examples 'project hook data'
|
||||
|
@ -107,7 +107,7 @@ describe Gitlab::DataBuilder::Note do
|
|||
expect(data[:merge_request].except('updated_at'))
|
||||
.to eq(merge_request.reload.hook_attrs.except('updated_at'))
|
||||
expect(data[:merge_request]['updated_at'])
|
||||
.to be > merge_request.hook_attrs['updated_at']
|
||||
.to be >= merge_request.hook_attrs['updated_at']
|
||||
end
|
||||
|
||||
include_examples 'project hook data'
|
||||
|
@ -130,7 +130,7 @@ describe Gitlab::DataBuilder::Note do
|
|||
expect(data[:snippet].except('updated_at'))
|
||||
.to eq(snippet.reload.hook_attrs.except('updated_at'))
|
||||
expect(data[:snippet]['updated_at'])
|
||||
.to be > snippet.hook_attrs['updated_at']
|
||||
.to be >= snippet.hook_attrs['updated_at']
|
||||
end
|
||||
|
||||
include_examples 'project hook data'
|
||||
|
|
|
@ -164,7 +164,7 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
|
|||
Timecop.freeze do
|
||||
importer.update_repository
|
||||
|
||||
expect(project.last_repository_updated_at).to eq(Time.zone.now)
|
||||
expect(project.last_repository_updated_at).to be_like_time(Time.zone.now)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -571,13 +571,13 @@ describe Project do
|
|||
last_activity_at: timestamp,
|
||||
last_repository_updated_at: timestamp - 1.hour)
|
||||
|
||||
expect(project.last_activity_date).to eq(timestamp)
|
||||
expect(project.last_activity_date).to be_like_time(timestamp)
|
||||
|
||||
project.update_attributes(updated_at: timestamp,
|
||||
last_activity_at: timestamp - 1.hour,
|
||||
last_repository_updated_at: nil)
|
||||
|
||||
expect(project.last_activity_date).to eq(timestamp)
|
||||
expect(project.last_activity_date).to be_like_time(timestamp)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Keys::LastUsedService do
|
|||
|
||||
Timecop.freeze(time) { described_class.new(key).execute }
|
||||
|
||||
expect(key.last_used_at).to eq(time)
|
||||
expect(key.reload.last_used_at).to be_like_time(time)
|
||||
end
|
||||
|
||||
it 'does not update the key when it has been used recently' do
|
||||
|
@ -17,7 +17,7 @@ describe Keys::LastUsedService do
|
|||
|
||||
described_class.new(key).execute
|
||||
|
||||
expect(key.last_used_at).to eq(time)
|
||||
expect(key.last_used_at).to be_like_time(time)
|
||||
end
|
||||
|
||||
it 'does not update the updated_at field' do
|
||||
|
|
|
@ -12,7 +12,7 @@ describe MergeRequestMetricsService do
|
|||
service.merge(event)
|
||||
|
||||
expect(metrics.merged_by).to eq(user)
|
||||
expect(metrics.merged_at).to eq(event.created_at)
|
||||
expect(metrics.merged_at).to be_like_time(event.created_at)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ describe MergeRequestMetricsService do
|
|||
service.close(event)
|
||||
|
||||
expect(metrics.latest_closed_by).to eq(user)
|
||||
expect(metrics.latest_closed_at).to eq(event.created_at)
|
||||
expect(metrics.latest_closed_at).to be_like_time(event.created_at)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ shared_examples_for 'throttled touch' do
|
|||
it 'updates the updated_at timestamp' do
|
||||
Timecop.freeze do
|
||||
subject.touch
|
||||
expect(subject.updated_at).to eq(Time.zone.now)
|
||||
expect(subject.updated_at).to be_like_time(Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,7 +14,7 @@ shared_examples_for 'throttled touch' do
|
|||
Timecop.freeze(first_updated_at) { subject.touch }
|
||||
Timecop.freeze(second_updated_at) { subject.touch }
|
||||
|
||||
expect(subject.updated_at).to eq(first_updated_at)
|
||||
expect(subject.updated_at).to be_like_time(first_updated_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue