Sha256: 24f0a4784adea8a1bcd4aef6c8accd41c4e62f3d8cc61f3b5e4cffebff436f79

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Spree::Api::V1::ShipmentsController do
  let!(:shipment) { create(:shipment) }
  let!(:attributes) { [:id, :tracking, :number, :cost, :shipped_at] }

  before do
    Spree::Order.any_instance.stub(:paid? => true)
    stub_authentication!
  end

  context "working with a shipment" do
    let!(:resource_scoping) { { :order_id => shipment.order.to_param, :id => shipment.to_param } }

    it "can make a shipment ready" do
      api_put :ready
      json_response.should have_attributes(attributes)
      json_response["shipment"]["state"].should == "ready"
      shipment.reload.state.should == "ready"
    end

    context "can transition a shipment from ready to ship" do
      before do
        shipment.update!(shipment.order)
        shipment.state.should == "ready"
      end

      it "can transition a shipment from ready to ship" do
        shipment.reload
        api_put :ship, :order_id => shipment.order.to_param, :id => shipment.to_param, :shipment => { :tracking => "123123" }
        json_response.should have_attributes(attributes)
        json_response["shipment"]["state"].should == "shipped"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree_api-1.2.0 spec/controllers/spree/api/v1/shipments_controller_spec.rb
spree_api-1.2.0.rc2 spec/controllers/spree/api/v1/shipments_controller_spec.rb
spree_api-1.2.0.rc1 spec/controllers/spree/api/v1/shipments_controller_spec.rb
spree_api-1.1.3 spec/controllers/spree/api/v1/shipments_controller_spec.rb
spree_api-1.1.2 spec/controllers/spree/api/v1/shipments_controller_spec.rb
spree_api-1.1.2.rc1 spec/controllers/spree/api/v1/shipments_controller_spec.rb