summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-02-23 18:52:38 -0600
committerHombreLaser <sebastian-440@live.com>2023-02-23 18:52:38 -0600
commitea087f5bdc183b9c773979b795e366cc268aadaa (patch)
tree7ace77faec8b40799c543a8fa0de3658947f549c /spec
parent97ba3df5e5970d29064daf56309e73df85a70613 (diff)
Añade spec del controlador de autenticaciones
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/authentications_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb
new file mode 100644
index 0000000..2ee8ead
--- /dev/null
+++ b/spec/requests/authentications_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'Authentications', type: :request do
+ let(:user) { create(:user_account) }
+ let(:params) { { credentials: { email: user.email, password: user.password } } }
+ let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
+
+ describe 'POST /api/authenticate' do
+ scenario 'successfully' do
+ post('/api/authenticate', params: params.to_json, headers:)
+ expect(response).to have_http_status(200)
+ expect(response.body).to include('token')
+ expect(response.body).to include('refresh')
+ end
+
+ scenario 'unsuccessfully' do
+ params[:credentials][:password] = 'wrong_password'
+ post('/api/authenticate', params: params.to_json, headers:)
+ expect(response).to have_http_status(401)
+ expect(response.body).to include('Credenciales incorrectas')
+ end
+ end
+end