summaryrefslogtreecommitdiff
path: root/spec/requests/carts_controller/destroy_spec.rb
blob: ce083ef03ab1c957f9aa1692caaa448e325cd275 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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