From c3e6e9cfddff747082b3c3d199da2c594ce6559e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 1 Apr 2024 23:27:16 +0200 Subject: [PATCH] FIX: print view wasn't working (#26433) In e05628c0793567b581ca04cbae801a7d4a6e55ca we omitted the HTML view for logged in users but that view is used when printing. This restore the HTML view when printing a topic page. --- app/helpers/application_helper.rb | 6 +++++- spec/helpers/application_helper_spec.rb | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 45288529127..fe0edba2d80 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -430,7 +430,11 @@ module ApplicationHelper end def include_crawler_content? - (crawler_layout? || !mobile_view? || !modern_mobile_device?) && !current_user + if current_user + params.key?(:print) + else + crawler_layout? || !mobile_view? || !modern_mobile_device? + end end def modern_mobile_device? diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 93718f2b01b..38ecd1d11db 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -17,6 +17,13 @@ RSpec.describe ApplicationHelper do expect(helper.include_crawler_content?).to eq(false) end + it "sends crawler content to logged on users who wants to print" do + helper.stubs(:current_user).returns(Fabricate(:user)) + helper.stubs(:params).returns(print: true) + + expect(helper.include_crawler_content?).to eq(true) + end + it "sends crawler content to old mobiles" do controller.stubs(:use_crawler_layout?).returns(false)