2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2013-03-05 02:44:41 +08:00
|
|
|
|
|
|
|
describe Users::OmniauthCallbacksController do
|
|
|
|
|
2013-08-23 15:00:18 +08:00
|
|
|
context ".find_authenticator" do
|
|
|
|
it "fails if a provider is disabled" do
|
|
|
|
SiteSetting.stubs("enable_twitter_logins?").returns(false)
|
|
|
|
expect(lambda {
|
|
|
|
Users::OmniauthCallbacksController.find_authenticator("twitter")
|
2016-05-30 11:38:04 +08:00
|
|
|
}).to raise_error(Discourse::InvalidAccess)
|
2013-08-23 15:00:18 +08:00
|
|
|
end
|
2013-07-04 14:30:13 +08:00
|
|
|
|
2013-08-23 15:00:18 +08:00
|
|
|
it "fails for unknown" do
|
|
|
|
expect(lambda {
|
|
|
|
Users::OmniauthCallbacksController.find_authenticator("twitter1")
|
2016-05-30 11:38:04 +08:00
|
|
|
}).to raise_error(Discourse::InvalidAccess)
|
2013-08-23 15:00:18 +08:00
|
|
|
end
|
2013-07-04 14:30:13 +08:00
|
|
|
|
2013-08-23 15:00:18 +08:00
|
|
|
it "finds an authenticator when enabled" do
|
|
|
|
SiteSetting.stubs("enable_twitter_logins?").returns(true)
|
|
|
|
expect(Users::OmniauthCallbacksController.find_authenticator("twitter")).not_to eq(nil)
|
2013-07-04 14:30:13 +08:00
|
|
|
end
|
2013-08-23 15:00:18 +08:00
|
|
|
end
|
2013-07-04 14:30:13 +08:00
|
|
|
|
2013-03-05 02:44:41 +08:00
|
|
|
end
|