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.

Admin: Ability to set property position

Damian Legawiecb5669a1970c2
diff --git a/admin/spec/controllers/spree/admin/properties_controller_spec.rb b/admin/spec/controllers/spree/admin/properties_controller_spec.rb
index f70c873ec1..b70b053633 100644
--- a/admin/spec/controllers/spree/admin/properties_controller_spec.rb
+++ b/admin/spec/controllers/spree/admin/properties_controller_spec.rb
@@ -16,4 +16,26 @@ describe Spree::Admin::PropertiesController, type: :controller do
expect(assigns(:collection).to_a).to eq([property])
end
end
+
+ describe '#create ' do
+ it 'creates a property' do
+ expect { post :create, params: {property: {name: 'New Property', presentation: 'New Presentation'}} }.to change(Spree::Property, :count).by(1)
+ end
+ end
+
+ describe '#update' do
+ let(:property) { create(:property) }
+
+ it 'updates the property' do
+ put :update, params: {id: property.id, property: { name: 'New Name'}}
+
+ expect(property.reload.name).to eq('new-name')
+ end
+
+ it 'can set property position' do
+ put :update, params: {id: property.id, property: { position: 2 }}
+
+ expect(property.reload.position).to eq(2)
+ end
+ end
end
diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb
index f7560cad2c..08c4f7ea69 100644
--- a/core/lib/spree/permitted_attributes.rb
+++ b/core/lib/spree/permitted_attributes.rb
@@ -101,7 +101,7 @@ module Spree
}
]
- @@property_attributes = [:name, :presentation]
+ @@property_attributes = [:name, :presentation, :position]
@@return_authorization_attributes = [:amount, :memo, :stock_location_id, :inventory_units_attributes,
:return_authorization_reason_id]