<commit_before># Invoice queue

When /^the attendee invoicer runs$/ do
  # Set some things that must exist, if they don't already
  @invoice_description ||= SecureRandom.hex(32)
  @base_price ||= SecureRandom.random_number(9999)
  @invoice_uid ||= create_invoice_uid
  # Invoice
  Invoicer.perform(create_invoice_to_hash, create_invoice_details_hash, @invoice_uid)
end

When /^I have not already been invoiced$/ do
  Invoicer.should_receive(:invoice_sent?).with(create_invoice_uid).once.and_return(false)
end

Then /^I should be added to the invoicing queue$/ do
  # Set expectation
  Resque.should_receive(:enqueue) do |arg1, arg2, arg3|
    arg1.should == Invoicer
    arg2.should == create_invoice_to_hash
    arg3['payment_method'].should == create_invoice_details_hash['payment_method']
    arg3['repeat'].should == create_invoice_details_hash['repeat']
    arg3['purchase_order_reference'].should == create_invoice_details_hash['purchase_order_reference']
    arg3['sector'].should == create_invoice_details_hash['sector']

    create_invoice_details_hash['line_items'].each_with_index do |k, i|
      arg3['line_items'][i]['quantity'].should == k['quantity']
      arg3['line_items'][i]['base_price'].should == k['base_price']
      arg3['line_items'][i]['description'].should == k['description']
      arg3['line_items'][i]['payment_method'].should == k['payment_method']
      arg3['line_items'][i]['discount_rate'].should == k['discount_rate']
    end
  end
end

Then /^I should be added to the invoicing queue along with others$/ do
  # Set expectation
  Resque.stub(:enqueue)
  Resque.should_receive(:enqueue).with(Invoicer, create_invoice_to_hash, create_invoice_details_hash, create_invoice_uid).once
end

Then /^I should not be added to the invoicing queue$/ do
  Resque.should_not_receive(:enqueue).with(no_args) do |klass, user, payment|
    payment[:line_items] == @line_items
  end
end

Then /^the attendee invoicer should be requeued$/ do
  # Set some things that must exist, if they don't already
  @invoice_description ||= SecureRandom.hex(32)
  @base_price ||= SecureRandom.random_number(9999)
  # Set expectation
  Resque.should_receive(:enqueue).with(Invoicer, create_invoice_to_hash, create_invoice_details_hash, create_invoice_uid).once
end
<commit_msg>We don't use this either<commit_after># Invoice queue

When /^the attendee invoicer runs$/ do
  # Set some things that must exist, if they don't already
  @invoice_description ||= SecureRandom.hex(32)
  @base_price ||= SecureRandom.random_number(9999)
  @invoice_uid ||= create_invoice_uid
  # Invoice
  Invoicer.perform(create_invoice_to_hash, create_invoice_details_hash, @invoice_uid)
end

When /^I have not already been invoiced$/ do
  Invoicer.should_receive(:invoice_sent?).with(create_invoice_uid).once.and_return(false)
end

Then /^I should be added to the invoicing queue$/ do
  # Set expectation
  Resque.should_receive(:enqueue) do |arg1, arg2, arg3|
    arg1.should == Invoicer
    arg2.should == create_invoice_to_hash
    arg3['payment_method'].should == create_invoice_details_hash['payment_method']
    arg3['repeat'].should == create_invoice_details_hash['repeat']
    arg3['purchase_order_reference'].should == create_invoice_details_hash['purchase_order_reference']
    arg3['sector'].should == create_invoice_details_hash['sector']

    create_invoice_details_hash['line_items'].each_with_index do |k, i|
      arg3['line_items'][i]['quantity'].should == k['quantity']
      arg3['line_items'][i]['base_price'].should == k['base_price']
      arg3['line_items'][i]['description'].should == k['description']
      arg3['line_items'][i]['payment_method'].should == k['payment_method']
      arg3['line_items'][i]['discount_rate'].should == k['discount_rate']
    end
  end
end

Then /^I should be added to the invoicing queue along with others$/ do
  # Set expectation
  Resque.stub(:enqueue)
  Resque.should_receive(:enqueue).with(Invoicer, create_invoice_to_hash, create_invoice_details_hash, create_invoice_uid).once
end

Then /^I should not be added to the invoicing queue$/ do
  Resque.should_not_receive(:enqueue).with(no_args)
end

Then /^the attendee invoicer should be requeued$/ do
  # Set some things that must exist, if they don't already
  @invoice_description ||= SecureRandom.hex(32)
  @base_price ||= SecureRandom.random_number(9999)
  # Set expectation
  Resque.should_receive(:enqueue).with(Invoicer, create_invoice_to_hash, create_invoice_details_hash, create_invoice_uid).once
end

{'fraction_non_alphanumeric': 0.12336074683262947, 'fraction_numerical': 0.01155812402756168, 'mean_word_length': 5.80786686838124, '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': '4658773', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1472, 'n_words': 309}