Skip to content

Commit 9f3a1c6

Browse files
committed
add test for path problem
1 parent 1756e88 commit 9f3a1c6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/controllers/upload.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ describe('controllers/upload.js', function () {
3737
}
3838
}
3939
};
40+
41+
mockLoginedRequestForbidden = {
42+
session: {
43+
user: {
44+
_id: 'mock_user_id'
45+
}
46+
},
47+
files: {
48+
userfile: {
49+
name: '/../../' + path.basename(tmpFile),
50+
path: tmpFile
51+
}
52+
}
53+
};
4054
});
4155

4256
var oldUploadDir = config.upload_dir;
@@ -83,6 +97,17 @@ describe('controllers/upload.js', function () {
8397
});
8498
});
8599

100+
it('should forbidden when path err', function (done) {
101+
upload.uploadImage(mockLoginedRequestForbidden, {
102+
send: function (data) {
103+
data.should.have.property('status', 'forbidden');
104+
done();
105+
}
106+
}, function () {
107+
throw new Error('should not call this method');
108+
});
109+
});
110+
86111
it('should upload file success', function (done) {
87112
upload.uploadImage(mockLoginedRequest, {
88113
send: function (data) {

0 commit comments

Comments
 (0)