Commit 8e319ab2 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'dcouture-floc-optout-beforeaction' into 'master'

Set floc opt out header before_action

See merge request gitlab-org/gitlab!82320
parents 53e4024e bceba1b5
...@@ -4,7 +4,7 @@ module FlocOptOut ...@@ -4,7 +4,7 @@ module FlocOptOut
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
after_action :set_floc_opt_out_header, unless: :floc_enabled? before_action :set_floc_opt_out_header, unless: :floc_enabled?
end end
def floc_enabled? def floc_enabled?
......
...@@ -1059,15 +1059,25 @@ RSpec.describe ApplicationController do ...@@ -1059,15 +1059,25 @@ RSpec.describe ApplicationController do
describe 'setting permissions-policy header' do describe 'setting permissions-policy header' do
controller do controller do
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
before_action :redirect_to_example, only: [:redirect]
def index def index
render html: 'It is a flock of sheep, not a floc of sheep.' render html: 'It is a flock of sheep, not a floc of sheep.'
end end
def redirect
raise 'Should not be reached'
end
def redirect_to_example
redirect_to('https://example.com')
end
end end
before do before do
routes.draw do routes.draw do
get 'index' => 'anonymous#index' get 'index' => 'anonymous#index'
get 'redirect' => 'anonymous#redirect'
end end
end end
...@@ -1093,6 +1103,13 @@ RSpec.describe ApplicationController do ...@@ -1093,6 +1103,13 @@ RSpec.describe ApplicationController do
expect(response.headers['Permissions-Policy']).to eq('interest-cohort=()') expect(response.headers['Permissions-Policy']).to eq('interest-cohort=()')
end end
it 'sets the Permissions-Policy header even when redirected before_action' do
get :redirect
expect(response).to have_gitlab_http_status(:redirect)
expect(response.headers['Permissions-Policy']).to eq('interest-cohort=()')
end
end end
end end
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