Sha256: df19cc210fecd6aceba24fa970bf3497615da8fcf435f51b79081ff968c29236

Contents?: true

Size: 893 Bytes

Versions: 6

Compression:

Stored size: 893 Bytes

Contents

require 'spec_helper'
require 'shared_examples/calculator_shared_examples'

describe Spree::Calculator::DistributedAmount, type: :model do
  describe "#compute_line_item" do
    subject { calculator.compute_line_item(order.line_items.first) }

    let(:calculator) { Spree::Calculator::DistributedAmount.new }

    let(:order) do
      FactoryGirl.create(
        :order_with_line_items,
        line_items_attributes: [{ price: 50 }, { price: 50 }, { price: 50 }]
      )
    end

    before do
      calculator.preferred_amount = 15
      calculator.preferred_currency = currency
    end

    context "when the order currency matches the store's currency" do
      let(:currency) { "USD" }
      it { is_expected.to eq 5 }
    end

    context "when the order currency does not match the store's currency" do
      let(:currency) { "CAD" }
      it { is_expected.to eq 0 }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-2.3.1 spec/models/spree/calculator/distributed_amount_spec.rb
solidus_core-2.3.0 spec/models/spree/calculator/distributed_amount_spec.rb
solidus_core-2.3.0.rc3 spec/models/spree/calculator/distributed_amount_spec.rb
solidus_core-2.3.0.rc2 spec/models/spree/calculator/distributed_amount_spec.rb
solidus_core-2.3.0.rc1 spec/models/spree/calculator/distributed_amount_spec.rb
solidus_core-2.3.0.beta1 spec/models/spree/calculator/distributed_amount_spec.rb