From bb9554c298a5edc6c0ff90ec7497adff299891e0 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 11 Apr 2023 19:38:39 -0600 Subject: AƱade spec de show cart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/requests/carts_controller/show_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/requests/carts_controller/show_spec.rb (limited to 'spec/requests/carts_controller') 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 -- cgit v1.2.3