Welcome to mirror list, hosted at ThFree Co, Russian Federation.

import_spec_helper.rb « helpers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 26b78acbc4465af595c04a129e8d6d33c7258964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'ostruct'

# Helper methods for controller specs in the Import namespace
#
# Must be included manually.
module ImportSpecHelper
  # Stub `controller` to return a null object double with the provided messages
  # when `client` is called
  #
  # Examples:
  #
  #   stub_client(foo: %w(foo))
  #
  #   controller.client.foo         # => ["foo"]
  #   controller.client.bar.baz.foo # => ["foo"]
  #
  # Returns the client double
  def stub_client(messages = {})
    client = double('client', messages).as_null_object
    allow(controller).to receive(:client).and_return(client)

    client
  end

  def stub_omniauth_provider(name)
    provider = ActiveSupport::InheritableOptions.new(
      name: name,
      app_id: 'asd123',
      app_secret: 'asd123'
    )
    stub_omniauth_setting(providers: [provider])
  end
end