lib/dm-is-reflective/test.rb in dm-is-reflective-1.3.0 vs lib/dm-is-reflective/test.rb in dm-is-reflective-1.3.1
- old
+ new
@@ -67,10 +67,27 @@
end
include Abstract
shared :reflective do
+ def cat_indices
+ @cat_indices ||= begin
+ id = case DataMapper.repository.adapter.class.name
+ when 'DataMapper::Adapters::SqliteAdapter'
+ nil
+ else
+ [:id, {:unique_index => :abstract_cats_pkey, :key => true}]
+ end
+ [id ,
+ [:super_user_id, {:unique_index => :unique_abstract_cats_usu ,
+ :index => :index_abstract_cats_su }] ,
+ [ :user_id, {:unique_index => [:unique_abstract_cats_usu ,
+ :unique_abstract_cats_u]}] ].
+ compact
+ end
+ end
+
def cat_fields
@cat_fields ||=
[[:id, DataMapper::Property::Serial,
{:unique_index => :abstract_cats_pkey}.merge(AttrCommonPK)],
[:super_user_id, Integer,
@@ -202,9 +219,13 @@
r
}.should.eq('abstract_cats' => cat_fields,
'abstract_comments' => comment_fields,
'abstract_users' => user_fields,
'abstract_super_users' => super_user_fields)
+ end
+
+ should 'indices' do
+ sort_fields(@dm.indices('abstract_cats')).should.eq cat_indices
end
should 'reflect type' do
model, local_dm = create_fake_model
model.storage_names[:default] = 'abstract_comments'