Commit 8dcff73e authored by Lin Jen-Shin's avatar Lin Jen-Shin

Stub more and memorise current user

parent 5de49a36
......@@ -2,6 +2,8 @@ module EE
module API
module Helpers
def current_user
return @current_user if defined?(@current_user)
user = super
::Gitlab::Database::LoadBalancing::RackMiddleware
......
require 'spec_helper'
describe EE::API::Helpers do
let(:helper) { Class.new { include API::Helpers }.new }
let(:env) { { 'rack.input' => StringIO.new } }
let(:helper) do
Class.new { include API::Helpers, API::APIGuard::HelperMethods }.new
end
before do
allow(helper).to receive(:env).and_return({})
allow(helper).to receive(:env).and_return(env)
allow(helper).to receive(:params).and_return({})
allow(helper).to receive(:options).and_return({})
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true)
end
......@@ -19,7 +25,7 @@ describe EE::API::Helpers do
allow(helper).to receive(:initial_current_user).and_return(user)
expect(Gitlab::Database::LoadBalancing::RackMiddleware)
.to receive(:stick_or_unstick).with({}, :user, 42)
.to receive(:stick_or_unstick).with(env, :user, 42)
helper.current_user
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