summaryrefslogtreecommitdiff
path: root/spec/requests/user_accounts_controller
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-13 19:48:40 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-13 19:48:40 -0600
commit5c899df07753a31543f8dad725a26ccddc44dfe2 (patch)
treecc13040e9f859688ec2ec454486528394bbc1cde /spec/requests/user_accounts_controller
parent3dae1ce143d006cc75940b746a8eb74982e6e861 (diff)
Añade método update a UserAccountsController
Diffstat (limited to 'spec/requests/user_accounts_controller')
-rw-r--r--spec/requests/user_accounts_controller/create_user_accounts_spec.rb12
-rw-r--r--spec/requests/user_accounts_controller/update_user_accounts_spec.rb24
2 files changed, 30 insertions, 6 deletions
diff --git a/spec/requests/user_accounts_controller/create_user_accounts_spec.rb b/spec/requests/user_accounts_controller/create_user_accounts_spec.rb
index 3fd5990..a45e02b 100644
--- a/spec/requests/user_accounts_controller/create_user_accounts_spec.rb
+++ b/spec/requests/user_accounts_controller/create_user_accounts_spec.rb
@@ -4,18 +4,18 @@ require 'rails_helper'
RSpec.describe 'POST /api/user_accounts', type: :request do
it_behaves_like 'a POST request' do
- let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
+ let(:headers) { {} }
let(:route) { '/api/user_accounts' }
let(:expected_error_messages) do
- ["Password can't be blank", 'Email is invalid', "First name can't be blank", "Last name can't be blank" ]
+ ["Password can't be blank", 'Email is invalid', "First name can't be blank", "Last name can't be blank"]
end
let(:desired_error_status) { 422 }
let(:expected_text) { %w[token refresh] }
- let(:user) { create(:user_account) }
+ let(:user) { build(:user_account) }
let(:params) do
- JSON.generate({ email: user.email, password: user.password,
- first_name: user.first_name, last_name: user.last_name })
+ { email: user.email, password: user.password,
+ first_name: user.first_name, last_name: user.last_name }
end
- let(:wrong_params) { JSON.generate({ email: 'notanemail', password: '' }) }
+ let(:wrong_params) { { email: 'notanemail', password: '', first_name: '', last_name: '' } }
end
end
diff --git a/spec/requests/user_accounts_controller/update_user_accounts_spec.rb b/spec/requests/user_accounts_controller/update_user_accounts_spec.rb
new file mode 100644
index 0000000..ba9cc69
--- /dev/null
+++ b/spec/requests/user_accounts_controller/update_user_accounts_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'PUT /api/account', type: :request do
+ let(:user) { create(:user_account) }
+ let(:data) { build(:user_account) }
+ let(:token) { jwt(user) }
+
+ it_behaves_like 'a PUT request' do
+ let(:account) { true }
+ let(:route) { '/api/account' }
+ let(:headers) { { 'Authorization' => "Bearer #{token['token']}" } }
+ let(:params) do
+ { email: data.email, password: data.password, first_name: data.first_name, last_name: data.last_name }
+ end
+ let(:expected_text) { [] }
+ let(:desired_error_status) { 422 }
+ let(:wrong_params) { { email: 'notanemail', password: '', first_name: '', last_name: '' } }
+ let(:expected_error_messages) do
+ ["Password can't be blank", 'Email is invalid', "First name can't be blank", "Last name can't be blank"]
+ end
+ end
+end