 
 QUnit.module "Batman.Model hasMany Associations"
   setup: ->
-    namespace = this
+    Batman.currentApp = null
+    namespace = {}
 
-    class @Store extends Batman.Model
+    namespace.Store = class @Store extends Batman.Model
       @encode 'id', 'name'
       @hasMany 'products', namespace: namespace
 

        name: "Store One"
        id: 1

    class @Product extends Batman.Model
      @encode 'id', 'name', 'store_id'
      @belongsTo 'store', namespace: namespace
      @hasMany 'productVariants', namespace: namespace

  @Store.find 1, (err, store) =>
    source = '<div><span data-foreach-product="store.products" data-bind="product.name"></span></div>'
    context = Batman(store: store)
    helpers.render source, context, (node, view) =>
      equal node.children().get(0)?.innerHTML, 'Product One'
      equal node.children().get(1)?.innerHTML, 'Product Two'
      equal node.children().get(2)?.innerHTML, 'Product Three'

      addedProduct = new @Product(name: 'Product Four', store_id: store.id)
      addedProduct.save (err, savedProduct) ->
