Commit cba68d33 authored by digitalMoksha's avatar digitalMoksha

use `Gitlab::Routing.url_helpers` instead of `Rails.application.routes.url_helpers`

since `Rails.application.routes.url_helpers` creates a new anonymous module every time it's called
parent 3c52e2f0
......@@ -58,7 +58,7 @@ module Gitlab
end
def last_visited_url
@env['HTTP_REFERER'] || rack_session['user_return_to'] || Rails.application.routes.url_helpers.root_url
@env['HTTP_REFERER'] || rack_session['user_return_to'] || Gitlab::Routing.url_helpers.root_url
end
def route_hash
......
......@@ -91,6 +91,12 @@ describe Gitlab::Middleware::ReadOnly do
expect(subject).to disallow_request
end
it 'returns last_vistited_url for disallowed request' do
response = request.post('/test_request')
expect(response.location).to eq 'http://localhost/'
end
context 'whitelisted requests' do
it 'expects a POST internal request to be allowed' do
expect(Rails.application.routes).not_to receive(:recognize_path)
......
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