2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-10-21 02:38:41 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe Users::OmniauthCallbacksController do
|
|
|
|
|
context 'email is not there in auth hash' do
|
|
|
|
|
before do
|
|
|
|
|
stub_env_for_omniauth
|
|
|
|
|
get :google
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it { expect(flash[:error]).to eq('Email field is missing in your google account') }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def stub_env_for_omniauth
|
|
|
|
|
request.env['devise.mapping'] = Devise.mappings[:user]
|
|
|
|
|
env = OmniAuth::AuthHash.new(
|
|
|
|
|
provider: 'google',
|
|
|
|
|
uid: 'google-test-uid-1',
|
|
|
|
|
info: {
|
|
|
|
|
name: 'google user',
|
|
|
|
|
email: nil,
|
|
|
|
|
username: 'user_google'
|
|
|
|
|
},
|
|
|
|
|
credentials: {
|
|
|
|
|
token: 'google_mock_token',
|
|
|
|
|
secret: 'google_mock_secret'
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
request.env['omniauth.auth'] = env
|
2018-03-01 19:00:41 -08:00
|
|
|
allow(@controller).to receive(:env).and_return(env)
|
2017-10-21 02:38:41 +05:30
|
|
|
end
|