File tree 3 files changed +6
-4
lines changed
3 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,10 @@ class Event < ApplicationRecord
22
22
default_scope -> { where ( label : Whitelabel [ :label_id ] ) }
23
23
24
24
scope :with_topics , -> { joins ( :topics ) . distinct }
25
- scope :current , -> { where ( date : Date . today . to_time ..( Time . now + 9 . weeks ) ) . limit ( 1 ) . order ( ' date ASC' ) }
26
- scope :latest , -> { where ( 'date < ?' , Date . today . to_time ) . order ( ' date DESC' ) }
25
+ scope :current , -> { where ( date : Date . today . to_time ..) . limit ( 1 ) . order ( date : :asc ) }
26
+ scope :latest , -> { where ( 'date < ?' , Date . today . to_time ) . order ( date : :desc ) }
27
27
scope :unpublished , -> { where ( 'published IS NULL' ) }
28
- scope :ordered , -> { order ( ' date DESC' ) }
28
+ scope :ordered , -> { order ( date : :desc ) }
29
29
30
30
def end_date
31
31
date + 2 . hours
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ class Highlight < ApplicationRecord
5
5
6
6
default_scope -> { where ( label : Whitelabel [ :label_id ] ) }
7
7
8
- scope :active , -> { where ( 'end_at > ?' , Time . now ) . order ( ' start_at' ) . limit ( 1 ) }
8
+ scope :active , -> { where ( 'end_at > ?' , Time . now ) . order ( start_at : :asc ) . limit ( 1 ) }
9
9
10
10
def disabled?
11
11
end_at <= Time . now
Original file line number Diff line number Diff line change 24
24
it 'finds a current event' do
25
25
event_next = create ( :event , date : 2 . days . from_now )
26
26
expect ( Event . current . first ) . to eql ( event_next )
27
+ event_next . update ( date : 5 . months . from_now )
28
+ expect ( Event . current . first ) . to eql ( event_next )
27
29
end
28
30
end
29
31
You can’t perform that action at this time.
0 commit comments