summaryrefslogtreecommitdiff
path: root/spec/requests/user_accounts_controller
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-06 11:04:41 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-06 11:04:41 -0600
commitef0bd5e3ebd3822eca1aa12fb9e347ad397a295b (patch)
treea8f29f59fe879df2b5b24773131f6575c076a84b /spec/requests/user_accounts_controller
parent111e93744aceb8a61c06dfa4d2d843544b7b1078 (diff)
Añadida creación de carrito a la hora de crearusuario
Diffstat (limited to 'spec/requests/user_accounts_controller')
-rw-r--r--spec/requests/user_accounts_controller/create_spec.rb18
1 files changed, 16 insertions, 2 deletions
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