From ef0bd5e3ebd3822eca1aa12fb9e347ad397a295b Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 6 Apr 2023 11:04:41 -0600 Subject: Añadida creación de carrito a la hora de crearusuario MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/requests/user_accounts_controller/create_spec.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'spec/requests/user_accounts_controller') diff --git a/spec/requests/user_accounts_controller/create_spec.rb b/spec/requests/user_accounts_controller/create_spec.rb index 7b70268..61ba5b4 100644 --- a/spec/requests/user_accounts_controller/create_spec.rb +++ b/spec/requests/user_accounts_controller/create_spec.rb @@ -3,19 +3,33 @@ require 'rails_helper' RSpec.describe 'POST /api/user_accounts', type: :request do + let(:user) { build(:user_account) } + let(:route) { '/api/user_accounts' } + let(:params) do + { email: user.email, password: user.password, + first_name: user.first_name, last_name: user.last_name } + end + it_behaves_like 'a POST request' do let(:headers) { {} } - let(:route) { '/api/user_accounts' } let(:expected_error_messages) do ["can't be blank", 'is invalid', "can't be blank", "can't be blank"] end let(:desired_error_status) { 422 } let(:expected_text) { %w[token refresh] } - let(:user) { build(:user_account) } let(:params) do { email: user.email, password: user.password, first_name: user.first_name, last_name: user.last_name } end let(:wrong_params) { { email: 'notanemail', password: '', first_name: '', last_name: '' } } end + + context 'after creating a user' do + it 'should create a cart belonging to him' do + post(route, params:) + created_user = UserAccount.find_by(email: user.email) + expect { Cart.find(created_user.cart_id) }.not_to raise_error + 2 + 2 + end + end end -- cgit v1.2.3