test/unit/orm/mongoid_test.rb in has_constant-0.4.5 vs test/unit/orm/mongoid_test.rb in has_constant-0.4.6

- old
+ new

@@ -36,10 +36,16 @@ assert MongoUserWithout.fields.map(&:first).include?('sal') end should 'add index when index option is supplied' do MongoUserWithout.has_constant :salutations, ['Mr', 'Mrs'], :index => true - assert MongoUserWithout.index_information.keys.any? { |k| k.match(/salutation/) } + MongoUserWithout.create_indexes + assert MongoUserWithout.index_information.keys.any? { |key| key.match(/salutation/) } + end + + should 'not index when index option is not supplied' do + MongoUser.create_indexes + assert !MongoUser.index_information.keys.any? { |key| key.match(/salutation/) } end should 'save values as integers' do m = MongoUser.new(:salutation => 'Mr') m.save!