2019-07-25 01:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-05-21 17:40:13 -04:00
|
|
|
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)
|
2022-02-17 07:12:30 -05:00
|
|
|
provider = ActiveSupport::InheritableOptions.new(
|
2015-05-21 17:40:13 -04:00
|
|
|
name: name,
|
|
|
|
app_id: 'asd123',
|
|
|
|
app_secret: 'asd123'
|
|
|
|
)
|
2017-03-23 09:49:59 -04:00
|
|
|
stub_omniauth_setting(providers: [provider])
|
2015-05-21 17:40:13 -04:00
|
|
|
end
|
|
|
|
end
|