Sha256: 6ffbbce176b95ac5fcde597de04b3032e7d89f0537c75754158dbc9f99a12525

Contents?: true

Size: 854 Bytes

Versions: 32

Compression:

Stored size: 854 Bytes

Contents

require 'spec_helper'

describe Spree::Calculator::FlatPercentItemTotal, :type => :model do
  let(:calculator) { Spree::Calculator::FlatPercentItemTotal.new }
  let(:line_item) { mock_model Spree::LineItem }

  before { allow(calculator).to receive_messages preferred_flat_percent: 10 }

  context "compute" do
    it "should round result correctly" do
      allow(line_item).to receive_messages amount: 31.08
      expect(calculator.compute(line_item)).to eq 3.11

      allow(line_item).to receive_messages amount: 31.00
      expect(calculator.compute(line_item)).to eq 3.10
    end

    it 'returns object.amount if computed amount is greater' do
      allow(calculator).to receive_messages preferred_flat_percent: 110
      allow(line_item).to receive_messages amount: 30.00

      expect(calculator.compute(line_item)).to eq 30.0
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
solidus_core-1.2.3 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-1.1.4 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-1.0.7 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.5 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.4 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.3 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.2 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.0.10 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.1 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.0 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.0.rc4 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.0.9 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.0.rc3 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.0.rc2 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.1.0.rc1 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-1.0.6 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.0.8 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-1.2.2 spec/models/spree/calculator/flat_percent_item_total_spec.rb
spree_core-3.0.7 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-1.2.1 spec/models/spree/calculator/flat_percent_item_total_spec.rb