Sha256: 09d0b85cc92ca5ed2c5b434148e8cf87ff023f4d49a485eb05f8ff8f1902855e

Contents?: true

Size: 1.67 KB

Versions: 11

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

module Spree
  module Admin
    describe VariantsController, type: :controller do
      stub_authorization!

      describe "#index" do
        let(:product) { create(:product) }
        let(:params) { { product_id: product.slug } }

        subject { get :index, params: params }

        context "the value of @parent" do
          it "is the product" do
            subject
            expect(assigns(:parent)).to eq product
          end

          context "with a deleted product" do
            before { product.destroy! }

            it "is the product" do
              subject
              expect(assigns(:parent)).to eq product
            end
          end
        end

        context "the value of @collection" do
          let!(:variant) { create(:variant, product: product) }
          let!(:deleted_variant) { create(:variant, product: product) }

          context "with deleted variants" do
            before { deleted_variant.destroy }

            context "when deleted is not requested" do
              it "excludes deleted variants" do
                subject
                expect(assigns(:collection)).to include variant
                expect(assigns(:collection)).not_to include deleted_variant
              end
            end

            context "when deleted is requested" do
              let(:params) { { product_id: product.slug, deleted: "on" } }

              it "includes deleted variants" do
                subject
                expect(assigns(:collection)).to include variant
                expect(assigns(:collection)).to include deleted_variant
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
solidus_backend-2.4.2 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.4.1 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.3.1 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.4.0 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.4.0.rc1 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.4.0.beta1 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.3.0 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.3.0.rc3 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.3.0.rc2 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.3.0.rc1 spec/controllers/spree/admin/variants_controller_spec.rb
solidus_backend-2.3.0.beta1 spec/controllers/spree/admin/variants_controller_spec.rb