Updated regexp for filter system collections

Fixed cleaning collections with names like:

favourite_systems
operating_systems
systems

and so on.

All real mongo's system collections have following name format (as in 2.4.1):

  {db_name}.system.{system_collection_type}
This commit is contained in:
Viacheslav Molokov 2014-06-20 16:14:35 +04:00
parent 8d7f72ffc9
commit 1111b7fa9f

View file

@ -23,7 +23,7 @@ module DatabaseCleaner
session.use(db) session.use(db)
end end
session['system.namespaces'].find(:name => { '$not' => /system|\$/ }).to_a.map do |collection| session['system.namespaces'].find(:name => { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
_, name = collection['name'].split('.', 2) _, name = collection['name'].split('.', 2)
name name
end end