<commit_before>require 'spec_helper'

describe Spree::Calculator::Vat do
  before(:each) do
    @configuration ||= Spree::AppConfiguration.find_or_create_by_name("Default configuration")
  end

  let(:tax_category) { Factory(:tax_category, :tax_rates => []) }
  let(:vat_rate) { Factory(:tax_rate, :amount => 0.15, :tax_category_id => tax_category.id) }
  let(:calculator) { Spree::Calculator::Vat.new(:calculable => vat_rate) }

  context ".compute" do
    let(:order) { mock_model Spree::Order, :line_items => [Factory(:line_item, :price => 20.0), Factory(:line_item, :price => 40.0)], :adjustments => [] }

    context "when rate does not belong to the default tax category" do
      before { vat_rate.tax_category.stub(:is_default => false) }

      it "should compute correctly when one product has matching tax category" do<commit_msg>Allow backorders in calcualtor/vat_spec to stop 'Quantity exceeds stock' error<commit_after>require 'spec_helper'

describe Spree::Calculator::Vat do
  before(:each) do
    @configuration ||= Spree::AppConfiguration.find_or_create_by_name("Default configuration")
    Spree::Config.set :allow_backorders => true
  end

  let(:tax_category) { Factory(:tax_category, :tax_rates => []) }
  let(:vat_rate) { Factory(:tax_rate, :amount => 0.15, :tax_category_id => tax_category.id) }
  let(:calculator) { Spree::Calculator::Vat.new(:calculable => vat_rate) }

  context ".compute" do
    let(:order) { mock_model Spree::Order, :line_items => [Factory(:line_item, :price => 20.0), Factory(:line_item, :price => 40.0)], :adjustments => [] }

    context "when rate does not belong to the default tax category" do
      before { vat_rate.tax_category.stub(:is_default => false) }

      it "should compute correctly when one product has matching tax category" do
{'fraction_non_alphanumeric': 0.14094707520891364, 'fraction_numerical': 0.010027855153203343, 'mean_word_length': 5.1931034482758625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '3385328', 'n_tokens_mistral': 597, 'n_tokens_neox': 561, 'n_words': 139}