<commit_before>module Spree
  # Handles checkout logic.  This is somewhat contrary to standard REST convention since there is not actually a
  # Checkout object.  There's enough distinct logic specific to checkout which has nothing to do with updating an
  # order that this approach is waranted.

  # Much of this file, especially the update action is overriden in the promo gem.
  # This is to allow for the promo behavior but also allow the promo gem to be 
  # removed if the functionality is not needed. 

  class CheckoutController < Spree::StoreController
    ssl_required

    before_filter :load_order
    before_filter :ensure_valid_state
    before_filter :associate_user
    before_filter :check_authorization
    rescue_from Spree::Core::GatewayError, :with => :rescue_from_spree_gateway_error

    respond_to :html

    # Updates the order and advances to the next state (when possible.)
    # Overriden by the promo gem if it exists. 
    def update
      if @order.update_attributes(object_params)
        fire_event('spree.checkout.update')

        if @order.next
          state_callback(:after)
        else
          flash[:error] = t(:payment_processing_failed)
          respond_with(@order, :location => checkout_state_path(@order.state))
          return
        end<commit_msg>Use truncate_html to fix HTML truncating issues<commit_after>module Spree
  # Handles checkout logic.  This is somewhat contrary to standard REST convention since there is not actually a
  # Checkout object.  There's enough distinct logic specific to checkout which has nothing to do with updating an
  # order that this approach is waranted.

  # Much of this file, especially the update action is overriden in the promo gem.
  # This is to allow for the promo behavior but also allow the promo gem to be 
  # removed if the functionality is not needed. 

  class CheckoutController < Spree::StoreController
    ssl_required

    before_filter :load_order
    before_filter :ensure_valid_state
    before_filter :associate_user
    before_filter :check_authorization
    rescue_from Spree::Core::GatewayError, :with => :rescue_from_spree_gateway_error

    respond_to :html

    helper 'spree/orders'

    # Updates the order and advances to the next state (when possible.)
    # Overriden by the promo gem if it exists. 
    def update
      if @order.update_attributes(object_params)
        fire_event('spree.checkout.update')

        if @order.next
          state_callback(:after)
        else
          flash[:error] = t(:payment_processing_failed)
          respond_with(@order, :location => checkout_state_path(@order.state))
          return
        end
{'fraction_non_alphanumeric': 0.05511811023622047, 'fraction_numerical': 0.0, 'mean_word_length': 3.3666121112929623, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4548423', 'n_tokens_mistral': 731, 'n_tokens_neox': 703, 'n_words': 271}