-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed silent failure when no post_date_gmt was present in "post" item #8
Changes from all commits
a35c172
8ae6bb8
ecf12b4
e25d81e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,13 @@ var g; | |
var p; | ||
|
||
before(function(done) { | ||
when.then(function(data) { g = data.data; p = g.posts[0]; done(); }, | ||
when.then(function(data) { | ||
g = data.data; | ||
p = g.posts[0]; | ||
post_missing_both_post_fields = g.posts[1]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well there is still a pubDate field? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True.. I wonder if we should add fallback to that too. But that's for another PR. |
||
post_missing_post_date_gmt = g.posts[2]; | ||
done(); | ||
}, | ||
function(err) { done(new Error(err)); }); | ||
}); | ||
|
||
|
@@ -16,13 +22,24 @@ describe('Wordpress XML', function() { | |
}); | ||
}); | ||
|
||
describe('Post', function(){ | ||
describe('itself', function(){ | ||
describe('Posts', function(){ | ||
describe('simple post with text', function(){ | ||
it("should exist", function() { | ||
p = g.posts[0]; | ||
if (!p) throw new Exception(); | ||
}); | ||
}); | ||
describe('post without both date fields', function(){ | ||
it("should exist", function() { | ||
if (!post_missing_both_post_fields) | ||
throw new Exception(); | ||
}); | ||
}); | ||
describe('post without post_date_gmt', function(){ | ||
it("should exist", function() { | ||
if (!post_missing_post_date_gmt) | ||
throw new Exception(); | ||
}); | ||
}); | ||
|
||
describe('title', function(){ | ||
it("should be preserved", function() { | ||
|
@@ -71,6 +88,23 @@ describe('Post', function(){ | |
}); | ||
}); | ||
|
||
describe('Post date fallbacks', function(){ | ||
describe('no post_date_gmt or post_date', function(){ | ||
it("should return a default year 1970-01-01 00:00:00 AC", function() { | ||
var date = new Date("1970-01-01 00:00:00 UTC"); | ||
var unixtime = date.getTime() | ||
post_missing_both_post_fields.created_at.should.equal(unixtime); | ||
}); | ||
}); | ||
describe('no post_date_gmt', function(){ | ||
it("should fallback to post_date", function() { | ||
var date = new Date("2011-04-18 08:41:09 UTC"); | ||
var unixtime = date.getTime() | ||
post_missing_post_date_gmt.created_at.should.equal(unixtime); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('author', function(){ | ||
it("should be reset to admin", function() { | ||
p.created_by.should.equal(1); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
if
/else
should not be necessary any more.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, did not notice it was the same match thing. Will fix.