mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
changed get template details to findOne
This commit is contained in:
parent
cd60817592
commit
6982ec63ae
4 changed files with 9 additions and 8 deletions
|
@ -23,7 +23,8 @@ module.exports =
|
|||
callback(err, details)
|
||||
|
||||
getProjectDescription: (project_id, callback)->
|
||||
Project.find _id:project_id, "description", callback
|
||||
Project.findOne _id:project_id, "description", (err, project)->
|
||||
callback(err, project?.description)
|
||||
|
||||
setProjectDescription: (project_id, description, callback)->
|
||||
conditions = _id:project_id
|
||||
|
|
|
@ -102,7 +102,6 @@ block content
|
|||
}
|
||||
}
|
||||
};
|
||||
window.project_description = "#{project.description}"
|
||||
|
||||
script(type='text/javascript').
|
||||
ga('send', 'event', 'editor-interaction', 'editor-opened')
|
||||
|
|
|
@ -17,8 +17,7 @@ define [
|
|||
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, ide) ->
|
||||
permissionsManager = new PermissionsManager(ide, $scope)
|
||||
user_id = ide.$scope.user.id
|
||||
$scope.template =
|
||||
description: window.project_description
|
||||
$scope.template = {}
|
||||
$scope.publishedDetails =
|
||||
exists:false
|
||||
|
||||
|
@ -30,6 +29,8 @@ define [
|
|||
ide.socket.emit "getPublishedDetails", user_id, (err, data)->
|
||||
$scope.publishedDetails = data
|
||||
$scope.publishedDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
||||
console.log data
|
||||
$scope.template.description = data.description
|
||||
|
||||
refreshPublishedStatus()
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ describe 'Project details handler', ->
|
|||
getProject: sinon.stub().callsArgWith(2, null, @project)
|
||||
@ProjectModel =
|
||||
update: sinon.stub()
|
||||
find: sinon.stub()
|
||||
findOne: sinon.stub()
|
||||
@UserGetter =
|
||||
getUser: sinon.stub().callsArgWith(1, null, @user)
|
||||
@tpdsUpdateSender =
|
||||
|
@ -58,15 +58,15 @@ describe 'Project details handler', ->
|
|||
describe "getProjectDescription", ->
|
||||
|
||||
it "should make a call to mongo just for the description", (done)->
|
||||
@ProjectModel.find.callsArgWith(2)
|
||||
@ProjectModel.findOne.callsArgWith(2)
|
||||
@handler.getProjectDescription @project_id, (err, description)=>
|
||||
@ProjectModel.find.calledWith({_id:@project_id}, "description").should.equal true
|
||||
@ProjectModel.findOne.calledWith({_id:@project_id}, "description").should.equal true
|
||||
done()
|
||||
|
||||
it "should return what the mongo call returns", (done)->
|
||||
err = "error"
|
||||
description = "cool project"
|
||||
@ProjectModel.find.callsArgWith(2, err, description)
|
||||
@ProjectModel.findOne.callsArgWith(2, err, {description:description})
|
||||
@handler.getProjectDescription @project_id, (returnedErr, returnedDescription)=>
|
||||
err.should.equal returnedErr
|
||||
description.should.equal returnedDescription
|
||||
|
|
Loading…
Reference in a new issue