Sha256: a7188d47e301644698f819377eb57bbd400cc0ba2b65fe2eb432cef7a0f5684b

Contents?: true

Size: 995 Bytes

Versions: 27

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'shared_examples/calculator_shared_examples'

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

  it_behaves_like 'a calculator with a description'

  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

27 entries across 27 versions & 2 rubygems

Version Path
solidus_core-2.6.6 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.7.4 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.7.3 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.6.5 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.7.2 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.6.4 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.6.3 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.7.1 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core-2.6.2 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.10 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.9 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.8 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.7 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.6 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.5 spec/models/spree/calculator/flat_percent_item_total_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.4 spec/models/spree/calculator/flat_percent_item_total_spec.rb