Sha256: 41fd7156a60974eff29b284cefb39abf62a3cf2633a34e83a99fe60368daaf9c

Contents?: true

Size: 840 Bytes

Versions: 3

Compression:

Stored size: 840 Bytes

Contents

module SpecSupport
  module Login
    def mock_logged_in_user
      controller.session[:current_user_id] =
        create(:person, email: 'test.user@digital.moj.gov.uk').id
    end

    def current_user
      Peoplefinder::Person.where(email: 'test.user@digital.moj.gov.uk').first
    end

    def omni_auth_log_in_as(email)
      OmniAuth.config.test_mode = true

      OmniAuth.config.mock_auth[:gplus] = OmniAuth::AuthHash.new(
        provider: 'gplus',
        info: {
          email: email,
          first_name: 'John',
          last_name: 'Doe',
          name: 'John Doe'
        }
      )

      visit 'auth/gplus'
    end

    def token_log_in_as(email)
      token = create(:token, user_email: email)
      visit token_path(token)
    end

    def javascript_log_in
      visit '/'
      click_link 'Log in'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
peoplefinder-0.1.1 spec/support/login.rb
peoplefinder-0.1.0 spec/support/login.rb
peoplefinder-0.0.2 spec/support/login.rb