Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cms_site_detect fails if request is nil #940

Open
catmando opened this issue Jun 29, 2021 · 0 comments
Open

cms_site_detect fails if request is nil #940

catmando opened this issue Jun 29, 2021 · 0 comments

Comments

@catmando
Copy link

Expected behavior

cms_site_detect should just return nil if there is no request object

Actual behavior

If there is no rails request object (request == nil) cms_site_detect raises an error

Steps to reproduce

Try it in a server side test spec for example, where perhaps there is no CMS environment. Old behavior (comfy v 1.12 for example) was just to return a blank string when rendering if there was no site. Comfy > v 1.12 no raises an error.

Here is a patch:

module Comfy
  module CmsHelper
    def cms_site_detect
      return nil unless request

      host = request.host_with_port.downcase
      path = request.fullpath
      Comfy::Cms::Site.find_site(host, path)
    end
  end
end

System configuration

CMS version:

1.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant