Files
openfoodnetwork/spec/models/spree/order/address_spec.rb
Maikel Linke dcb6f4676d Remove all unnecessary spec_helper require statements
The `.rspec` file is doing this for us.
2026-01-21 12:35:34 +11:00

51 lines
1.2 KiB
Ruby

# frozen_string_literal: true
RSpec.describe Spree::Order do
let(:order) { Spree::Order.new }
context 'validation' do
context "when @use_billing is populated" do
before do
order.bill_address = build(:address)
order.ship_address = nil
end
context "with true" do
before { order.use_billing = true }
it "clones the bill address to the ship address" do
order.valid?
expect(order.ship_address).to eq order.bill_address
end
end
context "with 'true'" do
before { order.use_billing = 'true' }
it "clones the bill address to the shipping" do
order.valid?
expect(order.ship_address).to eq order.bill_address
end
end
context "with '1'" do
before { order.use_billing = '1' }
it "clones the bill address to the shipping" do
order.valid?
expect(order.ship_address).to eq order.bill_address
end
end
context "with something other than a 'truthful' value" do
before { order.use_billing = '0' }
it "does not clone the bill address to the shipping" do
order.valid?
expect(order.ship_address).to be_nil
end
end
end
end
end