Sha256: 4d0dcb065e1c9d94f01331a33bb4d9688ceb6ee251f97a8e18618177c187def1

Contents?: true

Size: 996 Bytes

Versions: 13

Compression:

Stored size: 996 Bytes

Contents

require 'spec_helper'

describe Spree::Api::LineItemsController do

  before(:each) do
    stub_authentication!
  end

  describe "POST create" do
    let(:user) { create(:user) }
    let(:current_api_user) { user }
    let(:order) { create(:order, user: user) }
    let(:line_item) { build(:line_item, order: order) }

    subject { spree_post :create, line_item: line_item, order_id: line_item.order.number }

    context "A SpreeMultiDomain::LineItemDecorator::ProductDoesNotBelongToStoreError is raised" do
      before(:each) do
        def controller.create
          raise SpreeMultiDomain::LineItemConcerns::ProductDoesNotBelongToStoreError
        end
      end

      it "sets the correct status" do
        subject
        expect(response.status).to eq 422
      end

      it "contains the correct error message" do
        subject
        expect(JSON.parse(response.body)["message"]).to eq "Products from different stores may not be added to this order."
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
solidus_multi_domain-1.5.0 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.4.3 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.4.2 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.4.1 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.4.0 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.3.0 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.2.0 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.1.3 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.1.2 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.1.1 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.0.3 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.1.0 spec/controllers/spree/api/line_items_controller_spec.rb
solidus_multi_domain-1.0.1 spec/controllers/spree/api/line_items_controller_spec.rb