summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database_spec.rb
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-10-30 20:21:56 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-10-30 21:13:39 -0300
commit1796936abc8873c1fcc38061fe3d8b44acda3ffe (patch)
treefa1544c2bacc27624f2c107dbf6679dc6ceb08d4 /spec/lib/gitlab/database_spec.rb
parentbba020a56cbedd6403b637ec7f9eaee258eb7c67 (diff)
downloadgitlab-ce-1796936abc8873c1fcc38061fe3d8b44acda3ffe.tar.gz
Handle large values on `MergeRequestDiffCommit` dates39561-seed_fu-fails-to-load-gitlab-test
Diffstat (limited to 'spec/lib/gitlab/database_spec.rb')
-rw-r--r--spec/lib/gitlab/database_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb
index 5fa94999d25..7aeb85b8f5a 100644
--- a/spec/lib/gitlab/database_spec.rb
+++ b/spec/lib/gitlab/database_spec.rb
@@ -256,4 +256,26 @@ describe Gitlab::Database do
expect(described_class.false_value).to eq 0
end
end
+
+ describe '#sanitize_timestamp' do
+ let(:max_timestamp) { Time.at((1 << 31) - 1) }
+
+ subject { described_class.sanitize_timestamp(timestamp) }
+
+ context 'with a timestamp smaller than MAX_TIMESTAMP_VALUE' do
+ let(:timestamp) { max_timestamp - 10.years }
+
+ it 'returns the given timestamp' do
+ expect(subject).to eq(timestamp)
+ end
+ end
+
+ context 'with a timestamp larger than MAX_TIMESTAMP_VALUE' do
+ let(:timestamp) { max_timestamp + 1.second }
+
+ it 'returns MAX_TIMESTAMP_VALUE' do
+ expect(subject).to eq(max_timestamp)
+ end
+ end
+ end
end