<commit_before>module LightMobile::DynamicRenderer
  # In order to only render mobile views if they exist.
  def render(*args, &blk)
    if request.user_agent && view_context.agent_mobile? && (session[:light_mobile_version].to_s == "mobile" || !session[:light_mobile_version].present?)
      name = args[0]
      name = action_name.to_sym if !name.is_a?(Symbol) && !name.is_a?(String)

      if name.is_a? Symbol
        view_paths.each do |view_path|
          ActionView::Template::Handlers.extensions.each do |handler|
            full_path = "#{view_path}/#{controller_path}/#{name}.mobile.#{handler}"
            next unless File.exists?(full_path)
            request.format = :mobile
            self.formats = [:mobile, :html]
          end
        end
      end
    end

    super
  end
end<commit_msg>Added way to force mobile version through params to easier write tests<commit_after>module LightMobile::DynamicRenderer
  # In order to only render mobile views if they exist.
  def render(*args, &blk)
    if request.user_agent && view_context.agent_mobile? && (session[:light_mobile_version].to_s == "mobile" || !session[:light_mobile_version].present?)
      render_mobile = true
    elsif params[:mobile].to_s == '1'
      render_mobile = true
    end

    if render_mobile
      name = args[0]
      name = action_name.to_sym if !name.is_a?(Symbol) && !name.is_a?(String)

      if name.is_a? Symbol
        view_paths.each do |view_path|
          ActionView::Template::Handlers.extensions.each do |handler|
            full_path = "#{view_path}/#{controller_path}/#{name}.mobile.#{handler}"
            next unless File.exists?(full_path)
            request.format = :mobile
            self.formats = [:mobile, :html]
          end
        end
      end
    end

    super
  end
end
{'fraction_non_alphanumeric': 0.11660188784008883, 'fraction_numerical': 0.001665741254858412, 'mean_word_length': 2.809725158562368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3294541', 'n_tokens_mistral': 539, 'n_tokens_neox': 545, 'n_words': 128}