Skip to content

cms_site_detect fails if request is nil #940

@catmando

Description

@catmando

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions