diff --git a/app/models/twitter_auth/generic_user.rb b/app/models/twitter_auth/generic_user.rb
index abc0b0f..7e9bfbd 100644
--- a/app/models/twitter_auth/generic_user.rb
+++ b/app/models/twitter_auth/generic_user.rb
@@ -14,6 +14,8 @@ class GenericUser < ActiveRecord::Base
:profile_link_color,
:profile_sidebar_border_color,
:profile_text_color,
+ :profile_background_image_url,
+ :profile_background_tiled,
:friends_count,
:statuses_count,
:followers_count,
diff --git a/generators/twitter_auth/templates/migration.rb b/generators/twitter_auth/templates/migration.rb
index 9854c5d..c9f7811 100644
--- a/generators/twitter_auth/templates/migration.rb
+++ b/generators/twitter_auth/templates/migration.rb
@@ -27,6 +27,8 @@ def self.up
t.string :profile_link_color
t.string :profile_sidebar_border_color
t.string :profile_text_color
+ t.string :profile_background_image_url
+ t.boolean :profile_background_tiled
t.integer :friends_count
t.integer :statuses_count
t.integer :followers_count
diff --git a/lib/twitter_auth.rb b/lib/twitter_auth.rb
index 7f14936..c3e3358 100644
--- a/lib/twitter_auth.rb
+++ b/lib/twitter_auth.rb
@@ -78,4 +78,10 @@ def self.net
require 'twitter_auth/dispatcher/basic'
require 'twitter_auth/dispatcher/shared'
-class TwitterAuth::Dispatcher::Error < StandardError; end
+module TwitterAuth
+ module Dispatcher
+ class Error < StandardError; end
+ class Unauthorized < Error; end
+ end
+end
+
diff --git a/lib/twitter_auth/dispatcher/shared.rb b/lib/twitter_auth/dispatcher/shared.rb
index 9b61584..3ad835a 100644
--- a/lib/twitter_auth/dispatcher/shared.rb
+++ b/lib/twitter_auth/dispatcher/shared.rb
@@ -16,7 +16,7 @@ def handle_response(response)
response.body
end
when Net::HTTPUnauthorized
- raise TwitterAuth::Dispatcher::Error, 'The credentials provided did not authorize the user.'
+ raise TwitterAuth::Dispatcher::Unauthorized, 'The credentials provided did not authorize the user.'
else
message = begin
JSON.parse(response.body)['error']
diff --git a/spec/twitter_auth/dispatcher/basic_spec.rb b/spec/twitter_auth/dispatcher/basic_spec.rb
index 59b6b29..4e93af4 100644
--- a/spec/twitter_auth/dispatcher/basic_spec.rb
+++ b/spec/twitter_auth/dispatcher/basic_spec.rb
@@ -54,12 +54,17 @@
end
it 'should set the error message to the JSON message' do
- FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['401', 'Unauthorized'])
+ FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['403', 'Forbidden'])
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
end
+ it 'should raise a TwitterAuth::Dispatcher::Unauthorized on 401' do
+ FakeWeb.register_uri('https://twitter.com:443/unauthenticated_response.xml', :string => "\n/unauthenticated_response.xml\nbad response\n", :status => ['401', 'Unauthorized'])
+ lambda{@dispatcher.request(:get, '/unauthenticated_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Unauthorized)
+ end
+
it 'should set the error message to the XML message' do
- FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "\n/bad_response.xml\nbad response\n", :status => ['401', 'Unauthorized'])
+ FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "\n/bad_response.xml\nbad response\n", :status => ['403', 'Forbidden'])
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
end
end
diff --git a/spec/twitter_auth/dispatcher/oauth_spec.rb b/spec/twitter_auth/dispatcher/oauth_spec.rb
index 05a3013..555abaf 100644
--- a/spec/twitter_auth/dispatcher/oauth_spec.rb
+++ b/spec/twitter_auth/dispatcher/oauth_spec.rb
@@ -51,13 +51,18 @@
end
it 'should set the error message to the JSON message' do
- FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['401', 'Unauthorized'])
+ FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['403', 'Forbidden'])
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
end
it 'should set the error message to the XML message' do
- FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "\n/bad_response.xml\nbad response\n", :status => ['401', 'Unauthorized'])
- lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
+ FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "\n/bad_response.xml\nbad response\n", :status => ['403', 'Forbidden'])
+ lambda{@dispatcher.request(:get, '/bad_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
+ end
+
+ it 'should raise a TwitterAuth::Dispatcher::Unauthorized on 401' do
+ FakeWeb.register_uri('https://twitter.com:443/unauthenticated_response.xml', :string => "\n/unauthenticated_response.xml\nbad response\n", :status => ['401', 'Unauthorized'])
+ lambda{@dispatcher.request(:get, '/unauthenticated_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Unauthorized)
end
it 'should work with verb methods' do