discourse/spec/controllers/omniauth_callbacks_controller_spec.rb

27 lines
731 B
Ruby
Raw Normal View History

require 'rails_helper'
describe Users::OmniauthCallbacksController do
2013-08-23 15:00:18 +08:00
context ".find_authenticator" do
it "fails if a provider is disabled" do
2017-03-01 10:53:03 +08:00
SiteSetting.enable_twitter_logins = false
expect {
2013-08-23 15:00:18 +08:00
Users::OmniauthCallbacksController.find_authenticator("twitter")
2017-03-01 10:53:03 +08:00
}.to raise_error(Discourse::InvalidAccess)
2013-08-23 15:00:18 +08:00
end
2013-08-23 15:00:18 +08:00
it "fails for unknown" do
2017-03-01 10:53:03 +08:00
expect {
2013-08-23 15:00:18 +08:00
Users::OmniauthCallbacksController.find_authenticator("twitter1")
2017-03-01 10:53:03 +08:00
}.to raise_error(Discourse::InvalidAccess)
2013-08-23 15:00:18 +08:00
end
2013-08-23 15:00:18 +08:00
it "finds an authenticator when enabled" do
2017-03-01 10:53:03 +08:00
SiteSetting.enable_twitter_logins = true
2013-08-23 15:00:18 +08:00
expect(Users::OmniauthCallbacksController.find_authenticator("twitter")).not_to eq(nil)
end
2013-08-23 15:00:18 +08:00
end
end