Skip to content
Snippets Groups Projects
Commit 57a94173 authored by Illya Klymov's avatar Illya Klymov :rocket:
Browse files

Maintain namespace_id when connection error occurs in fogbugz importer

Always maintain namespace_id when performing redirects

Changelog: fixed
parent 7e268b5a
No related branches found
No related tags found
1 merge request!91319Maintain namespace_id when connection error occurs in fogbugz importer
......@@ -17,7 +17,7 @@ def callback
res = Gitlab::FogbugzImport::Client.new(import_params.to_h.symbolize_keys)
rescue StandardError
# If the URI is invalid various errors can occur
return redirect_to new_import_fogbugz_path, alert: _('Could not connect to FogBugz, check your URL')
return redirect_to new_import_fogbugz_path(namespace_id: params[:namespace_id]), alert: _('Could not connect to FogBugz, check your URL')
end
session[:fogbugz_token] = res.get_token
session[:fogbugz_uri] = params[:uri]
......
......@@ -29,12 +29,21 @@
expect(response).to redirect_to(new_user_map_import_fogbugz_path)
end
it 'preserves namespace_id query param' do
it 'preserves namespace_id query param on success' do
post :callback, params: { uri: uri, email: 'test@example.com', password: 'mypassword', namespace_id: namespace_id }
expect(response).to redirect_to(new_user_map_import_fogbugz_path(namespace_id: namespace_id))
end
it 'redirects to new page maintaining namespace_id when client raises standard error' do
namespace_id = 5
allow(::Gitlab::FogbugzImport::Client).to receive(:new).and_raise(StandardError)
post :callback, params: { uri: uri, email: 'test@example.com', password: 'mypassword', namespace_id: namespace_id }
expect(response).to redirect_to(new_import_fogbugz_url(namespace_id: namespace_id))
end
it 'redirects to new page form when client raises authentication exception' do
allow(::Gitlab::FogbugzImport::Client).to receive(:new).and_raise(::Fogbugz::AuthenticationException)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment