summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-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