Migrate controller type specs to request types for omniauth.
This commit is contained in:
parent
81ca3677f7
commit
0fabf80dca
|
@ -1,26 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe Users::OmniauthCallbacksController do
|
|
||||||
|
|
||||||
context ".find_authenticator" do
|
|
||||||
it "fails if a provider is disabled" do
|
|
||||||
SiteSetting.enable_twitter_logins = false
|
|
||||||
|
|
||||||
expect {
|
|
||||||
Users::OmniauthCallbacksController.find_authenticator("twitter")
|
|
||||||
}.to raise_error(Discourse::InvalidAccess)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "fails for unknown" do
|
|
||||||
expect {
|
|
||||||
Users::OmniauthCallbacksController.find_authenticator("twitter1")
|
|
||||||
}.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
|
|
||||||
|
|
||||||
end
|
|
|
@ -12,6 +12,29 @@ RSpec.describe Users::OmniauthCallbacksController do
|
||||||
OmniAuth.config.test_mode = false
|
OmniAuth.config.test_mode = false
|
||||||
end
|
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
|
context 'Google Oauth2' do
|
||||||
before do
|
before do
|
||||||
SiteSetting.enable_google_oauth2_logins = true
|
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]
|
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2]
|
||||||
|
|
||||||
get "/auth/google_oauth2/callback.json"
|
get "/auth/google_oauth2/callback.json"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
JSON.parse(response.body)
|
JSON.parse(response.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue