summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-10-18 00:55:42 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-10-26 14:27:05 +0800
commit52fa309e86d1bafc6b8a986d8bd74fd906b1ebc9 (patch)
tree879d8ed6fb6646d1a642a24460f03f6409fb0bd3
parentf1701c0fec096184a5908df65187573209dd6254 (diff)
downloadgitlab-ce-52fa309e86d1bafc6b8a986d8bd74fd906b1ebc9.tar.gz
Extract EE only oauth routes and add tests
-rw-r--r--config/routes.rb2
-rw-r--r--lib/gitlab/patch/draw_route.rb8
-rw-r--r--spec/lib/gitlab/patch/draw_route_spec.rb30
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