 request = require 'supertest'
 assert  = require 'assert'
 
-app     = require './../../coffee/server'
 req     = request require './../../coffee/server'
 
 steder = turer = null
-
-before -> steder = module.parent.exports.steder
+before ->
+  steder = module.parent.exports.steder
+  turer = module.parent.exports.turer
 
 describe 'OPTIONS', ->
   url = '/steder/53507fb375049e5615000181?api_key=nrk'

        done()

  it 'should return 404 for private document for non owner', (done) ->
    request(app)
      .get('/steder/52d65b2544db971c94b2d949?api_key=nrk')
      .end (err, res) ->
        assert.equal res.statusCode, 404
        assert.deepEqual res.body, message: 'Not Found'


describe 'PUT', ->
  it 'should return 403 for non owner', (done) ->
    req.put('/steder/52407fb375049e5615000170?api_key=nrk')
      .end (err, res) ->
        assert.equal res.statusCode, 403
        assert.deepEqual res.body, message: 'Request Denied'
        done()

  it 'should return 200 for owner', (done) ->
    req.put('/steder/52407fb375049e5615000170?api_key=dnt')
      .send(navn: 'Foo')
      .end (err, res) ->
        assert.equal res.statusCode, 200
