summaryrefslogtreecommitdiff
path: root/spec/requests/carts_controller
diff options
context:
space:
mode:
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