Skip to content

Commit 10d9bc4

Browse files
rolfschmidtmantas
andcommitted
Fixes zammad#5541 - The use of X-On-Behalf-Of in a REST call leads to a 500 error message.
Co-authored-by: Mantas Masalskis <[email protected]>
1 parent 54dbd7d commit 10d9bc4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

app/controllers/application_controller/has_user.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def current_user_real
2424
def request_header_from
2525
@request_header_from ||= begin
2626
if request.headers['X-On-Behalf-Of'].present?
27-
ActiveSupport::Deprecation.send(:warn, "Header 'X-On-Behalf-Of' is deprecated. Please use header 'From' instead.") # rubocop:disable Zammad/DetectTranslatableString
27+
ActiveSupport::Deprecation.new.warn("Header 'X-On-Behalf-Of' is deprecated. Please use header 'From' instead.")
28+
Rails.logger.warn("Header 'X-On-Behalf-Of' is deprecated. Please use header 'From' instead.")
2829
end
2930

3031
request.headers['From'] || request.headers['X-On-Behalf-Of']

lib/background_services/service_config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def self.configuration_from_env(input)
99
if !input['ZAMMAD_PROCESS_SESSIONS_JOBS_WORKERS'] && input['ZAMMAD_SESSION_JOBS_CONCURRENT']
1010
input['ZAMMAD_PROCESS_SESSIONS_JOBS_WORKERS'] = input['ZAMMAD_SESSION_JOBS_CONCURRENT']
1111

12-
ActiveSupport::Deprecation.send(:warn, 'The environment variable ZAMMAD_SESSION_JOBS_CONCURRENT is deprecated, please use ZAMMAD_PROCESS_SESSIONS_JOBS_WORKERS instead.') # rubocop:disable Zammad/DetectTranslatableString
12+
ActiveSupport::Deprecation.new.warn('The environment variable ZAMMAD_SESSION_JOBS_CONCURRENT is deprecated, please use ZAMMAD_PROCESS_SESSIONS_JOBS_WORKERS instead.')
13+
Rails.logger.warn('The environment variable ZAMMAD_SESSION_JOBS_CONCURRENT is deprecated, please use ZAMMAD_PROCESS_SESSIONS_JOBS_WORKERS instead.')
1314
end
1415

1516
BackgroundServices

spec/lib/background_services/service_config_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@
5959
end
6060

6161
it 'handles the deprecated setting ZAMMAD_SESSION_JOBS_CONCURRENT correctly', :aggregate_failures do
62-
allow(ActiveSupport::Deprecation).to receive(:warn)
62+
deprecator = instance_double(ActiveSupport::Deprecation)
63+
allow(ActiveSupport::Deprecation).to receive(:new).and_return(deprecator)
64+
allow(deprecator).to receive(:warn)
6365
hash = { 'ZAMMAD_SESSION_JOBS_CONCURRENT' => 2 }
6466

6567
configurations = described_class.configuration_from_env(hash)
6668
single_config = configurations.find { |config| config.service == BackgroundServices::Service::ProcessSessionsJobs }
6769

6870
expect(single_config.workers).to be(2)
69-
expect(ActiveSupport::Deprecation).to have_received(:warn).once
71+
expect(deprecator).to have_received(:warn).once
7072
end
7173
end
7274

0 commit comments

Comments
 (0)