From fbb48bd7e9e20037bb5a1b79e70f68f2d4bc3170 Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Sat, 7 Jul 2018 13:46:23 +0200 Subject: [PATCH] Rails5 fix mysql milliseconds problem in specs --- changelogs/unreleased/rails5-fix-48977.yml | 5 +++++ spec/models/user_spec.rb | 4 +++- spec/services/ci/retry_build_service_spec.rb | 12 ++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/rails5-fix-48977.yml diff --git a/changelogs/unreleased/rails5-fix-48977.yml b/changelogs/unreleased/rails5-fix-48977.yml new file mode 100644 index 00000000000..bfd86f20e24 --- /dev/null +++ b/changelogs/unreleased/rails5-fix-48977.yml @@ -0,0 +1,5 @@ +--- +title: Rails5 fix mysql milliseconds problem in specs +merge_request: 20464 +author: Jasper Maes +type: fixed diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 097144d04ce..57c408498dd 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2461,7 +2461,9 @@ describe User do it 'changes the namespace (just to compare to when username is not changed)' do expect do - user.update_attributes!(username: new_username) + Timecop.freeze(1.second.from_now) do + user.update_attributes!(username: new_username) + end end.to change { user.namespace.updated_at } end diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index decb5d22f59..b8cdbc8c0f6 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -100,7 +100,11 @@ describe Ci::RetryBuildService do end describe '#execute' do - let(:new_build) { service.execute(build) } + let(:new_build) do + Timecop.freeze(1.second.from_now) do + service.execute(build) + end + end context 'when user has ability to execute build' do before do @@ -150,7 +154,11 @@ describe Ci::RetryBuildService do end describe '#reprocess' do - let(:new_build) { service.reprocess!(build) } + let(:new_build) do + Timecop.freeze(1.second.from_now) do + service.reprocess!(build) + end + end context 'when user has ability to execute build' do before do