Follow up - a99f87a - Fixes #2085 - timezone issue with elasticsearch: Added tests.

This commit is contained in:
Mantas Masalskis 2021-07-14 14:07:07 +00:00 committed by Thorsten Eckel
parent fd5be086ec
commit 9a71ac98d5

View file

@ -75,15 +75,28 @@ RSpec.describe SearchIndexBackend, searchindex: true do
let(:record) { create :ticket } let(:record) { create :ticket }
before do before do
travel_to(Time.zone.parse('2019-01-01 23:33')) travel_to(Time.zone.parse('2019-01-02 00:33'))
described_class.add(record_type, record) described_class.add(record_type, record)
described_class.refresh described_class.refresh
end end
it 'finds record in effective time zone' do it 'finds record in a given timezone with a range' do
Setting.set('timezone_default', 'UTC')
result = described_class.search('created_at: [2019-01-01 TO 2019-01-01]', record_type) result = described_class.search('created_at: [2019-01-01 TO 2019-01-01]', record_type)
expect(result).to eq([{ id: record.id.to_s, type: record_type }]) expect(result).to eq([{ id: record.id.to_s, type: record_type }])
end end
it 'finds record in a far away timezone with a date' do
Setting.set('timezone_default', 'Europe/Vilnius')
result = described_class.search('created_at: 2019-01-02', record_type)
expect(result).to eq([{ id: record.id.to_s, type: record_type }])
end
it 'finds record in UTC with date' do
Setting.set('timezone_default', 'UTC')
result = described_class.search('created_at: 2019-01-01', record_type)
expect(result).to eq([{ id: record.id.to_s, type: record_type }])
end
end end
context 'does find integer values for ticket data', db_strategy: :reset do context 'does find integer values for ticket data', db_strategy: :reset do