mirror of
https://github.com/danbee/micropub.git
synced 2025-03-04 08:59:13 +00:00
Test github posting
This commit is contained in:
parent
1f1afc99e8
commit
36e3e15542
@ -58,6 +58,10 @@ module Micropub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def photo
|
||||||
|
params["photo"]
|
||||||
|
end
|
||||||
|
|
||||||
def content_from_hash
|
def content_from_hash
|
||||||
if params["content"]["text"]
|
if params["content"]["text"]
|
||||||
params["content"]["text"]
|
params["content"]["text"]
|
||||||
|
|||||||
48
test/lib/micropub/github_test.rb
Normal file
48
test/lib/micropub/github_test.rb
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
require "micropub/github"
|
||||||
|
|
||||||
|
describe Micropub::Github do
|
||||||
|
describe "#post!" do
|
||||||
|
it "sends the post to github" do
|
||||||
|
contents = mock("contents")
|
||||||
|
contents.expects(:create).with(
|
||||||
|
"danbee",
|
||||||
|
"danbarber.me.hugo",
|
||||||
|
"content/blog/2020-01-01-hello-world/index.md",
|
||||||
|
{
|
||||||
|
path: "content/blog/2020-01-01-hello-world/index.md",
|
||||||
|
message: "Posting: Hello, World!",
|
||||||
|
:content => <<~CONTENT,
|
||||||
|
---
|
||||||
|
date: '2020-01-01T00:00:00+00:00'
|
||||||
|
layout: micropost
|
||||||
|
categories:
|
||||||
|
- my-blog
|
||||||
|
---
|
||||||
|
|
||||||
|
Hello, World!
|
||||||
|
CONTENT
|
||||||
|
:branch => "master",
|
||||||
|
}).returns(true)
|
||||||
|
repos = mock("repos")
|
||||||
|
repos.stubs(:contents).returns(contents)
|
||||||
|
github_api = mock("Github")
|
||||||
|
github_api.stubs(:repos).returns(repos)
|
||||||
|
::Github.stubs(:new).returns(github_api)
|
||||||
|
|
||||||
|
github = Micropub::Github.new
|
||||||
|
post = Micropub::Post.new(params)
|
||||||
|
|
||||||
|
github.post!(post)
|
||||||
|
end
|
||||||
|
|
||||||
|
def params
|
||||||
|
{
|
||||||
|
"content" => "Hello, World!",
|
||||||
|
"category" => "my-blog",
|
||||||
|
"published" => DateTime.parse("2020-01-01").rfc3339,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -184,6 +184,18 @@ describe Micropub::Post do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#photo" do
|
||||||
|
it "returns the url of the photo" do
|
||||||
|
post = Micropub::Post.new(
|
||||||
|
"content" => "Hallo, Earth!",
|
||||||
|
"photo" => "http://www.example.com/example.png",
|
||||||
|
"published" => "2019-11-12",
|
||||||
|
)
|
||||||
|
|
||||||
|
_(post.photo).must_equal "http://www.example.com/example.png"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#post_content" do
|
describe "#post_content" do
|
||||||
it "returns a post formatted for hugo" do
|
it "returns a post formatted for hugo" do
|
||||||
post = Micropub::Post.new(
|
post = Micropub::Post.new(
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
require "test_helper"
|
require "test_helper"
|
||||||
require 'minitest/hooks'
|
|
||||||
|
|
||||||
include Rack::Test::Methods
|
include Rack::Test::Methods
|
||||||
MiniTest::Spec.register_spec_type(/something/, Minitest::HooksSpec)
|
|
||||||
|
|
||||||
def app
|
def app
|
||||||
Micropub::Webserver
|
Micropub::Webserver
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user