Sha256: 23c062c13b37a53a301ac8869a53a9f2ba91960502dc80948daf7d8cda8177ca

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe Spree::LineItem do
  describe "before create" do

    let(:order_store) { create(:store) }
    let(:other_store) { create(:store) }
    let(:order)       { create(:order, store: order_store) }
    let(:variant)     { create(:variant, product: product) }
    let(:line_item)   { build(:line_item, order: order, product: product) }

    subject { line_item.save! }

    context "the order does not have a store" do
      before(:each) { order.update_attributes(store_id: nil) }
      let(:product) { create(:product, stores: [order_store])}

      it 'does not raise an error' do
        expect{ subject }.to_not raise_error
      end
    end

    context "the line item's product does not belong to the order's store" do
      let(:product) { create(:product, stores: [other_store]) }

      it 'raises the correct error' do
        expect{ subject }.to raise_error(SpreeMultiDomain::LineItemConcerns::ProductDoesNotBelongToStoreError)
      end
    end

    context "the line item's product belongs to the order's store" do
      let(:product) { create(:product, stores: [order_store])}

      it "does not raise an error" do
        expect{ subject }.to_not raise_error
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
solidus_multi_domain-1.4.0 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.3.0 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.2.0 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.1.3 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.1.2 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.1.1 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.0.3 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.1.0 spec/models/spree/line_item_spec.rb
solidus_multi_domain-1.0.1 spec/models/spree/line_item_spec.rb