Merge branch 'stable' into develop
This commit is contained in:
commit
6528f1479c
1 changed files with 12 additions and 5 deletions
|
|
@ -4,9 +4,9 @@ describe Services::Tumblr, type: :model do
|
|||
let(:user) { alice }
|
||||
let(:post) { user.post(:status_message, text: "hello", to: user.aspects.first.id) }
|
||||
let(:service) { Services::Tumblr.new(access_token: "yeah", access_secret: "foobar") }
|
||||
let(:post_id) { "bla" }
|
||||
|
||||
describe "#post" do
|
||||
let(:post_id) { "bla" }
|
||||
let(:post_request) { {body: service.build_tumblr_post(post, "")} }
|
||||
let(:post_response) { {status: 201, body: {response: {id: post_id}}.to_json} }
|
||||
|
||||
|
|
@ -24,12 +24,14 @@ describe Services::Tumblr, type: :model do
|
|||
}
|
||||
|
||||
it "posts a status message to the primary blog and stores the id" do
|
||||
stub_request(:post, "http://api.tumblr.com/v2/blog/bar.tumblr.com/post")
|
||||
stub = stub_request(:post, "http://api.tumblr.com/v2/blog/bar.tumblr.com/post")
|
||||
.with(post_request).to_return(post_response)
|
||||
|
||||
expect(post).to receive(:tumblr_ids=).with({"bar.tumblr.com" => post_id}.to_json)
|
||||
|
||||
service.post(post)
|
||||
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -37,20 +39,25 @@ describe Services::Tumblr, type: :model do
|
|||
let(:user_info) { {response: {user: {blogs: [{url: "http://foo.tumblr.com"}]}}}.to_json }
|
||||
|
||||
it "posts a status message to the returned blog" do
|
||||
stub_request(:post, "http://api.tumblr.com/v2/blog/foo.tumblr.com/post")
|
||||
stub = stub_request(:post, "http://api.tumblr.com/v2/blog/foo.tumblr.com/post")
|
||||
.with(post_request).to_return(post_response)
|
||||
|
||||
service.post(post)
|
||||
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#delete_post" do
|
||||
it "removes posts from tumblr" do
|
||||
stub_request(:post, "http://api.tumblr.com/v2/blog/foodbar.tumblr.com/post/delete")
|
||||
.to_return(status: 200)
|
||||
post.tumblr_ids = {"foodbar.tumblr.com" => post_id}.to_json
|
||||
stub = stub_request(:post, "http://api.tumblr.com/v2/blog/foodbar.tumblr.com/post/delete")
|
||||
.with(body: {"id" => post_id}).to_return(status: 200)
|
||||
|
||||
service.delete_post(post)
|
||||
|
||||
expect(stub).to have_been_requested
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue