This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +5
-10
lines changed
spec/lib/modules/sentiment Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ module Sentiment
55 class EmotionFilterOrder
66 def self . register! ( plugin )
77 Emotions ::LIST . each do |emotion |
8- filter_order_emotion = -> ( scope , order_direction ) do
8+ filter_order_emotion = -> ( scope , order_direction , _guardian ) do
99 scope_period =
1010 scope
1111 . arel
Original file line number Diff line number Diff line change 88 let ( :post_1 ) { Fabricate ( :post ) }
99 let ( :post_2 ) { Fabricate ( :post ) }
1010 let ( :post_3 ) { Fabricate ( :post ) }
11+ let ( :guardian ) { Guardian . new }
1112 let ( :classification_1 ) do
1213 {
1314 love : 0.9444406 ,
179180 . find { _1 . keys . include? "order:emotion_#{ emotion } " }
180181 . values
181182 . first
182- result = filter . call ( scope , order_direction )
183+ result = filter . call ( scope , order_direction , guardian )
183184
184185 expect ( result . to_sql ) . to include ( "classification_results" )
185186 expect ( result . to_sql ) . to include (
190191
191192 it "sorts emotion in ascending order" do
192193 expect (
193- TopicsFilter
194- . new ( guardian : Guardian . new )
195- . filter_from_query_string ( "order:emotion_love-asc" )
196- . pluck ( :id ) ,
194+ TopicsFilter . new ( guardian :) . filter_from_query_string ( "order:emotion_love-asc" ) . pluck ( :id ) ,
197195 ) . to contain_exactly ( post_2 . topic . id , post_1 . topic . id )
198196 end
199197 it "sorts emotion in default descending order" do
200198 expect (
201- TopicsFilter
202- . new ( guardian : Guardian . new )
203- . filter_from_query_string ( "order:emotion_love" )
204- . pluck ( :id ) ,
199+ TopicsFilter . new ( guardian :) . filter_from_query_string ( "order:emotion_love" ) . pluck ( :id ) ,
205200 ) . to contain_exactly ( post_1 . topic . id , post_2 . topic . id )
206201 end
207202end
You can’t perform that action at this time.
0 commit comments