Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added location_filter_class as a writable attribute #3330

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/lib/spree/core/stock_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Core
class StockConfiguration
attr_writer :coordinator_class
attr_writer :estimator_class
attr_writer :location_filter_class
attr_writer :location_sorter_class
attr_writer :allocator_class

Expand Down
36 changes: 36 additions & 0 deletions core/spec/lib/spree/core/stock_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@
end
end

describe '#location_filter_class' do
let(:stock_configuration) { described_class.new }
subject { stock_configuration.location_filter_class }

it "returns Spree::Stock::LocationFilter::Active" do
is_expected.to be ::Spree::Stock::LocationFilter::Active
end

context "with another constant name assiged" do
MyFilter = Class.new
before { stock_configuration.location_filter_class = MyFilter.to_s }

it "returns the constant" do
is_expected.to be MyFilter
end
end
end

describe '#location_sorter_class' do
let(:stock_configuration) { described_class.new }
subject { stock_configuration.location_sorter_class }
Expand All @@ -56,4 +74,22 @@
end
end
end

describe '#allocator_class' do
let(:stock_configuration) { described_class.new }
subject { stock_configuration.allocator_class }

it "returns Spree::Stock::Allocator::OnHandFirst" do
is_expected.to be ::Spree::Stock::Allocator::OnHandFirst
end

context "with another constant name assiged" do
MyAllocator = Class.new
before { stock_configuration.allocator_class = MyAllocator.to_s }

it "returns the constant" do
is_expected.to be MyAllocator
end
end
end
end