Sha256: 910803c93be8d9cb8bb3f23ec243c04079d2334e8948dbfea435653681a3b50e

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

describe Spree::BaseHelper do

  before(:each) do 
    @variant = mock_model(Variant, :option_values => [], :null_object => true)
    @variant.should_receive(:in_stock).and_return(false)
  end
  describe "variant_options" do
    describe "with :allow_backorders => true" do
      before(:each) { Spree::Config.stub!(:[]).with(:allow_backorders).and_return(true) }
      it "should not mention 'out of stock'" do
        helper.variant_options(@variant).should_not include("OUT OF STOCK")
      end
      it "should mention 'out of stock' when passing allow_back_orders = false" do
        helper.variant_options(@variant, false).should include("OUT OF STOCK")
      end
    end

    describe "with :allow_backorders => false" do
      before(:each) { Spree::Config.stub!(:[]).with(:allow_backorders).and_return(false) }    
      it "should mention 'out of stock'" do
        helper.variant_options(@variant).should include("OUT OF STOCK")        
      end
      it "should not mention 'out of stock' when passing allow_back_orders = true" do
        helper.variant_options(@variant, true).should_not include("OUT OF STOCK")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree-0.4.0 spec/helpers/spree/base_helper_spec.rb
spree-0.4.1 spec/helpers/spree/base_helper_spec.rb
spree-0.5.0 spec/helpers/spree/base_helper_spec.rb
spree-0.6.0 spec/helpers/spree/base_helper_spec.rb
spree-0.5.1 spec/helpers/spree/base_helper_spec.rb
spree-0.7.0 spec/helpers/spree/base_helper_spec.rb
spree-0.7.1 spec/helpers/spree/base_helper_spec.rb