2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
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-04-04 11:22:00 +05:30
|
|
|
provider = ActiveSupport::InheritableOptions.new(
|
2015-09-11 14:41:01 +05:30
|
|
|
name: name,
|
|
|
|
app_id: 'asd123',
|
|
|
|
app_secret: 'asd123'
|
|
|
|
)
|
2017-09-10 17:25:29 +05:30
|
|
|
stub_omniauth_setting(providers: [provider])
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|