Sha256: 858f127f97929879b43329b25d2e4daa61a9883396c7eb282ebf56cad11e93f3

Contents?: true

Size: 1.67 KB

Versions: 35

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

module Spree
  module Stock
    RSpec.describe ContentItem, type: :model do
      let(:instance) { ContentItem.new(inventory_unit, state) }
      let(:inventory_unit) { build(:inventory_unit) }
      let(:state) { :on_hand }

      describe '#variant' do
        subject { instance.variant }
        it { is_expected.to eq(inventory_unit.variant) }
      end

      describe '#weight' do
        subject { instance.weight }
        it { is_expected.to eq(0.to_d) }
      end

      describe '#line_item' do
        subject { instance.line_item }
        it { is_expected.to eq(inventory_unit.line_item) }
      end

      describe '#on_hand?' do
        subject { instance.on_hand? }

        context 'the state is on hand' do
          it { is_expected.to eq(true) }
        end

        context 'the state is not on hand' do
          let(:state) { 'foo' }
          it { is_expected.to eq(false) }
        end
      end

      describe '#backordered?' do
        subject { instance.backordered? }

        context 'the state is not backordered' do
          let(:state) { 'foo' }
          it { is_expected.to eq(false) }
        end

        context 'the state is backordered' do
          let(:state) { :backordered }
          it { is_expected.to eq(true) }
        end
      end

      describe '#price' do
        subject { instance.price }
        it { is_expected.to eq(10.to_d) }
      end

      describe '#amount' do
        subject { instance.amount }
        it { is_expected.to eq(10.to_d) }
      end

      describe '#quantity' do
        subject { instance.quantity }
        it { is_expected.to eq(1) }
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
solidus_core-2.8.0 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.10 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.9 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.8 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.7 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.6 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.5 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.4 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.3 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.1 spec/models/spree/stock/content_item_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.0 spec/models/spree/stock/content_item_spec.rb