Skip to content

Commit

Permalink
Merge pull request #68 from nono/master
Browse files Browse the repository at this point in the history
Fix creation date
  • Loading branch information
nono authored Feb 14, 2017
2 parents 1b8eeea + e7beeda commit f28d0bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function doUpload (cozy, data, method, path, options) {
method: method,
headers: {
'Content-Type': contentType,
'Date': lastModifiedDate ? lastModifiedDate.toISOString() : ''
'Date': lastModifiedDate ? lastModifiedDate.toGMTString() : ''
},
body: data
})
Expand Down
6 changes: 5 additions & 1 deletion test/integration/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ describe('files API', async function () {

it('creates a file', async function () {
const filename = 'foo_' + random()
const date = new Date('Wed, 01 Feb 2017 10:24:42 GMT')

const created = await cozy.files.create('datastring1', {
name: filename,
contentType: 'application/json'
contentType: 'application/json',
lastModifiedDate: date
})

created.should.have.property('attributes')
created.attributes.md5sum.should.equal('7Zfd8PaeeXsm5WJesf/KJw==')
new Date(created.attributes.created_at).should.eql(date)
new Date(created.attributes.updated_at).should.eql(date)
})

it('creates a file from a stream', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Files', function () {
before(mock.mockAPI('UploadFile'))

it('should work for supported data types', async function () {
const date = new Date('2017-02-01T10:24:42.116Z')
const date = new Date('Wed, 01 Feb 2017 10:24:42 GMT')
const stream = new Readable()

stream.push('somestreamdata')
Expand All @@ -35,7 +35,7 @@ describe('Files', function () {
const calls = mock.calls('UploadFile')
calls.should.have.length(4)
calls[0][1].headers['Content-Type'].should.equal('text/html')
calls[1][1].headers['Date'].should.equal(date.toISOString())
calls[1][1].headers['Date'].should.equal(date.toGMTString())
mock.lastUrl('UploadFile').should.equal('http://my.cozy.io/files/12345?Name=foo&Type=file')

res1.should.have.property('attributes')
Expand Down

0 comments on commit f28d0bd

Please sign in to comment.