mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 17:51:16 +08:00
Migrate controller type specs to request types for omniauth.
This commit is contained in:
@ -12,6 +12,29 @@ RSpec.describe Users::OmniauthCallbacksController do
|
||||
OmniAuth.config.test_mode = false
|
||||
end
|
||||
|
||||
describe ".find_authenticator" do
|
||||
it "fails if a provider is disabled" do
|
||||
SiteSetting.enable_twitter_logins = false
|
||||
|
||||
expect do
|
||||
Users::OmniauthCallbacksController.find_authenticator("twitter")
|
||||
end.to raise_error(Discourse::InvalidAccess)
|
||||
end
|
||||
|
||||
it "fails for unknown" do
|
||||
expect do
|
||||
Users::OmniauthCallbacksController.find_authenticator("twitter1")
|
||||
end.to raise_error(Discourse::InvalidAccess)
|
||||
end
|
||||
|
||||
it "finds an authenticator when enabled" do
|
||||
SiteSetting.enable_twitter_logins = true
|
||||
|
||||
expect(Users::OmniauthCallbacksController.find_authenticator("twitter"))
|
||||
.not_to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Google Oauth2' do
|
||||
before do
|
||||
SiteSetting.enable_google_oauth2_logins = true
|
||||
@ -176,6 +199,7 @@ RSpec.describe Users::OmniauthCallbacksController do
|
||||
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2]
|
||||
|
||||
get "/auth/google_oauth2/callback.json"
|
||||
expect(response.status).to eq(200)
|
||||
JSON.parse(response.body)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user