Skip to content

A platform for community discussion. Free, open, simple.

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

Régis Hanolc3e6e9cfddff
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)