mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
Add a small connection stubbing API.
This commit is contained in:
@@ -10,18 +10,20 @@ class OAuthableTest < ActionController::IntegrationTest
|
||||
:access_token => "plataformatec"
|
||||
}
|
||||
|
||||
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
|
||||
stub.post('/oauth/access_token') { [200, {}, ACCESS_TOKEN.to_json] }
|
||||
stub.get('/me?access_token=plataformatec') { [200, {}, FACEBOOK_INFO.to_json] }
|
||||
setup do
|
||||
Devise::Oauth.short_circuit_authorizers!
|
||||
|
||||
Devise::Oauth.stub!(:facebook) do |b|
|
||||
b.post('/oauth/access_token') { [200, {}, ACCESS_TOKEN.to_json] }
|
||||
b.get('/me?access_token=plataformatec') { [200, {}, FACEBOOK_INFO.to_json] }
|
||||
end
|
||||
end
|
||||
|
||||
User.oauth_configs[:facebook].client.connection.build do |b|
|
||||
b.adapter :test, stubs
|
||||
teardown do
|
||||
Devise::Oauth.unshort_circuit_authorizers!
|
||||
Devise::Oauth.reset_stubs!
|
||||
end
|
||||
|
||||
setup { Devise::Oauth.short_circuit_authorizers! }
|
||||
teardown { Devise::Oauth.unshort_circuit_authorizers! }
|
||||
|
||||
test "omg" do
|
||||
assert_difference "User.count", 1 do
|
||||
get "/users/sign_up"
|
||||
|
||||
Reference in New Issue
Block a user