     Backbone.sync.restore()
 
   describe '#index', ->
-
     it 'bootstraps the artwork', ->
       routes.index @req, @res
       _.last(Backbone.sync.args)[2].success fabricate 'artwork', id: 'andy-foobar'

{ fabricate } = require 'antigravity'
_ = require 'underscore'
sinon = require 'sinon'
Backbone = require 'backbone'
routes = require '../routes'
CurrentUser = require '../../../models/current_user.coffee'
Artwork = require '../../../models/artwork.coffee'

describe 'Artwork routes', ->

  beforeEach ->
    sinon.stub Backbone, 'sync'
    @req = { params: { id: 'foo' }, query: { sort: '-published_at' } }

      _.last(Backbone.sync.args)[2].success fabricate 'artwork', id: 'andy-foobar', artist: null
      @res.locals.sd.ARTWORK.id.should.equal 'andy-foobar'
      @res.render.args[0][0].should.equal 'index'

  describe '#save', ->
    it 'saves the artwork', ->
      @req.user = new CurrentUser fabricate 'user'
      routes.save @req, @res
      _.last(Backbone.sync.args)[0].should.equal 'create'
      _.last(Backbone.sync.args)[1].url.should.include "/api/v1/collection/saved-artwork/artwork/#{@req.params.id}?user_id=#{@req.user.id}"
