fix minor issues in acceptance test

This commit is contained in:
Henrique Dias 2015-09-16 19:33:23 -03:00
parent a4575f178d
commit 01cbfd5338
5 changed files with 14 additions and 12 deletions

View file

@ -27,13 +27,14 @@ describe "Archiving updates", ->
MockWebApi.projects[@project_id] = MockWebApi.projects[@project_id] =
features: features:
versioning: true versioning: true
sinon.spy MockWebApi, "getProjectDetails"
MockWebApi.users[@user_id] = @user = MockWebApi.users[@user_id] = @user =
email: "user@sharelatex.com" email: "user@sharelatex.com"
first_name: "Leo" first_name: "Leo"
last_name: "Lion" last_name: "Lion"
id: @user_id id: @user_id
sinon.spy MockWebApi, "getUser" sinon.spy MockWebApi, "getUserInfo"
MockDocStoreApi.docs[@doc_id] = @doc = MockDocStoreApi.docs[@doc_id] = @doc =
_id: @doc_id _id: @doc_id
@ -60,7 +61,7 @@ describe "Archiving updates", ->
done() done()
after (done) -> after (done) ->
MockWebApi.getUser.restore() MockWebApi.getUserInfo.restore()
db.docHistory.remove {project_id: ObjectId(@project_id)} db.docHistory.remove {project_id: ObjectId(@project_id)}
TrackChangesClient.removeS3Doc @project_id, @doc_id, done TrackChangesClient.removeS3Doc @project_id, @doc_id, done

View file

@ -28,7 +28,7 @@ describe "Getting a diff", ->
first_name: "Leo" first_name: "Leo"
last_name: "Lion" last_name: "Lion"
id: @user_id id: @user_id
sinon.spy MockWebApi, "getUser" sinon.spy MockWebApi, "getUserInfo"
twoMinutes = 2 * 60 * 1000 twoMinutes = 2 * 60 * 1000
@ -68,7 +68,7 @@ describe "Getting a diff", ->
after () -> after () ->
MockDocUpdaterApi.getDoc.restore() MockDocUpdaterApi.getDoc.restore()
MockWebApi.getUser.restore() MockWebApi.getUserInfo.restore()
it "should return the diff", -> it "should return the diff", ->
expect(@diff).to.deep.equal @expected_diff expect(@diff).to.deep.equal @expected_diff

View file

@ -31,7 +31,7 @@ describe "Getting updates", ->
first_name: "Leo" first_name: "Leo"
last_name: "Lion" last_name: "Lion"
id: @user_id id: @user_id
sinon.spy MockWebApi, "getUser" sinon.spy MockWebApi, "getUserInfo"
@updates = [] @updates = []
for i in [0..9] for i in [0..9]
@ -52,7 +52,7 @@ describe "Getting updates", ->
done() done()
after: () -> after: () ->
MockWebApi.getUser.restore() MockWebApi.getUserInfo.restore()
describe "getting updates up to the limit", -> describe "getting updates up to the limit", ->
before (done) -> before (done) ->
@ -62,7 +62,7 @@ describe "Getting updates", ->
done() done()
it "should fetch the user details from the web api", -> it "should fetch the user details from the web api", ->
MockWebApi.getUser MockWebApi.getUserInfo
.calledWith(@user_id) .calledWith(@user_id)
.should.equal true .should.equal true

View file

@ -49,6 +49,7 @@ describe "Restoring a version", ->
first_name: "Leo" first_name: "Leo"
last_name: "Lion" last_name: "Lion"
id: @user_id id: @user_id
MockDocUpdaterApi.docs[@doc_id] = MockDocUpdaterApi.docs[@doc_id] =
lines: @lines lines: @lines
version: 7 version: 7

View file

@ -6,15 +6,15 @@ module.exports = MockWebApi =
projects: {} projects: {}
getUser: (user_id, callback = (error) ->) -> getUserInfo: (user_id, callback = (error) ->) ->
callback null, @users[user_id] or null callback null, @users[user_id] or null
getProject: (project_id, callback = (error, project) ->) -> getProjectDetails: (project_id, callback = (error, project) ->) ->
callback null, @projects[project_id] callback null, @projects[project_id]
run: () -> run: () ->
app.get "/user/:user_id/personal_info", (req, res, next) => app.get "/user/:user_id/personal_info", (req, res, next) =>
@getUser req.params.user_id, (error, user) -> @getUserInfo req.params.user_id, (error, user) ->
if error? if error?
res.send 500 res.send 500
if !user? if !user?
@ -23,7 +23,7 @@ module.exports = MockWebApi =
res.send JSON.stringify user res.send JSON.stringify user
app.get "/project/:project_id/details", (req, res, next) => app.get "/project/:project_id/details", (req, res, next) =>
@getProject req.params.project_id, (error, project) -> @getProjectDetails req.params.project_id, (error, project) ->
if error? if error?
res.send 500 res.send 500
if !project? if !project?