summaryrefslogtreecommitdiff
path: root/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb')
-rw-r--r--app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb b/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb
index 7221b7b..15d35d0 100644
--- a/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb
+++ b/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb
@@ -8,7 +8,7 @@ module SolidusSubscriptions
wrap_parameters :subscription_line_item
def update
- authorize! :update, @line_item
+ authorize! :update, @line_item, subscription_guest_token
if @line_item.update(line_item_params)
render json: @line_item.to_json
else
@@ -17,11 +17,13 @@ module SolidusSubscriptions
end
def destroy
- authorize! :destroy, @line_item
- return render json: {}, status: :bad_request if @line_item.order.complete?
+ authorize! :destroy, @line_item, subscription_guest_token
@line_item.destroy!
- @line_item.order.recalculate
+
+ if @line_item.order && !@line_item.order.complete?
+ @line_item.order.recalculate
+ end
render json: @line_item.to_json
end