diff options
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/patch/draw_route.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/patch/draw_route_spec.rb | 30 |
3 files changed, 38 insertions, 2 deletions
diff --git a/config/routes.rb b/config/routes.rb index c081ca9672a..8723a928cc3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,6 +34,8 @@ Rails.application.routes.draw do match '*all', via: [:get, :post], to: proc { [404, {}, ['']] } end + draw :oauth + use_doorkeeper_openid_connect # Autocomplete diff --git a/lib/gitlab/patch/draw_route.rb b/lib/gitlab/patch/draw_route.rb index f8ae6f7afc0..c7a0b49a948 100644 --- a/lib/gitlab/patch/draw_route.rb +++ b/lib/gitlab/patch/draw_route.rb @@ -13,11 +13,15 @@ module Gitlab end def draw_ce(routes_name) - draw_route(Rails.root.join("config/routes/#{routes_name}.rb")) + draw_route(route_path("config/routes/#{routes_name}.rb")) end def draw_ee(routes_name) - draw_route(Rails.root.join("ee/config/routes/#{routes_name}.rb")) + draw_route(route_path("ee/config/routes/#{routes_name}.rb")) + end + + def route_path(routes_name) + Rails.root.join(routes_name) end def draw_route(path) diff --git a/spec/lib/gitlab/patch/draw_route_spec.rb b/spec/lib/gitlab/patch/draw_route_spec.rb new file mode 100644 index 00000000000..4009b903dc3 --- /dev/null +++ b/spec/lib/gitlab/patch/draw_route_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +describe Gitlab::Patch::DrawRoute do + subject do + Class.new do + include Gitlab::Patch::DrawRoute + + def route_path(route_name) + File.expand_path("../../../../#{route_name}", __dir__) + end + end.new + end + + before do + allow(subject).to receive(:instance_eval) + end + + it 'evaluates CE only route' do + subject.draw(:help) + + expect(subject).to have_received(:instance_eval) + .with(File.read(subject.route_path('config/routes/help.rb'))) + .once + + expect(subject).to have_received(:instance_eval) + .once + end +end |