Commit 7d534208 authored by Peter Leitzen's avatar Peter Leitzen

Refactor project import service spec to stub provider without details

It seems that the stubbed provider variable is not used to verify import
behaviour, so let's not stub it with too many details.

Note that this was caught because we've passed a Hash with String keys
to `ActiveSupport::InheritableOptions` whereas Symbol keys are expected.
parent c5cd56d7
......@@ -199,12 +199,13 @@ RSpec.describe Projects::ImportService do
context 'with valid importer' do
before do
stub_github_omniauth_provider
provider = double(:provider).as_null_object
stub_omniauth_setting(providers: [provider])
project.import_url = 'https://github.com/vim/vim.git'
project.import_type = 'github'
allow(project).to receive(:import_data).and_return(double.as_null_object)
allow(project).to receive(:import_data).and_return(double(:import_data).as_null_object)
end
it 'succeeds if importer succeeds' do
......@@ -296,22 +297,5 @@ RSpec.describe Projects::ImportService do
subject.execute
end
end
def stub_github_omniauth_provider
provider = ActiveSupport::InheritableOptions.new(
'name' => 'github',
'app_id' => 'asd123',
'app_secret' => 'asd123',
'args' => {
'client_options' => {
'site' => 'https://github.com/api/v3',
'authorize_url' => 'https://github.com/login/oauth/authorize',
'token_url' => 'https://github.com/login/oauth/access_token'
}
}
)
stub_omniauth_setting(providers: [provider])
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment