Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Added `StockLocation#address` method and ability to add encryption (#12061)

Damian Legawiec3ca3e94ad375
diff --git a/core/app/models/spree/stock_location.rb b/core/app/models/spree/stock_location.rb
index 26b75c9ddf..af28e1820d 100644
--- a/core/app/models/spree/stock_location.rb
+++ b/core/app/models/spree/stock_location.rb
@@ -7,6 +7,9 @@ module Spree
if defined?(Spree::Security::StockLocations)
include Spree::Security::StockLocations
end
+ if defined?(Spree::Security::StockLocations)
+ include Spree::Security::StockLocations
+ end
if defined?(Spree::VendorConcern)
include Spree::VendorConcern
end
@@ -122,6 +125,20 @@ module Spree
end
end
+ def address
+ Spree::Address.new(
+ address1: address1,
+ address2: address2,
+ city: city,
+ state: state,
+ state: state,
+ state_name: state_name,
+ country: country,
+ zipcode: zipcode,
+ phone: phone
+ )
+ end
+
private
def create_stock_items
diff --git a/core/spec/models/spree/stock_location_spec.rb b/core/spec/models/spree/stock_location_spec.rb
index ee5b1ba2c7..485471165f 100644
--- a/core/spec/models/spree/stock_location_spec.rb
+++ b/core/spec/models/spree/stock_location_spec.rb
@@ -313,5 +313,11 @@ module Spree
it { expect { subject.update(name: 'my other warehouse').to change(variant, :updated_at) } }
end
end
+
+ describe '#address' do
+ it 'returns Spree::Address instance' do
+ expect(subject.address).to be_an_instance_of(Spree::Address)
+ end
+ end
end
end