Nest variant soft delete route under product resource

This commit is contained in:
Rohan Mitchell
2014-04-04 14:06:12 +11:00
parent e28a450875
commit e6d988ff34
3 changed files with 5 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
Spree::Api::VariantsController.class_eval do
def soft_delete
@variant = scope.find(params[:id])
@variant = scope.find(params[:variant_id])
authorize! :delete, @variant
@variant.deleted_at = Time.now()

View File

@@ -108,10 +108,10 @@ Spree::Core::Engine.routes.prepend do
resources :products do
get :managed, on: :collection
end
resources :variants do
delete :soft_delete
resources :variants do
delete :soft_delete
end
end
resources :orders do

View File

@@ -43,7 +43,7 @@ module Spree
product = create(:product)
variant = product.master
spree_delete :soft_delete, {id: variant.to_param, product_id: product.to_param, format: :json}
spree_delete :soft_delete, {variant_id: variant.to_param, product_id: product.to_param, format: :json}
response.status.should == 204
lambda { variant.reload }.should_not raise_error(ActiveRecord::RecordNotFound)
variant.deleted_at.should_not be_nil