Sha256: 093b8c2c02d2504aa249e38f156ffcd81ffe413dc2994f102bb95d004e1b1740

Contents?: true

Size: 1.13 KB

Versions: 21

Compression:

Stored size: 1.13 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
    without_partial_double_verification do
      allow(helper).to receive(:current_pricing_options) { pricing_options }
    end
  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

21 entries across 21 versions & 1 rubygems

Version Path
solidus_core-2.10.5 spec/helpers/taxons_helper_spec.rb
solidus_core-2.10.3 spec/helpers/taxons_helper_spec.rb
solidus_core-2.10.2 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.6 spec/helpers/taxons_helper_spec.rb
solidus_core-2.8.6 spec/helpers/taxons_helper_spec.rb
solidus_core-2.10.1 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.5 spec/helpers/taxons_helper_spec.rb
solidus_core-2.10.0 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.4 spec/helpers/taxons_helper_spec.rb
solidus_core-2.8.5 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.3 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.2 spec/helpers/taxons_helper_spec.rb
solidus_core-2.10.0.beta1 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.1 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.0 spec/helpers/taxons_helper_spec.rb
solidus_core-2.9.0.rc.1 spec/helpers/taxons_helper_spec.rb
solidus_core-2.8.4 spec/helpers/taxons_helper_spec.rb
solidus_core-2.8.3 spec/helpers/taxons_helper_spec.rb
solidus_core-2.8.2 spec/helpers/taxons_helper_spec.rb
solidus_core-2.8.1 spec/helpers/taxons_helper_spec.rb