Skip to content

Commit

Permalink
Insert send request middleware only if env variable RAILS_SERVE_STATI…
Browse files Browse the repository at this point in the history
…C_FILES set (#70)
  • Loading branch information
asatwal authored Apr 26, 2023
1 parent 6edcb17 commit b4cddf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/dfe/analytics/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class Railtie < Rails::Railtie
initializer 'dfe.analytics.insert_middleware' do |app|
app.config.middleware.use DfE::Analytics::Middleware::RequestIdentity

app.config.middleware.insert_before \
ActionDispatch::Static, DfE::Analytics::Middleware::SendCachedPageRequestEvent
if ENV['RAILS_SERVE_STATIC_FILES'].present?
app.config.middleware.insert_before \
ActionDispatch::Static, DfE::Analytics::Middleware::SendCachedPageRequestEvent
end
end

initializer 'dfe.analytics.logger' do
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

ENV['RAILS_ENV'] = 'test'
ENV['SUPPRESS_DFE_ANALYTICS_INIT'] = 'true'
ENV['RAILS_SERVE_STATIC_FILES'] = 'true'

require_relative '../spec/dummy/config/environment'
require 'debug'
Expand Down

0 comments on commit b4cddf6

Please sign in to comment.