Sha256: 78a2ba17bccecaf8f17b8a6d5ae3813808f21c8d5f0557ab2c587644a70657c5

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module UserOmniauthMethods
  def stub_g5_omniauth(user, options = {})
    OmniAuth.config.mock_auth[:g5] = OmniAuth::AuthHash.new({
      uid: user.uid,
      provider: 'g5',
      info: { email: user.email },
      credentials: { token: user.g5_access_token },
      extra: {
        raw_info: {
          accessible_applications: [{ url: 'global' }],
          restricted_application_redirect_url: 'https://imc.com'
        }
      }
    }.merge(options))
  end

  def stub_g5_invalid_credentials
    OmniAuth.config.mock_auth[:g5] = :invalid_credentials
  end

  def visit_path_and_login_with(path, user)
    stub_g5_omniauth(user)
    visit path
  end
end

RSpec.configure do |config|
  config.before(:all) { OmniAuth.config.logger = Logger.new('/dev/null') }

  config.before(:each) do
    OmniAuth.config.test_mode = true
    OmniAuth.config.mock_auth[:g5] = nil
  end
  config.after(:each) { OmniAuth.config.test_mode = false }

  config.include UserOmniauthMethods, type: :feature
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise_g5_authenticatable-1.0.3 spec/support/user_omniauth_methods.rb
devise_g5_authenticatable-1.0.2.rc.3 spec/support/user_omniauth_methods.rb
devise_g5_authenticatable-1.0.2.rc.2 spec/support/user_omniauth_methods.rb
devise_g5_authenticatable-1.0.2.rc.1 spec/support/user_omniauth_methods.rb