Permalink
Browse files

Adding "include-theme" param to Tumblr Authenticator"

  • Loading branch information...
1 parent 4a59ce5 commit bd419dd79964cbc189c7076f9a6a424d09cb080d @mwunsch mwunsch committed Mar 26, 2010
Showing with 17 additions and 2 deletions.
  1. +3 −2 lib/tumblr.rb
  2. +1 −0 lib/tumblr/authenticator.rb
  3. +13 −0 test/test_tumblr.rb
View
@@ -36,9 +36,10 @@ def dashboard(parameters={})
reader.dashboard(parameters)
end
- def authenticate
+ def authenticate(theme = false)
raise 'Requires an e-mail address and password' unless @credentials
- Authenticator.new(@credentials[:email],@credentials[:password]).authenticate
+ params = theme ? {:'include-theme' => 1} : {}
+ Authenticator.new(@credentials[:email],@credentials[:password]).authenticate(params)
end
def reader
@@ -11,6 +11,7 @@ def initialize(*credentials)
post :authenticate do |auth|
auth.url = 'http://www.tumblr.com/api/authenticate'
auth.requires = [:email, :password]
+ auth.with = [:'include-theme']
end
end
View
@@ -110,6 +110,12 @@ class TestTumblr < Test::Unit::TestCase
assert_equal auth.uri, tumbl.authenticate.uri
end
+ test 'can pass include theme params to authenticate method' do
+ tumbl = Tumblr.new('test@testermcgee.com','dontrevealmysecrets')
+ include_theme = tumbl.authenticate(true)
+ assert include_theme.with.split('&').include?("include-theme=1")
+ end
+
test 'executes' do
cred = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
response = VCR.with_cassette('write/write') do
@@ -252,6 +258,8 @@ class TestTumblr < Test::Unit::TestCase
end
assert_equal 66, posts.count
end
+
+ # test 'pages'
end
describe 'Writer' do
@@ -306,6 +314,11 @@ class TestTumblr < Test::Unit::TestCase
assert response.success?
assert_equal 'mwunsch', response["tumblr"]["tumblelog"].first["name"]
end
+
+ test 'can include an optional theme' do
+ user = Tumblr::Authenticator.new('test@testermcgee.com','dontrevealmysecrets')
+ assert user.authenticate(:'include-theme' => 1).with.split('&').include?("include-theme=1")
+ end
end
describe 'Post' do

0 comments on commit bd419dd

Please sign in to comment.