Sha256: b66a2f07b1b898b7ddacfb66d56f406bb5652bfb9a36b774b3059ece148f6d4e

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require_relative 'test_helper'

class SkuLocTest < Skr::TestCase

    def test_qty_locked
        sl = skr_sku_locs(:hatdefault)
        sl.qty=800
        assert_saves sl
        assert_equal 25, sl.reload.qty
    end


    def test_allocations
        sol = skr_so_lines(:first_string)
        sl = sol.sku_loc

        assert_equal 33, sl.qty_available
        refute sol.is_fully_allocated?, "test line is already allocated"
        sl.allocate_available_qty!
        sol.reload # <- needed because sku_loc allocations uses a scope
        assert sol.is_fully_allocated?, "failed to allocate test line"
        assert_equal 27, sl.reload.qty_available

        sol.update_attributes :qty_allocated => 0
        assert_equal 33, sl.reload.qty_available
    end

    def test_qty_event
        sl = skr_sku_locs(:hatdefault)
        assert_event_fires( SkuLoc, :qty_change ) do
            # NEVER do this directly - it will throw the MAC
            # and GL out off balance.  Instead use SkuTran
            sl.unlock_fields( :qty ) do
                sl.adjust_qty( 10 )
                assert_saves sl
            end
        end
        assert_equal [sl], last_event_results
    end

    def test_picking
        sl = skr_sku_locs(:stringdefault)
        sol = sl.so_lines.where( sku_loc: sl ).first
        sl.allocate_available_qty!
        pt = sol.sales_order.pick_tickets.build
        assert_difference 'sl.reload.qty_picking', 6 do
            assert_saves pt
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stockor-core-0.2 test/sku_loc_test.rb