 Model = Lanes.Test.defineModel(
     props: {id: 'integer', code: 'string', name: 'string', notes: 'string'}
 )
+
 LAST_ROW_SELECTOR = '.fixedDataTableRowLayout_rowWrapper:last-child .public_fixedDataTableCell_cellContent'
+ADD_ROW_SELECTOR = 'button.add-row'
+
+RenderGrid = (q) ->
+    LT.renderComponent(LC.Grid, props: {
+        query: q, editor: true, allowCreate: true
+    })
 
 RenderEdit = (q, value) ->
-    grid = LT.renderComponent(LC.Grid, props: {
-        query: q, editor: true
-    })
+    grid = RenderGrid(q)
     _.dom(grid).qs(LAST_ROW_SELECTOR).click()
     editor = Lanes.Test.Utils.findRenderedComponentWithType(
         grid, Lanes.Components.Grid.RowEditor

        expect(editor.props.model).toEqual(jasmine.any(Model))
        expect(editor.props.model.id).toEqual(2)

    it 'can edit both rows and collections', ->
        {editor} = RenderEdit(@query, 'BOB')
        _.dom(editor).qs('.btn.save').click()
        expect( @query.results.rowAt(1)[1] ).toEqual('BOB')

        @query.src = @collection
        {editor} = RenderEdit(@query, 'BOB')
        _.dom(editor).qs('.btn.save').click()
        expect(@collection.at(1).code).toEqual('BOB')

    it 'does not update when edit is canceled', ->
        {editor} = RenderEdit(@query, 'CANCKED')
        _.dom(editor).qs('.btn.cancel').click()
        expect( @query.results.rowAt(1)[1] ).toEqual('TEST2')
        @query.src = @collection
        {editor} = RenderEdit(@query, 'CANCELED')
        _.dom(editor).qs('.btn.cancel').click()

        expect( @collection.at(1).code ).toEqual('TEST2')

    _.dom(editor).qs('.field:nth-of-type(2) input').setValue(value)
    {grid, editor}

CommonSpecs = ->

    it 'sets the props', ->
        grid = LT.renderComponent(LC.Grid, props: {
