@@ -20,7 +20,6 @@ const CollectionStatsStore = Reflux.createStore({
20
20
*/
21
21
init : function ( ) {
22
22
this . listenTo ( NamespaceStore , this . loadCollectionStats ) ;
23
- this . CollectionStore = app . appRegistry . getStore ( 'App.CollectionStore' ) ;
24
23
} ,
25
24
26
25
/**
@@ -30,7 +29,7 @@ const CollectionStatsStore = Reflux.createStore({
30
29
*/
31
30
loadCollectionStats : function ( ns ) {
32
31
if ( toNS ( ns || '' ) . collection ) {
33
- if ( this . CollectionStore . isReadonly ( ) ) {
32
+ if ( this . _isCollectionReadonly ( ) ) {
34
33
this . trigger ( ) ;
35
34
} else {
36
35
app . dataService . collection ( ns , { readPreference : READ } , ( err , result ) => {
@@ -42,6 +41,29 @@ const CollectionStatsStore = Reflux.createStore({
42
41
}
43
42
} ,
44
43
44
+ /**
45
+ * Determine if the collection is readonly.
46
+ *
47
+ * @note Durran: The wacky logic here is because the ampersand app is not
48
+ * loaded in the unit test environment and the validation tests fail since
49
+ * not app registry is found. Once we get rid of the ampersand app we can
50
+ * put the store set back into the init once we've sorted out the proper
51
+ * test strategy.
52
+ *
53
+ * @returns {Boolean } If the collection is readonly.
54
+ */
55
+ _isCollectionReadonly ( ) {
56
+ if ( this . CollectionStore ) {
57
+ return this . CollectionStore . isReadonly ( ) ;
58
+ }
59
+ const registry = app . appRegistry ;
60
+ if ( registry ) {
61
+ this . CollectionStore = registry . getStore ( 'App.CollectionStore' ) ;
62
+ return this . CollectionStore . isReadonly ( ) ;
63
+ }
64
+ return false ;
65
+ } ,
66
+
45
67
_parseCollectionDetails ( result ) {
46
68
return {
47
69
documentCount : this . _format ( result . document_count ) ,
0 commit comments