Sha256: 8e0ee3ea95995407aad60f7a091873e9de74ae98a1bcf027d7733ad8ec333538

Contents?: true

Size: 1.08 KB

Versions: 27

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Spree::TaxonsHelper, type: :helper do
  let(:currency) { 'USD' }
  let(:pricing_options) do
    Spree::Config.pricing_options_class.new(currency: currency)
  end
  before do
    allow(helper).to receive(:current_pricing_options) { pricing_options }
  end

  describe "#taxon_preview" do
    let!(:taxon) { create(:taxon) }
    let!(:child_taxon) { create(:taxon, parent: taxon) }
    let!(:product_1) { create(:product) }
    let!(:product_2) { create(:product) }
    let!(:product_3) { create(:product) }

    before do
      taxon.products << product_1
      taxon.products << product_2
      child_taxon.products << product_3
      taxon.reload
    end

    # Regression test for https://github.com/spree/spree/issues/4382
    it "returns products" do
      expect(helper.taxon_preview(taxon)).to eql([product_1, product_2, product_3])
    end

    context "with different currency" do
      let(:currency) { 'CAD' }

      it "returns no products" do
        expect(helper.taxon_preview(taxon)).to be_empty
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
solidus_core-2.6.6 spec/helpers/taxons_helper_spec.rb
solidus_core-2.7.4 spec/helpers/taxons_helper_spec.rb
solidus_core-2.7.3 spec/helpers/taxons_helper_spec.rb
solidus_core-2.6.5 spec/helpers/taxons_helper_spec.rb
solidus_core-2.7.2 spec/helpers/taxons_helper_spec.rb
solidus_core-2.6.4 spec/helpers/taxons_helper_spec.rb
solidus_core-2.6.3 spec/helpers/taxons_helper_spec.rb
solidus_core-2.7.1 spec/helpers/taxons_helper_spec.rb
solidus_core-2.6.2 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.10 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.9 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.8 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.7 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.6 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.5 spec/helpers/taxons_helper_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.4 spec/helpers/taxons_helper_spec.rb