# frozen_string_literal: true

require 'rails_helper'

module Spree
  module Stock
    module LocationFilter
      RSpec.describe Active, type: :model do
        subject { described_class.new(stock_locations, order) }

        let(:stock_locations) { instance_double('Spree::StockLocation::ActiveRecord_Relation') }
        let(:order) { instance_double('Spree::Order') }

        it 'returns only active stock locations' do
          active_stock_locations = instance_double('Spree::StockLocation::ActiveRecord_Relation')

          without_partial_double_verification do
            expect(stock_locations).to receive(:active) { active_stock_locations }
          end
          expect(subject.filter).to eq(active_stock_locations)
        end
      end
    end
  end
end

# frozen_string_literal: true

require 'rails_helper'

module Spree
  module Stock
    module LocationFilter
      RSpec.describe Active, type: :model do
        subject { described_class.new(stock_locations, order) }

        let!(:active_stock_location) { create(:stock_location) }
        let!(:inactive_stock_location) { create(:stock_location, active: false) }
        let(:stock_locations) { Spree::StockLocation.all }
        let(:order) { instance_double('Spree::Order') }

        it 'returns only active stock locations' do
          expect(subject.filter).to eq([active_stock_location])
        end
      end
    end
  end
end

Rewrite Stock Location Filter specs
Rewrite Stock Location Filter specs

In order to avoid stubbing the implementation. This could have benefits
in terms of speed but everything is more complex to read and
it's causing flaky specs in combination with verifying partial doubles.
