diff --git a/engines/dfc_provider/spec/services/variant_fetcher_spec.rb b/engines/dfc_provider/spec/services/variant_fetcher_spec.rb new file mode 100644 index 0000000000..8a7adebc15 --- /dev/null +++ b/engines/dfc_provider/spec/services/variant_fetcher_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require DfcProvider::Engine.root.join("spec/spec_helper") + +describe VariantFetcher do + subject { VariantFetcher.new(enterprise) } + let(:enterprise) { build(:enterprise) } + let(:other_enterprise) { build(:enterprise) } + + it "returns an empty set" do + expect(subject.scope).to eq [] + end + + it "returns the variants of a supplier" do + product = create(:product, supplier: enterprise) + + pending "ignoring of the master variant" + # it currently returns two variants instead of one + expect(subject.scope.count).to eq 1 + expect(subject.scope).to eq product.variants + end + + it "ignores the variants of another enterprise" do + create(:product, supplier: other_enterprise) + + expect(subject.scope).to eq [] + end +end