basic specs
This commit is contained in:
parent
5cbbdf2949
commit
72c6efe41c
2 changed files with 38 additions and 2 deletions
|
|
@ -16,8 +16,12 @@ class Services::Tumblr < Service
|
||||||
def post(post, url='')
|
def post(post, url='')
|
||||||
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, :site => 'http://tumblr.com')
|
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, :site => 'http://tumblr.com')
|
||||||
access = OAuth::AccessToken.new(consumer, self.access_token, self.access_secret)
|
access = OAuth::AccessToken.new(consumer, self.access_token, self.access_secret)
|
||||||
resp = access.post('http://tumblr.com/api/write', {:type => 'regular', :title => self.public_message(post, url), :generator => 'diaspora'})
|
begin
|
||||||
resp
|
resp = access.post('http://tumblr.com/api/write', {:type => 'regular', :title => self.public_message(post, url), :generator => 'diaspora'})
|
||||||
|
resp
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_message(post, url)
|
def public_message(post, url)
|
||||||
|
|
|
||||||
32
spec/models/services/tumblr_spec.rb
Normal file
32
spec/models/services/tumblr_spec.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Services::Tumblr do
|
||||||
|
|
||||||
|
before do
|
||||||
|
@user = alice
|
||||||
|
@post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id)
|
||||||
|
@service = Services::Tumblr.new(:access_token => "yeah", :access_secret => "foobar")
|
||||||
|
@user.services << @service
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#post' do
|
||||||
|
it 'posts a status message to tumblr' do
|
||||||
|
OAuth::AccessToken.any_instance.should_receive(:post)
|
||||||
|
@service.post(@post)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'swallows exception raised by tumblr not being webscale' do
|
||||||
|
pending "meh"
|
||||||
|
OAuth::AccessToken.any_instance.should_receive(:post).and_raise
|
||||||
|
@service.post(@post)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should call public message' do
|
||||||
|
OAuth::AccessToken.any_instance.stub(:post)
|
||||||
|
url = "foo"
|
||||||
|
@service.should_receive(:public_message).with(@post, url)
|
||||||
|
@service.post(@post, url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Loading…
Reference in a new issue