summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-06 14:53:02 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-06 14:53:02 -0600
commit61110336bc5a924346f0654cb5bb812101c3bc7a (patch)
treed51511956e1246819c2480a4f3c30b6074bfe7ad /spec/requests
parentfc191f53503629087fd453e626ec2a4c58e0a21b (diff)
Añade specs de cxarts_controller
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/carts_controller/destroy_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/requests/carts_controller/destroy_spec.rb b/spec/requests/carts_controller/destroy_spec.rb
new file mode 100644
index 0000000..ce083ef
--- /dev/null
+++ b/spec/requests/carts_controller/destroy_spec.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'DELETE /api/account/cart/product_id', type: :request do
+ let(:user) { create(:user_account, role: 'regular') }
+ let(:product) { create(:product) }
+ let(:token) { jwt(user) }
+ let(:headers) { { 'Authorization' => "Bearer #{token['token']}" } }
+
+ before(:each) do
+ user.cart = Cart.create
+ user.cart.add_product(product.id, 1)
+ end
+
+ it_behaves_like 'a DELETE request' do
+ let(:product_not_in_cart) { create(:product) }
+ let(:resource) { "/api/account/cart/#{product.id}" }
+ let(:nonexistent_resource) { "/api/account/cart/#{product_not_in_cart.id}" }
+ end
+end