Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/migrations/update_historical_data_recorded_at_spec.rb
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/migrations/update_historical_data_recorded_at_spec.rb')
-rw-r--r--spec/migrations/update_historical_data_recorded_at_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/migrations/update_historical_data_recorded_at_spec.rb b/spec/migrations/update_historical_data_recorded_at_spec.rb
new file mode 100644
index 00000000000..bccc711f339
--- /dev/null
+++ b/spec/migrations/update_historical_data_recorded_at_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require Rails.root.join('db', 'migrate', '20201022094846_update_historical_data_recorded_at.rb')
+
+RSpec.describe UpdateHistoricalDataRecordedAt do
+ let(:historical_data_table) { table(:historical_data) }
+
+ it 'reversibly populates recorded_at from created_at or date' do
+ row1 = historical_data_table.create!(
+ date: Date.current - 1.day,
+ created_at: Time.current - 1.day
+ )
+
+ row2 = historical_data_table.create!(date: Date.current - 2.days)
+ row2.update!(created_at: nil)
+
+ reversible_migration do |migration|
+ migration.before -> {
+ expect(row1.reload.recorded_at).to eq(nil)
+ expect(row2.reload.recorded_at).to eq(nil)
+ }
+
+ migration.after -> {
+ expect(row1.reload.recorded_at).to eq(row1.created_at)
+ expect(row2.reload.recorded_at).to eq(row2.date.in_time_zone(Time.zone).change(hour: 12))
+ }
+ end
+ end
+end