Sha256: c596362757ea0f65e9ea52c4c609426dc378de5ffe46604772ef63ff0c91bfec

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

module Spree
  RSpec.describe Variant do
    let(:product) do
      Product.create!(
        name: 'mobility',
        price: 19.99,
        shipping_category: ShippingCategory.create!(name: 'a')
      )
    end

    let!(:variant) do
      Variant.create!(
        price: 19.99,
        product: product
      )
    end

    # this test is invalid, should be removed or changed
    #  see https://github.com/spree-contrib/spree_mobility/commit/87802a97c8ee82f5444243467faf2a8faa8236f6#commitcomment-12963401
    xit 'fetches variant from product via translation table' do
      product_relation = Product.where(name: "mobility")
      variant_relation = described_class.joins(:product).merge(product_relation)
      described_class.includes(:product).ransack(name_cont: 'mobility').result.to_a

      expect(variant_relation.last).to eq variant

      variants = described_class.includes(:product).ransack(name_cont: 'mobility').result.to_a
      expect(variants.last).to eq variant
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_mobility-1.4.0 spec/models/variant_spec.rb
spree_mobility-1.3.0 spec/models/variant_spec.rb
spree_mobility-1.2.0 spec/models/variant_spec.rb
spree_mobility-1.1.0 spec/models/variant_spec.rb
spree_mobility-1.0.0 spec/models/variant_spec.rb