summaryrefslogtreecommitdiff
path: root/spec/requests/carts_controller
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-11 19:38:39 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-11 19:38:39 -0600
commitbb9554c298a5edc6c0ff90ec7497adff299891e0 (patch)
tree2ac9a09a1912d08e60f6d7c890abfc694d84e3fd /spec/requests/carts_controller
parent4611fdd6da7f9a1cc04144104e5ca26398f1b502 (diff)
Añade spec de show cart
Diffstat (limited to 'spec/requests/carts_controller')
-rw-r--r--spec/requests/carts_controller/show_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/requests/carts_controller/show_spec.rb b/spec/requests/carts_controller/show_spec.rb
new file mode 100644
index 0000000..b8a59ce
--- /dev/null
+++ b/spec/requests/carts_controller/show_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'GET /api/account/cart', type: :request do
+ let(:user) { create(:user_account) }
+ let(:token) { jwt(user) }
+ let(:headers) { { 'Authorization' => "Bearer #{token['token']}" } }
+ let(:product) { create(:product) }
+
+ before(:each) do
+ cart = Cart.new(user_account_id: user.id)
+ cart.save
+ user.cart = cart
+ user.save
+ user.cart.add_product(product.id, 1)
+ user.cart.save
+ end
+
+ it_behaves_like 'a GET resource request', sole_route: true do
+ let(:route) { '/api/account/cart' }
+ let(:expected_text) do
+ [product.name, product.bulk_price.to_i, product.unitary_price.to_i, user.cart.product_carts.first.quantity]
+ end
+ end
+end