diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-11 21:09:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-11 21:09:23 +0300 |
commit | 76e9fc7b29c1ce716c26932e9fbec0f3c99f53f4 (patch) | |
tree | b5ca8e3a6b2cf93b67257b38ee71e2efee177700 /spec/controllers | |
parent | a210c43e0aca0311cc1d3d381763b25979ec72dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/sessions_controller_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 2f597fd5cb3..a677e17ab0c 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -495,4 +495,45 @@ describe SessionsController do expect(session[:failed_login_attempts]).to eq(1) end end + + describe '#set_current_context' do + before do + set_devise_mapping(context: @request) + end + + context 'when signed in' do + let_it_be(:user) { create(:user) } + + before do + sign_in(user) + end + + it 'sets the username and caller_id in the context' do + expect(controller).to receive(:destroy).and_wrap_original do |m, *args| + expect(Labkit::Context.current.to_h) + .to include('meta.user' => user.username, + 'meta.caller_id' => 'SessionsController#destroy') + + m.call(*args) + end + + delete :destroy + end + end + + context 'when not signed in' do + it 'sets the caller_id in the context' do + expect(controller).to receive(:new).and_wrap_original do |m, *args| + expect(Labkit::Context.current.to_h) + .to include('meta.caller_id' => 'SessionsController#new') + expect(Labkit::Context.current.to_h) + .not_to include('meta.user') + + m.call(*args) + end + + get :new + end + end + end end |