Relocate specs for #provided_by_order_cycle? method extracted from Order class to service

This commit is contained in:
Matt-Yorkley
2021-01-28 23:11:54 +00:00
parent dffa4d4f39
commit b2b6d3ab87
2 changed files with 20 additions and 28 deletions

View File

@@ -588,34 +588,6 @@ describe Spree::Order do
end
end
describe "looking up whether a line item can be provided by an order cycle" do
it "returns true when the variant is provided" do
v = double(:variant)
line_item = double(:line_item, variant: v)
order_cycle = double(:order_cycle, variants: [v])
allow(subject).to receive(:order_cycle) { order_cycle }
expect(subject.send(:provided_by_order_cycle?, line_item)).to be true
end
it "returns false otherwise" do
v = double(:variant)
line_item = double(:line_item, variant: v)
order_cycle = double(:order_cycle, variants: [])
allow(subject).to receive(:order_cycle) { order_cycle }
expect(subject.send(:provided_by_order_cycle?, line_item)).to be false
end
it "returns false when there is no order cycle" do
v = double(:variant)
line_item = double(:line_item, variant: v)
allow(subject).to receive(:order_cycle) { nil }
expect(subject.send(:provided_by_order_cycle?, line_item)).to be false
end
end
describe "getting the admin and handling charge" do
let(:o) { create(:order) }
let(:li) { create(:line_item, order: o) }

View File

@@ -38,4 +38,24 @@ describe OrderFeesHandler do
service.create_order_fees!
end
end
context "checking if a line item can be provided by the order cycle" do
it "returns true when the variant is provided" do
allow(order_cycle).to receive(:variants) { [line_item.variant] }
expect(service.__send__(:provided_by_order_cycle?, line_item)).to be true
end
it "returns false otherwise" do
allow(order_cycle).to receive(:variants) { [] }
expect(service.__send__(:provided_by_order_cycle?, line_item)).to be false
end
it "returns false when there is no order cycle" do
allow(order).to receive(:order_cycle) { nil }
expect(service.__send__(:provided_by_order_cycle?, line_item)).to be false
end
end
end