mirror of
https://git.sr.ht/~edwardloveall/scribe
synced 2025-12-10 12:41:23 +00:00
Add post creation date/time
This commit is contained in:
@@ -80,6 +80,31 @@ describe PageConverter do
|
||||
page.author.should eq "Author"
|
||||
end
|
||||
|
||||
it "sets the publish date/time" do
|
||||
data_json = <<-JSON
|
||||
{
|
||||
"post": {
|
||||
"title": "This is a story",
|
||||
"createdAt": 1000,
|
||||
"creator": {
|
||||
"id": "abc123",
|
||||
"name": "Author"
|
||||
},
|
||||
"content": {
|
||||
"bodyModel": {
|
||||
"paragraphs": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
data = PostResponse::Data.from_json(data_json)
|
||||
|
||||
page = PageConverter.new.convert(data)
|
||||
|
||||
page.created_at.should eq Time.utc(1970, 1, 1, 0, 0, 1)
|
||||
end
|
||||
|
||||
it "calls ParagraphConverter to convert the remaining paragraph content" do
|
||||
paragraph_json = <<-JSON
|
||||
[
|
||||
|
||||
@@ -8,6 +8,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Paragraph.new(children: [
|
||||
Text.new(content: "hi"),
|
||||
@@ -25,6 +26,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Paragraph.new(children: [
|
||||
Text.new(content: "Hello, "),
|
||||
@@ -53,6 +55,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Anchor.new(children: [Text.new("link")] of Child, href: "https://example.com"),
|
||||
] of Child
|
||||
@@ -68,6 +71,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
BlockQuote.new(children: [
|
||||
Text.new("Wayne Gretzky. Michael Scott."),
|
||||
@@ -85,6 +89,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Code.new(children: [
|
||||
Text.new("foo = bar"),
|
||||
@@ -102,6 +107,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Paragraph.new(children: [
|
||||
Text.new(content: "This is "),
|
||||
@@ -123,6 +129,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Figure.new(children: [
|
||||
Image.new(src: "image.png", originalWidth: 100, originalHeight: 200),
|
||||
@@ -150,6 +157,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Heading2.new(children: [
|
||||
Text.new(content: "Title!"),
|
||||
@@ -167,6 +175,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Heading3.new(children: [
|
||||
Text.new(content: "In Conclusion..."),
|
||||
@@ -184,6 +193,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Paragraph.new(children: [
|
||||
Image.new(src: "image.png", originalWidth: 100, originalHeight: 200),
|
||||
@@ -205,6 +215,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Paragraph.new(children: [
|
||||
IFrame.new(href: "https://example.com"),
|
||||
@@ -228,6 +239,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
OrderedList.new(children: [
|
||||
ListItem.new(children: [Text.new("One")] of Child),
|
||||
@@ -246,6 +258,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Paragraph.new(children: [
|
||||
Text.new("Hello, world!"),
|
||||
@@ -263,6 +276,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Preformatted.new(children: [
|
||||
Text.new("New\nline"),
|
||||
@@ -280,6 +294,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
Strong.new(children: [
|
||||
Text.new("Oh yeah!"),
|
||||
@@ -297,6 +312,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
UnorderedList.new(children: [
|
||||
ListItem.new(children: [Text.new("Apple")] of Child),
|
||||
@@ -315,6 +331,7 @@ describe PageContent do
|
||||
title: "Title",
|
||||
subtitle: nil,
|
||||
author: "Author",
|
||||
created_at: Time.local,
|
||||
nodes: [
|
||||
UserAnchor.new(children: [Text.new("Some User")] of Child, userId: "abc123"),
|
||||
] of Child
|
||||
|
||||
Reference in New Issue
Block a user