Commit 3223771b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rails5-fix-48430' into 'master'

Rails5 fix MySQL milliseconds problem in specs

Closes #48430

See merge request gitlab-org/gitlab-ce!20221
parents 54692746 f0eaf225
---
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 ...@@ -52,7 +52,7 @@ describe Gitlab::DataBuilder::Note do
expect(data[:issue].except('updated_at')) expect(data[:issue].except('updated_at'))
.to eq(issue.reload.hook_attrs.except('updated_at')) .to eq(issue.reload.hook_attrs.except('updated_at'))
expect(data[:issue]['updated_at']) expect(data[:issue]['updated_at'])
.to be > issue.hook_attrs['updated_at'] .to be >= issue.hook_attrs['updated_at']
end end
context 'with confidential issue' do context 'with confidential issue' do
...@@ -84,7 +84,7 @@ describe Gitlab::DataBuilder::Note do ...@@ -84,7 +84,7 @@ describe Gitlab::DataBuilder::Note do
expect(data[:merge_request].except('updated_at')) expect(data[:merge_request].except('updated_at'))
.to eq(merge_request.reload.hook_attrs.except('updated_at')) .to eq(merge_request.reload.hook_attrs.except('updated_at'))
expect(data[:merge_request]['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 end
include_examples 'project hook data' include_examples 'project hook data'
...@@ -107,7 +107,7 @@ describe Gitlab::DataBuilder::Note do ...@@ -107,7 +107,7 @@ describe Gitlab::DataBuilder::Note do
expect(data[:merge_request].except('updated_at')) expect(data[:merge_request].except('updated_at'))
.to eq(merge_request.reload.hook_attrs.except('updated_at')) .to eq(merge_request.reload.hook_attrs.except('updated_at'))
expect(data[:merge_request]['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 end
include_examples 'project hook data' include_examples 'project hook data'
...@@ -130,7 +130,7 @@ describe Gitlab::DataBuilder::Note do ...@@ -130,7 +130,7 @@ describe Gitlab::DataBuilder::Note do
expect(data[:snippet].except('updated_at')) expect(data[:snippet].except('updated_at'))
.to eq(snippet.reload.hook_attrs.except('updated_at')) .to eq(snippet.reload.hook_attrs.except('updated_at'))
expect(data[:snippet]['updated_at']) expect(data[:snippet]['updated_at'])
.to be > snippet.hook_attrs['updated_at'] .to be >= snippet.hook_attrs['updated_at']
end end
include_examples 'project hook data' include_examples 'project hook data'
......
...@@ -164,7 +164,7 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do ...@@ -164,7 +164,7 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
Timecop.freeze do Timecop.freeze do
importer.update_repository 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 end
end end
......
...@@ -571,13 +571,13 @@ describe Project do ...@@ -571,13 +571,13 @@ describe Project do
last_activity_at: timestamp, last_activity_at: timestamp,
last_repository_updated_at: timestamp - 1.hour) 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, project.update_attributes(updated_at: timestamp,
last_activity_at: timestamp - 1.hour, last_activity_at: timestamp - 1.hour,
last_repository_updated_at: nil) 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 end
end end
......
...@@ -8,7 +8,7 @@ describe Keys::LastUsedService do ...@@ -8,7 +8,7 @@ describe Keys::LastUsedService do
Timecop.freeze(time) { described_class.new(key).execute } 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 end
it 'does not update the key when it has been used recently' do it 'does not update the key when it has been used recently' do
...@@ -17,7 +17,7 @@ describe Keys::LastUsedService do ...@@ -17,7 +17,7 @@ describe Keys::LastUsedService do
described_class.new(key).execute described_class.new(key).execute
expect(key.last_used_at).to eq(time) expect(key.last_used_at).to be_like_time(time)
end end
it 'does not update the updated_at field' do it 'does not update the updated_at field' do
......
...@@ -12,7 +12,7 @@ describe MergeRequestMetricsService do ...@@ -12,7 +12,7 @@ describe MergeRequestMetricsService do
service.merge(event) service.merge(event)
expect(metrics.merged_by).to eq(user) 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
end end
...@@ -25,7 +25,7 @@ describe MergeRequestMetricsService do ...@@ -25,7 +25,7 @@ describe MergeRequestMetricsService do
service.close(event) service.close(event)
expect(metrics.latest_closed_by).to eq(user) 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
end end
......
...@@ -3,7 +3,7 @@ shared_examples_for 'throttled touch' do ...@@ -3,7 +3,7 @@ shared_examples_for 'throttled touch' do
it 'updates the updated_at timestamp' do it 'updates the updated_at timestamp' do
Timecop.freeze do Timecop.freeze do
subject.touch subject.touch
expect(subject.updated_at).to eq(Time.zone.now) expect(subject.updated_at).to be_like_time(Time.zone.now)
end end
end end
...@@ -14,7 +14,7 @@ shared_examples_for 'throttled touch' do ...@@ -14,7 +14,7 @@ shared_examples_for 'throttled touch' do
Timecop.freeze(first_updated_at) { subject.touch } Timecop.freeze(first_updated_at) { subject.touch }
Timecop.freeze(second_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 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