-_ = require 'underscore'
 sinon = require 'sinon'
 rewire = require 'rewire'
 Backbone = require 'backbone'

describe 'Artist routes', ->
  beforeEach ->
    routes.__set__ 'metaphysics', @metaphysics = sinon.stub()
    @metaphysics.returns Q.resolve artist: artistJSON

    @req = params: { id: 'foo' }, get: (->), query: {}

      locals: sd: APP_URL: 'http://localhost:5000', CURRENT_PATH: '/artist_2/jeff-koons-1'

  describe '#index', ->
    it 'renders the artist template', ->
      routes.index @req, @res
        .then =>
          @res.render.args[0][0].should.equal 'index'
          @res.render.args[0][1].artist.id.should.equal 'jeff-koons-1'
          @res.render.args[0][1].artist.name.should.equal 'Jeff Koons'

    it 'bootstraps the artist', ->
      routes.index @req, @res
        .then =>
          @res.locals.sd.ARTIST.should.equal artistJSON

    it 'redirects to canonical url', ->
      @res.locals.sd.CURRENT_PATH = '/artist_2/bar'
      routes.index @req, @res
        .then =>
          @res.redirect.args[0][0].should.equal '/artist_2/jeff-koons-1'

  describe '#follow', ->
    beforeEach ->
