|
|
@@ -33,6 +33,11 @@ describe 'ExportsController', ->
|
|
|
_id:user_id
|
|
|
i18n:
|
|
|
translate:->
|
|
|
+ @res =
|
|
|
+ json: sinon.stub()
|
|
|
+ status: sinon.stub()
|
|
|
+ @res.status.returns(@res)
|
|
|
+ @next = sinon.stub()
|
|
|
@AuthenticationController =
|
|
|
getLoggedInUserId: sinon.stub().returns(@req.session.user._id)
|
|
|
@controller = SandboxedModule.require modulePath, requires:
|
|
|
@@ -51,7 +56,7 @@ describe 'ExportsController', ->
|
|
|
brand_variation_id: brand_variation_id
|
|
|
first_name: firstName
|
|
|
last_name: lastName
|
|
|
- @controller.exportProject @req, send:(body) =>
|
|
|
+ @controller.exportProject @req, json:(body) =>
|
|
|
expect(@handler.exportProject.args[0][0]).to.deep.equal expected
|
|
|
expect(body).to.deep.equal {export_v1_id: 897}
|
|
|
done()
|
|
|
@@ -77,7 +82,7 @@ describe 'ExportsController', ->
|
|
|
author: author
|
|
|
license: license
|
|
|
show_source: show_source
|
|
|
- @controller.exportProject @req, send:(body) =>
|
|
|
+ @controller.exportProject @req, json:(body) =>
|
|
|
expect(@handler.exportProject.args[0][0]).to.deep.equal expected
|
|
|
expect(body).to.deep.equal {export_v1_id: 897}
|
|
|
done()
|
|
|
@@ -86,9 +91,10 @@ describe 'ExportsController', ->
|
|
|
it 'should forward the response onward', (done) ->
|
|
|
@error_json = { status: 422, message: 'nope' }
|
|
|
@handler.exportProject = sinon.stub().yields({forwardResponse: @error_json})
|
|
|
- @controller.exportProject @req, send:(body) =>
|
|
|
- expect(body).to.deep.equal @error_json
|
|
|
- done()
|
|
|
+ @controller.exportProject @req, @res, @next
|
|
|
+ expect(@res.json.args[0][0]).to.deep.equal @error_json
|
|
|
+ expect(@res.status.args[0][0]).to.equal @error_json.status
|
|
|
+ done()
|
|
|
|
|
|
it 'should ask the handler to return the status of an export', (done) ->
|
|
|
@handler.fetchExport = sinon.stub().yields(
|
|
|
@@ -106,7 +112,7 @@ describe 'ExportsController', ->
|
|
|
}")
|
|
|
|
|
|
@req.params = {project_id: project_id, export_id: 897}
|
|
|
- @controller.exportStatus @req, send:(body) =>
|
|
|
+ @controller.exportStatus @req, json:(body) =>
|
|
|
expect(body).to.deep.equal {export_json: {
|
|
|
status_summary: 'completed',
|
|
|
status_detail: "all done",
|