Commit f4d06fad authored by Lin Jen-Shin's avatar Lin Jen-Shin

Extract EE only oauth routes and add tests

parent 745d18e7
......@@ -37,13 +37,7 @@ Rails.application.routes.draw do
match '*all', via: [:get, :post], to: proc { [404, {}, ['']] }
end
namespace :oauth do
scope path: 'geo', controller: :geo_auth, as: :geo do
get 'auth'
get 'callback'
get 'logout'
end
end
draw :oauth
use_doorkeeper_openid_connect
......
namespace :oauth do
scope path: 'geo', controller: :geo_auth, as: :geo do
get 'auth'
get 'callback'
get 'logout'
end
end
# 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 EE only routes' do
subject.draw(:oauth)
expect(subject).to have_received(:instance_eval)
.with(File.read(subject.route_path('ee/config/routes/oauth.rb')))
.once
expect(subject).to have_received(:instance_eval)
.once
end
it 'evaluates CE and EE routes' do
subject.draw(:admin)
expect(subject).to have_received(:instance_eval)
.with(File.read(subject.route_path('config/routes/admin.rb')))
.once
expect(subject).to have_received(:instance_eval)
.with(File.read(subject.route_path('ee/config/routes/admin.rb')))
.once
end
end
......@@ -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)
......
# 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
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