diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1d5b5794d66..b409efe2183 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -431,7 +431,7 @@ module ApplicationHelper end def include_crawler_content? - if current_user + if current_user && !crawler_layout? params.key?(:print) else crawler_layout? || !mobile_view? || !modern_mobile_device? diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 040722f48e3..561005784b7 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -19,11 +19,19 @@ RSpec.describe ApplicationHelper do it "sends crawler content to logged on users who wants to print" do helper.stubs(:current_user).returns(Fabricate(:user)) + controller.stubs(:use_crawler_layout?).returns(false) helper.stubs(:params).returns(print: true) expect(helper.include_crawler_content?).to eq(true) end + it "sends crawler content to logged on users with a crawler user agent" do + helper.stubs(:current_user).returns(Fabricate(:user)) + controller.stubs(:use_crawler_layout?).returns(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)