Sha256: 960b6bcff30769d75b0e7d5e427ef27b4946bdcb4496b51482abbc84e7f2c74f

Contents?: true

Size: 1.18 KB

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
spree-0.8.4 spec/helpers/spree/base_helper_spec.rb
spree-0.8.5 spec/helpers/spree/base_helper_spec.rb
spree-0.8.0 spec/helpers/spree/base_helper_spec.rb
spree-0.8.1 spec/helpers/spree/base_helper_spec.rb
spree-0.8.2 spec/helpers/spree/base_helper_spec.rb
spree-0.8.3 spec/helpers/spree/base_helper_spec.rb