diff options
author | Jasper Maes <jaspermaes.jm@gmail.com> | 2018-06-27 19:25:25 +0300 |
---|---|---|
committer | Jasper Maes <jaspermaes.jm@gmail.com> | 2018-06-27 19:49:22 +0300 |
commit | f0eaf225538b40db5d0b2a6110378b65a240eac8 (patch) | |
tree | eaec46d8a236b175640efb902a9807ce6ca0619c | |
parent | 07de43a7e07cefcbb60e7ed84c684f478eae8b93 (diff) |
Rails5 fix MySQL milliseconds problem in specs
-rw-r--r-- | changelogs/unreleased/rails5-fix-48430.yml | 5 | ||||
-rw-r--r-- | spec/lib/gitlab/data_builder/note_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/keys/last_used_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/update_merge_request_metrics_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/support/shared_examples/throttled_touch.rb | 4 |
7 files changed, 18 insertions, 13 deletions
diff --git a/changelogs/unreleased/rails5-fix-48430.yml b/changelogs/unreleased/rails5-fix-48430.yml new file mode 100644 index 00000000000..16495615395 --- /dev/null +++ b/changelogs/unreleased/rails5-fix-48430.yml @@ -0,0 +1,5 @@ +--- +title: Rails5 fix MySQL milliseconds problem in specs +merge_request: 20221 +author: Jasper Maes +type: fixed diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb index 4f8412108ba..b236c1a9c49 100644 --- a/spec/lib/gitlab/data_builder/note_spec.rb +++ b/spec/lib/gitlab/data_builder/note_spec.rb @@ -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' diff --git a/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb index 44695acbe7d..51fad6c6838 100644 --- a/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb @@ -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 diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index a2f8fac2f38..abdc65336ca 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -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 diff --git a/spec/services/keys/last_used_service_spec.rb b/spec/services/keys/last_used_service_spec.rb index bb0fb6acf39..8e553c2f1fa 100644 --- a/spec/services/keys/last_used_service_spec.rb +++ b/spec/services/keys/last_used_service_spec.rb @@ -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 diff --git a/spec/services/update_merge_request_metrics_service_spec.rb b/spec/services/update_merge_request_metrics_service_spec.rb index b5fb999381d..812dd42934d 100644 --- a/spec/services/update_merge_request_metrics_service_spec.rb +++ b/spec/services/update_merge_request_metrics_service_spec.rb @@ -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 diff --git a/spec/support/shared_examples/throttled_touch.rb b/spec/support/shared_examples/throttled_touch.rb index 4a25bb9b750..eba990d4037 100644 --- a/spec/support/shared_examples/throttled_touch.rb +++ b/spec/support/shared_examples/throttled_touch.rb @@ -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 |