FIX: print view wasn't working (#26433)

In e05628c079 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.
This commit is contained in:
Régis Hanol 2024-04-01 23:27:16 +02:00 committed by GitHub
parent 48cb7b7863
commit c3e6e9cfdd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -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?

View File

@ -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)