Commit 47b10c4c authored by Michael Kozono's avatar Michael Kozono

Merge branch 'sh-fix-obsolete-column-date-boundary-test' into 'master'

Fix date-dependent test failure in obsolete_ignored_columns_spec.rb

Closes #118612

See merge request gitlab-org/gitlab!21887
parents a66e4518 d0754e4d
......@@ -4,6 +4,9 @@ require 'spec_helper'
describe Gitlab::Database::ObsoleteIgnoredColumns do
module Testing
# Used a fixed date to prevent tests failing across date boundaries
REMOVE_DATE = Date.new(2019, 12, 16)
class MyBase < ApplicationRecord
end
......@@ -23,12 +26,12 @@ describe Gitlab::Database::ObsoleteIgnoredColumns do
self.table_name = 'issues'
ignore_column :id, :other, remove_after: '2019-01-01', remove_with: '12.0'
ignore_column :not_used_but_still_ignored, remove_after: Date.today.to_s, remove_with: '12.1'
ignore_column :not_used_but_still_ignored, remove_after: REMOVE_DATE.to_s, remove_with: '12.1'
end
class A < SomeAbstract
ignore_column :also_unused, remove_after: '2019-02-01', remove_with: '12.1'
ignore_column :not_used_but_still_ignored, remove_after: Date.today.to_s, remove_with: '12.1'
ignore_column :not_used_but_still_ignored, remove_after: REMOVE_DATE.to_s, remove_with: '12.1'
end
class C < MyBase
......@@ -40,6 +43,7 @@ describe Gitlab::Database::ObsoleteIgnoredColumns do
describe '#execute' do
it 'returns a list of class names and columns pairs' do
Timecop.freeze(Testing::REMOVE_DATE) do
expect(subject.execute).to eq([
['Testing::A', {
'unused' => IgnorableColumns::ColumnIgnore.new(Date.parse('2019-01-01'), '12.0'),
......@@ -51,4 +55,5 @@ describe Gitlab::Database::ObsoleteIgnoredColumns do
])
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