<commit_before>
class AbilityDecorator
  include CanCan::Ability
  def initialize(user)
    if user.enterprises.count > 0
      can [:admin, :read, :update, :bulk_edit], Spree::Product  do |product|
        user.enterprises.include? product.supplier
      end

      can [:create], Spree::Product
      can [:admin, :index, :read, :create, :edit], Spree::Variant
      can [:admin, :index, :read, :create, :edit], Spree::ProductProperty
      can [:admin, :index, :read, :create, :edit], Spree::Image

      can [:admin, :index, :read, :search], Spree::Taxon
      can [:admin, :index, :read, :create, :edit], Spree::Classification

      can [:admin, :index, :read], Spree::Order
    end
  end
end

Spree::Ability.register_ability(AbilityDecorator)<commit_msg>Add clone and destroy product access for enterprise users<commit_after>
class AbilityDecorator
  include CanCan::Ability
  def initialize(user)
    if user.enterprises.count > 0
      can [:admin, :read, :update, :bulk_edit, :clone, :destroy], Spree::Product  do |product|
        user.enterprises.include? product.supplier
      end

      can [:create], Spree::Product
      can [:admin, :index, :read, :create, :edit], Spree::Variant
      can [:admin, :index, :read, :create, :edit], Spree::ProductProperty
      can [:admin, :index, :read, :create, :edit], Spree::Image

      can [:admin, :index, :read, :search], Spree::Taxon
      can [:admin, :index, :read, :create, :edit], Spree::Classification

      can [:admin, :index, :read], Spree::Order
    end
  end
end

Spree::Ability.register_ability(AbilityDecorator)
{'fraction_non_alphanumeric': 0.15025252525252525, 'fraction_numerical': 0.0012626262626262627, 'mean_word_length': 3.968652037617555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '805533', 'n_tokens_mistral': 531, 'n_tokens_neox': 521, 'n_words': 143}