Sha256: 10df037ffc2699d38e4aa4c899212ee6ea3cf13b2bf157fbac0772fac940dc3b

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Spree::Admin::PricesController do
  stub_authorization!

  let!(:product) { create(:product) }

  describe '#index' do
    context "when only given a product" do
      let(:product) { create(:product) }

      subject { spree_get :index, product_id: product.slug }

      it { is_expected.to be_success }

      it 'assigns usable instance variables' do
        subject
        expect(assigns(:search)).to be_a(Ransack::Search)
        expect(assigns(:prices)).to eq(product.prices)
        expect(assigns(:product)).to eq(product)
      end
    end

    context "when given a product and a variant" do
      let(:variant) { create(:variant) }
      let(:product) { variant.product }

      subject { spree_get :index, product_id: product.slug, variant_id: variant.id }

      it { is_expected.to be_success }

      it 'assigns usable instance variables' do
        subject
        expect(assigns(:search)).to be_a(Ransack::Search)
        expect(assigns(:prices)).to eq(product.prices)
        expect(assigns(:prices)).to include(variant.default_price)
        expect(assigns(:product)).to eq(product)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_backend-1.3.2 spec/controllers/spree/admin/prices_controller_spec.rb
solidus_backend-1.3.1 spec/controllers/spree/admin/prices_controller_spec.rb
solidus_backend-1.3.0 spec/controllers/spree/admin/prices_controller_spec.rb
solidus_backend-1.3.0.rc2 spec/controllers/spree/admin/prices_controller_spec.rb
solidus_backend-1.3.0.rc1 spec/controllers/spree/admin/prices_controller_spec.rb