File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
api/spec/requests/spree/api Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ module Spree::Api
6565 expect ( json_response [ 'stock_item_id' ] ) . to eq stock_movement . stock_item_id
6666 end
6767
68+ it 'can view admin metadata' do
69+ get spree . api_stock_location_stock_movement_path ( stock_location , stock_movement )
70+
71+ expect ( json_response ) . to have_attributes ( attributes )
72+ expect ( json_response [ 'stock_item_id' ] ) . to eq stock_movement . stock_item_id
73+ expect ( json_response ) . to have_key ( 'admin_metadata' )
74+ end
75+
6876 it 'can create a new stock movement' do
6977 params = {
7078 stock_movement : {
@@ -76,6 +84,21 @@ module Spree::Api
7684 expect ( response . status ) . to eq ( 201 )
7785 expect ( json_response ) . to have_attributes ( attributes )
7886 end
87+
88+ it 'can create a new stock movement with admin metadata' do
89+ params = {
90+ stock_movement : {
91+ stock_item_id : stock_item . to_param ,
92+ admin_metadata : { 'is_deadstock' => 'true' }
93+ }
94+ }
95+
96+ post ( spree . api_stock_location_stock_movements_path ( stock_location ) , params :)
97+
98+ expect ( response . status ) . to eq ( 201 )
99+ expect ( json_response ) . to have_attributes ( attributes )
100+ expect ( json_response [ "admin_metadata" ] ) . to eq ( { 'is_deadstock' => 'true' } )
101+ end
79102 end
80103 end
81104end
Original file line number Diff line number Diff line change 5959 end
6060 end
6161 end
62+
63+ describe "metadata fields" do
64+ it "responds to customer_metadata" do
65+ expect ( subject ) . to respond_to ( :customer_metadata )
66+ end
67+
68+ it "responds to admin_metadata" do
69+ expect ( subject ) . to respond_to ( :admin_metadata )
70+ end
71+
72+ it "can store data in customer_metadata" do
73+ subject . customer_metadata = { "movement_reason" => "restock" }
74+ expect ( subject . customer_metadata [ "movement_reason" ] ) . to eq ( "restock" )
75+ end
76+
77+ it "can store data in admin_metadata" do
78+ subject . admin_metadata = { "internal_note" => "Inventory verified" }
79+ expect ( subject . admin_metadata [ "internal_note" ] ) . to eq ( "Inventory verified" )
80+ end
81+ end
6282end
You can’t perform that action at this time.
0 commit comments