Sha256: ae9bb84ecf034511590215e22ecdffe8364685887852f0884e080d64e1feeee8
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true require 'spec_helper' module Spree describe InventoryUnit do subject { described_class.create!(attributes) } let!(:order) { create(:order_with_line_items) } let(:line_item) { order.line_items.first } let(:product) { line_item.product } let(:shipment) { create(:shipment, order: order) } if Spree.solidus_gem_version < Gem::Version.new('2.5.x') let(:attributes) { { shipment: shipment, line_item: line_item, variant: line_item.variant, order: order } } else let(:attributes) { { shipment: shipment, line_item: line_item, variant: line_item.variant } } end context 'if the unit is not part of an assembly' do it 'will return the percentage of a line item' do expect(subject.percentage_of_line_item).to eql(BigDecimal(1)) end end context 'if part of an assembly' do let(:parts) { (1..2).map { create(:variant) } } before do product.parts << parts order.create_proposed_shipments end it 'will return the percentage of a line item' do subject.line_item = line_item expect(subject.percentage_of_line_item).to eql(BigDecimal(0.5, 2)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_product_assembly-1.4.0 | spec/models/spree/inventory_unit_spec.rb |
solidus_product_assembly-1.3.0 | spec/models/spree/inventory_unit_spec.rb |