Sha256: 9a7d0a7886c98ac3af7e96670b5f1929b0391eb11f61265f2a6154974a9f0ba0
Contents?: true
Size: 1.52 KB
Versions: 6
Compression:
Stored size: 1.52 KB
Contents
require 'spec_helper' module Spree describe StockTransfer, type: :model do let(:destination_location) { create(:stock_location_with_items) } let(:source_location) { create(:stock_location_with_items) } let(:stock_item) { source_location.stock_items.order(:id).first } let(:variant) { stock_item.variant } subject { StockTransfer.create(reference: 'PO123') } describe '#reference' do subject { super().reference } it { is_expected.to eq 'PO123' } end describe '#to_param' do subject { super().to_param } it { is_expected.to match /T\d+/ } end it 'transfers variants between 2 locations' do variants = { variant => 5 } subject.transfer(source_location, destination_location, variants) expect(source_location.count_on_hand(variant)).to eq 5 expect(destination_location.count_on_hand(variant)).to eq 5 expect(subject.source_location).to eq source_location expect(subject.destination_location).to eq destination_location expect(subject.source_movements.first.quantity).to eq -5 expect(subject.destination_movements.first.quantity).to eq 5 end it 'receive new inventory (from a vendor)' do variants = { variant => 5 } subject.receive(destination_location, variants) expect(destination_location.count_on_hand(variant)).to eq 5 expect(subject.source_location).to be_nil expect(subject.destination_location).to eq destination_location end end end
Version data entries
6 entries across 6 versions & 1 rubygems