<commit_before>require 'spec_helper'

describe Spree::Order do
  let(:order_one) { OrderWalkthrough.up_to(:payment) }
  let(:order_two) { OrderWalkthrough.up_to(:payment) }
  let(:stripe_apple_pay_payment_method) do
    Spree::Gateway::StripeApplePayGateway.create!(
      name: 'ApplePay',
      preferred_domain_verification_certificate: FFaker::Lorem.characters(20)
    )
  end
  let(:stripe_credit_card_payment_method) do
    Spree::Gateway::StripeGateway.create!(
      name: 'CreditCard',
      preferred_secret_key: FFaker::Lorem.characters(20),
      preferred_publishable_key: FFaker::Lorem.characters(20)
    )
  end

  before do
    order_one.payments.create(payment_method_id: stripe_apple_pay_payment_method.id,
                              amount: 29.99,
                              state: 'completed')
    order_two.payments.create(payment_method_id: stripe_credit_card_payment_method.id,
                              amount: 29.99,
                              state: 'completed')
    order_one.update_totals
    order_two.update_totals
  end

  describe '#paid_with_apple_pay?' do
    context 'when an order was paid with Apply Pay' do
      it 'returns true' do
        expect(order_one.paid_with_apple_pay?).to eq true
      end
    end

    context 'when an order was paid with Credit Card' do
      it 'returns false' do<commit_msg>Fixed Order Spec for Spree 3.7/4.0 support<commit_after>require 'spec_helper'

describe Spree::Order do
  let(:order_one) { OrderWalkthrough.up_to(:payment) }
  let(:order_two) { OrderWalkthrough.up_to(:payment) }
  let(:stripe_apple_pay_payment_method) do
    Spree::Gateway::StripeApplePayGateway.create!(
      name: 'ApplePay',
      preferred_domain_verification_certificate: FFaker::Lorem.characters(20)
    )
  end
  let(:stripe_credit_card_payment_method) do
    Spree::Gateway::StripeGateway.create!(
      name: 'CreditCard',
      preferred_secret_key: FFaker::Lorem.characters(20),
      preferred_publishable_key: FFaker::Lorem.characters(20)
    )
  end

  before do
    Spree::Config[:always_include_confirm_step] = true
    allow_any_instance_of(Spree::PaymentMethod).to receive(:source_required?).and_return(false)

    order_one.payments.create(payment_method_id: stripe_apple_pay_payment_method.id,
                              amount: 29.99,
                              state: 'completed')
    order_two.payments.create(payment_method_id: stripe_credit_card_payment_method.id,
                              amount: 29.99,
                              state: 'completed')
    order_one.update_totals
    order_two.update_totals
  end

  describe '#paid_with_apple_pay?' do
    context 'when an order was paid with Apply Pay' do
      it 'returns true' do
        expect(order_one.paid_with_apple_pay?).to eq true
      end
    end

    context 'when an order was paid with Credit Card' do
      it 'returns false' do
{'fraction_non_alphanumeric': 0.08940283051432517, 'fraction_numerical': 0.011045909561615464, 'mean_word_length': 3.0362116991643453, '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': '3374536', 'n_tokens_mistral': 945, 'n_tokens_neox': 903, 'n_words': 169}