|
@@ -12,7 +12,7 @@ describe 'ProjectDetailsHandler', ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@project_id = "321l3j1kjkjl"
|
|
@project_id = "321l3j1kjkjl"
|
|
|
@user_id = "user-id-123"
|
|
@user_id = "user-id-123"
|
|
|
- @project =
|
|
|
|
|
|
|
+ @project =
|
|
|
name: "project"
|
|
name: "project"
|
|
|
description: "this is a great project"
|
|
description: "this is a great project"
|
|
|
something:"should not exist"
|
|
something:"should not exist"
|
|
@@ -20,7 +20,7 @@ describe 'ProjectDetailsHandler', ->
|
|
|
owner_ref: @user_id
|
|
owner_ref: @user_id
|
|
|
@user =
|
|
@user =
|
|
|
features: "mock-features"
|
|
features: "mock-features"
|
|
|
- @ProjectGetter =
|
|
|
|
|
|
|
+ @ProjectGetter =
|
|
|
getProjectWithoutDocLines: sinon.stub().callsArgWith(1, null, @project)
|
|
getProjectWithoutDocLines: sinon.stub().callsArgWith(1, null, @project)
|
|
|
getProject: sinon.stub().callsArgWith(2, null, @project)
|
|
getProject: sinon.stub().callsArgWith(2, null, @project)
|
|
|
@ProjectModel =
|
|
@ProjectModel =
|
|
@@ -42,7 +42,7 @@ describe 'ProjectDetailsHandler', ->
|
|
|
describe "getDetails", ->
|
|
describe "getDetails", ->
|
|
|
|
|
|
|
|
it "should find the project and owner", (done)->
|
|
it "should find the project and owner", (done)->
|
|
|
- @handler.getDetails @project_id, (err, details)=>
|
|
|
|
|
|
|
+ @handler.getDetails @project_id, (err, details)=>
|
|
|
details.name.should.equal @project.name
|
|
details.name.should.equal @project.name
|
|
|
details.description.should.equal @project.description
|
|
details.description.should.equal @project.description
|
|
|
details.compiler.should.equal @project.compiler
|
|
details.compiler.should.equal @project.compiler
|
|
@@ -50,6 +50,13 @@ describe 'ProjectDetailsHandler', ->
|
|
|
assert.equal(details.something, undefined)
|
|
assert.equal(details.something, undefined)
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
|
|
+ it "should find overleaf metadata if it exists", (done)->
|
|
|
|
|
+ @project.overleaf = { id: 'id' }
|
|
|
|
|
+ @handler.getDetails @project_id, (err, details)=>
|
|
|
|
|
+ details.overleaf.should.equal @project.overleaf
|
|
|
|
|
+ assert.equal(details.something, undefined)
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
it "should return an error for a non-existent project", (done)->
|
|
it "should return an error for a non-existent project", (done)->
|
|
|
@ProjectGetter.getProject.callsArg(2, null, null)
|
|
@ProjectGetter.getProject.callsArg(2, null, null)
|
|
|
err = new Errors.NotFoundError("project not found")
|
|
err = new Errors.NotFoundError("project not found")
|
|
@@ -79,7 +86,7 @@ describe 'ProjectDetailsHandler', ->
|
|
|
@handler.getProjectDescription @project_id, (returnedErr, returnedDescription)=>
|
|
@handler.getProjectDescription @project_id, (returnedErr, returnedDescription)=>
|
|
|
err.should.equal returnedErr
|
|
err.should.equal returnedErr
|
|
|
description.should.equal returnedDescription
|
|
description.should.equal returnedDescription
|
|
|
- done()
|
|
|
|
|
|
|
+ done()
|
|
|
|
|
|
|
|
describe "setProjectDescription", ->
|
|
describe "setProjectDescription", ->
|
|
|
|
|
|
|
@@ -110,7 +117,7 @@ describe 'ProjectDetailsHandler', ->
|
|
|
@handler.renameProject @project_id, @newName, =>
|
|
@handler.renameProject @project_id, @newName, =>
|
|
|
@tpdsUpdateSender.moveEntity.calledWith({project_id:@project_id, project_name:@project.name, newProjectName:@newName}).should.equal true
|
|
@tpdsUpdateSender.moveEntity.calledWith({project_id:@project_id, project_name:@project.name, newProjectName:@newName}).should.equal true
|
|
|
done()
|
|
done()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it "should not do anything with an invalid name", (done) ->
|
|
it "should not do anything with an invalid name", (done) ->
|
|
|
@handler.validateProjectName = sinon.stub().yields(new Error("invalid name"))
|
|
@handler.validateProjectName = sinon.stub().yields(new Error("invalid name"))
|
|
|
@handler.renameProject @project_id, @newName, =>
|
|
@handler.renameProject @project_id, @newName, =>
|