@@ -762,6 +762,41 @@ def test_ensure_index_timeout
762
762
assert_equal 1 , @collection . size
763
763
end
764
764
end
765
+
766
+ context "Drop index " do
767
+ setup do
768
+ @@db . drop_collection ( 'test-collection' )
769
+ @collection = @@db . collection ( 'test-collection' )
770
+ end
771
+
772
+ should "drop an index" do
773
+ @collection . create_index ( [ [ 'a' , Mongo ::ASCENDING ] ] )
774
+ assert @collection . index_information [ 'a_1' ]
775
+ @collection . drop_index ( [ [ 'a' , Mongo ::ASCENDING ] ] )
776
+ assert_nil @collection . index_information [ 'a_1' ]
777
+ end
778
+
779
+ should "drop an index which was given a specific name" do
780
+ @collection . create_index ( [ [ 'a' , Mongo ::DESCENDING ] ] , { :name => 'i_will_not_fear' } )
781
+ assert @collection . index_information [ 'i_will_not_fear' ]
782
+ @collection . drop_index ( [ [ 'a' , Mongo ::DESCENDING ] ] )
783
+ assert_nil @collection . index_information [ 'i_will_not_fear' ]
784
+ end
785
+
786
+ should "drops an composite index" do
787
+ @collection . create_index ( [ [ 'a' , Mongo ::DESCENDING ] , [ 'b' , Mongo ::ASCENDING ] ] )
788
+ assert @collection . index_information [ 'a_-1_b_1' ]
789
+ @collection . drop_index ( [ [ 'a' , Mongo ::DESCENDING ] , [ 'b' , Mongo ::ASCENDING ] ] )
790
+ assert_nil @collection . index_information [ 'a_-1_b_1' ]
791
+ end
792
+
793
+ should "drops an index with symbols" do
794
+ @collection . create_index ( [ [ 'a' , Mongo ::DESCENDING ] , [ :b , Mongo ::ASCENDING ] ] )
795
+ assert @collection . index_information [ 'a_-1_b_1' ]
796
+ @collection . drop_index ( [ [ 'a' , Mongo ::DESCENDING ] , [ :b , Mongo ::ASCENDING ] ] )
797
+ assert_nil @collection . index_information [ 'a_-1_b_1' ]
798
+ end
799
+ end
765
800
766
801
context "Creating indexes " do
767
802
setup do
0 commit comments