mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Transpec specs
This commit is contained in:
@@ -24,7 +24,7 @@ describe Spree::Core::CalculatedAdjustments do
|
||||
let(:target) { order }
|
||||
|
||||
it "should be associated with the target" do
|
||||
target.adjustments.should_receive(:create)
|
||||
expect(target.adjustments).to receive(:create)
|
||||
tax_rate.create_adjustment("foo", target, order)
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ describe Spree::Core::CalculatedAdjustments do
|
||||
end
|
||||
|
||||
context "when the calculator returns 0" do
|
||||
before { calculator.stub(compute: 0) }
|
||||
before { allow(calculator).to receive_messages(compute: 0) }
|
||||
|
||||
context "when adjustment is mandatory" do
|
||||
before { tax_rate.create_adjustment("foo", target, order, true) }
|
||||
@@ -66,7 +66,7 @@ describe Spree::Core::CalculatedAdjustments do
|
||||
it "should update the adjustment using its calculator (and the specified source)" do
|
||||
adjustment = double(:adjustment).as_null_object
|
||||
calculable = double :calculable
|
||||
adjustment.should_receive(:update_column).with(:amount, 10)
|
||||
expect(adjustment).to receive(:update_column).with(:amount, 10)
|
||||
tax_rate.update_adjustment(adjustment, calculable)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,8 +12,8 @@ module Spree
|
||||
|
||||
context "init" do
|
||||
it "calls override!" do
|
||||
MailSettings.should_receive(:new).and_return(subject)
|
||||
subject.should_receive(:override!)
|
||||
expect(MailSettings).to receive(:new).and_return(subject)
|
||||
expect(subject).to receive(:override!)
|
||||
MailSettings.init
|
||||
end
|
||||
end
|
||||
@@ -80,7 +80,7 @@ module Spree
|
||||
|
||||
context "init" do
|
||||
it "doesnt calls override!" do
|
||||
subject.should_not_receive(:override!)
|
||||
expect(subject).not_to receive(:override!)
|
||||
MailSettings.init
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,8 +16,8 @@ describe Spree::Core::TokenResource do
|
||||
|
||||
context '#token' do
|
||||
it 'should return the token of the associated permission' do
|
||||
order.stub tokenized_permission: permission
|
||||
permission.stub token: 'foo'
|
||||
allow(order).to receive_messages tokenized_permission: permission
|
||||
allow(permission).to receive_messages token: 'foo'
|
||||
expect(order.token).to eq 'foo'
|
||||
end
|
||||
|
||||
|
||||
@@ -49,36 +49,36 @@ module Spree
|
||||
end
|
||||
|
||||
before do
|
||||
product.should_receive(:dup).and_return(new_product)
|
||||
variant.should_receive(:dup).and_return(new_variant)
|
||||
image.should_receive(:dup).and_return(new_image)
|
||||
property.should_receive(:dup).and_return(new_property)
|
||||
expect(product).to receive(:dup).and_return(new_product)
|
||||
expect(variant).to receive(:dup).and_return(new_variant)
|
||||
expect(image).to receive(:dup).and_return(new_image)
|
||||
expect(property).to receive(:dup).and_return(new_property)
|
||||
end
|
||||
|
||||
it "can duplicate a product" do
|
||||
duplicator = Spree::ProductDuplicator.new(product)
|
||||
new_product.should_receive(:name=).with("COPY OF foo")
|
||||
new_product.should_receive(:taxons=).with([])
|
||||
new_product.should_receive(:product_properties=).with([new_property])
|
||||
new_product.should_receive(:created_at=).with(nil)
|
||||
new_product.should_receive(:updated_at=).with(nil)
|
||||
new_product.should_receive(:deleted_at=).with(nil)
|
||||
new_product.should_receive(:master=).with(new_variant)
|
||||
expect(new_product).to receive(:name=).with("COPY OF foo")
|
||||
expect(new_product).to receive(:taxons=).with([])
|
||||
expect(new_product).to receive(:product_properties=).with([new_property])
|
||||
expect(new_product).to receive(:created_at=).with(nil)
|
||||
expect(new_product).to receive(:updated_at=).with(nil)
|
||||
expect(new_product).to receive(:deleted_at=).with(nil)
|
||||
expect(new_product).to receive(:master=).with(new_variant)
|
||||
|
||||
new_variant.should_receive(:sku=).with("COPY OF 12345")
|
||||
new_variant.should_receive(:deleted_at=).with(nil)
|
||||
new_variant.should_receive(:images=).with([new_image])
|
||||
new_variant.should_receive(:price=).with(variant.price)
|
||||
new_variant.should_receive(:currency=).with(variant.currency)
|
||||
expect(new_variant).to receive(:sku=).with("COPY OF 12345")
|
||||
expect(new_variant).to receive(:deleted_at=).with(nil)
|
||||
expect(new_variant).to receive(:images=).with([new_image])
|
||||
expect(new_variant).to receive(:price=).with(variant.price)
|
||||
expect(new_variant).to receive(:currency=).with(variant.currency)
|
||||
|
||||
image.attachment.should_receive(:clone).and_return(image.attachment)
|
||||
expect(image.attachment).to receive(:clone).and_return(image.attachment)
|
||||
|
||||
new_image.should_receive(:assign_attributes).
|
||||
expect(new_image).to receive(:assign_attributes).
|
||||
with(attachment: image.attachment).
|
||||
and_return(new_image)
|
||||
|
||||
new_property.should_receive(:created_at=).with(nil)
|
||||
new_property.should_receive(:updated_at=).with(nil)
|
||||
expect(new_property).to receive(:created_at=).with(nil)
|
||||
expect(new_property).to receive(:updated_at=).with(nil)
|
||||
|
||||
duplicator.duplicate
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user