diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-09 12:55:14 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-09 12:55:14 +0300 |
commit | 1e4db9ed0f538d17e876ec36b538f05a31989cc0 (patch) | |
tree | d68729657f59e81e307448260f347754c6e992af /spec/support | |
parent | 3d72cb897efddc14021afe8b064aa2bff14c7c15 (diff) | |
parent | a0adafddd0ce40c4ce9f052d2ee5e8ea38a2fb58 (diff) |
Merge branch 'make-omniauth-tests-to-not-modify-global-state' into 'master'
Make Omniauth providers specs to not modify global configuration
See merge request !4534
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/import_spec_helper.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support/import_spec_helper.rb b/spec/support/import_spec_helper.rb new file mode 100644 index 00000000000..6710962f082 --- /dev/null +++ b/spec/support/import_spec_helper.rb @@ -0,0 +1,33 @@ +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 = OpenStruct.new( + name: name, + app_id: 'asd123', + app_secret: 'asd123' + ) + allow(Gitlab.config.omniauth).to receive(:providers).and_return([provider]) + end +end |