File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
lib/mongo/collection/view
spec/mongo/collection/view Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,7 @@ def count(opts = {})
207
207
# command to run.
208
208
# @option opts [ Hash ] :read The read preference options.
209
209
# @option opts [ Hash ] :collation The collation to use.
210
+ # @option opts [ Mongo::Session ] :session The session to use for the operation.
210
211
#
211
212
# @return [ Integer ] The document count.
212
213
#
Original file line number Diff line number Diff line change 671
671
end
672
672
end
673
673
674
+ describe '#count_documents' do
675
+
676
+ let ( :result ) do
677
+ new_view . count_documents ( options )
678
+ end
679
+
680
+ context 'when session is given' do
681
+ let ( :subscriber ) { Mrss ::EventSubscriber . new }
682
+
683
+ before do
684
+ authorized_collection . client . subscribe ( Mongo ::Monitoring ::COMMAND , subscriber )
685
+ end
686
+
687
+ it 'passes the session' do
688
+ authorized_collection . client . with_session do |session |
689
+ session_id = session . session_id
690
+
691
+ authorized_collection . count_documents ( { } , session : session )
692
+
693
+ event = subscriber . single_command_started_event ( 'aggregate' )
694
+ event . command [ 'lsid' ] . should == session_id
695
+ end
696
+ end
697
+ end
698
+ end
699
+
674
700
describe '#distinct' do
675
701
676
702
context 'when incorporating read concern' do
You can’t perform that action at this time.
0 commit comments