spec/integration/shared/between_times.rb in by_star-3.0.0 vs spec/integration/shared/between_times.rb in by_star-4.0.0

- old
+ new

@@ -35,48 +35,65 @@ context 'timespan loose query' do context 'only start time' do subject { Event.between_times(Time.zone.parse('2014-01-01'), nil, strict: false) } - it { expect(subject.count).to eql(9) } + it { expect(subject.count).to eql(17) } end context 'only end time' do subject { Event.between_times(nil, Time.zone.parse('2014-01-01'), strict: false) } it { expect(subject.count).to eql(13) } context 'neither start nor end time' do subject { Event.between_times(nil, nil) } - it { expect(subject.count).to eql(22) } + it { expect(subject.count).to eql(30) } end end end context 'timespan strict query' do context 'only start time' do subject { Event.between_times(Time.zone.parse('2014-01-01'), nil) } - it { expect(subject.count).to eql(9) } + it { expect(subject.count).to eql(17) } end context 'only end time' do subject { Event.between_times(nil, Time.zone.parse('2014-01-01')) } it { expect(subject.count).to eql(13) } context 'neither start nor end time' do subject { Event.between_times(nil, nil) } - it { expect(subject.count).to eql(22) } + it { expect(subject.count).to eql(30) } end end end end - end - if testing_mongoid? - describe '#between' do - it 'should not override Mongoid between method' do - posts = Post.between(created_at: Time.zone.parse('2014-01-01')..Time.zone.parse('2014-01-06')) - expect(posts.count).to eql(3) + context 'two-sided query' do + context 'DST starts (Sydney)', sydney: true do + context 'day before' do + subject { Event.between_times(Date.parse('2020-04-04'), Date.parse('2020-04-04'), offset: 5.hours) } + it { expect(subject.count).to eql(3) } + end + + context 'same day' do + subject { Event.between_times(Date.parse('2020-04-05'), Date.parse('2020-04-05'), offset: 5.hours) } + it { expect(subject.count).to eql(1) } + end + end + + context 'when DST ends (Sydney)', sydney: true do + context 'day before' do + subject { Event.between_times(Date.parse('2020-10-03'), Date.parse('2020-10-03'), offset: 5.hours) } + it { expect(subject.count).to eql(1) } + end + + context 'same day' do + subject { Event.between_times(Date.parse('2020-10-04'), Date.parse('2020-10-04'), offset: 5.hours) } + it { expect(subject.count).to eql(3) } + end end end end end