From cb2477a9912bd4c89fbb790aec2bef3a590d40bd Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Mon, 6 Feb 2023 18:38:00 -0500 Subject: [PATCH] Prefer remote_ip in GaEventsController (#19074) --- app/controllers/application_controller.rb | 2 +- app/controllers/ga_events_controller.rb | 2 +- .../seededFlows/articleFlows/playOrPauseAnimatedImages.spec.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3b2f5eb65..ecd23acf7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -238,7 +238,7 @@ class ApplicationController < ActionController::Base end def anonymous_user - User.new(ip_address: request.env["HTTP_FASTLY_CLIENT_IP"] || request.env["HTTP_X_FORWARDED_FOR"]) + User.new(ip_address: request.env["HTTP_FASTLY_CLIENT_IP"] || request.remote_ip) end def initialize_stripe diff --git a/app/controllers/ga_events_controller.rb b/app/controllers/ga_events_controller.rb index 21d283b98..79b16081a 100644 --- a/app/controllers/ga_events_controller.rb +++ b/app/controllers/ga_events_controller.rb @@ -31,7 +31,7 @@ class GaEventsController < ApplicationController def scrambled_ip crypt = ActiveSupport::MessageEncryptor.new(todays_key) - crypt.encrypt_and_sign(request.env["HTTP_X_FORWARDED_FOR"] || request.remote_ip) + crypt.encrypt_and_sign(request.env["HTTP_FASTLY_CLIENT_IP"] || request.remote_ip) end def todays_key diff --git a/cypress/e2e/seededFlows/articleFlows/playOrPauseAnimatedImages.spec.js b/cypress/e2e/seededFlows/articleFlows/playOrPauseAnimatedImages.spec.js index 19a4bbce6..e9bca3c0d 100644 --- a/cypress/e2e/seededFlows/articleFlows/playOrPauseAnimatedImages.spec.js +++ b/cypress/e2e/seededFlows/articleFlows/playOrPauseAnimatedImages.spec.js @@ -27,6 +27,7 @@ describe('play or pause animated images', () => { describe('no reduced motion preference', () => { beforeEach(() => { + cy.testSetup(); Cypress.on('window:before:load', (window) => { window.document.body = generateFakePageBody(); });