summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-03 20:58:25 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-03 20:58:25 -0600
commit898d91cca5721db785e991e0eab9f05010925b1a (patch)
tree46f8733de6fffabdd92c152308d0aee27f2d2d8e
parente3b19598c75790758995f9db206427135d6851c2 (diff)
Reacomoda directorio de specs
-rw-r--r--app/controllers/concerns/token_generation_concern.rb23
-rw-r--r--spec/controllers/authentications_controller_spec.rb8
-rw-r--r--spec/requests/refresh_tokens_controller/post_refresh_tokens_controller_spec.rb (renamed from spec/requests/post_refresh_tokens_spec.rb)0
-rw-r--r--spec/requests/sessions_controller/post_sessions_controller_spec.rb (renamed from spec/requests/authentications_spec.rb)4
-rw-r--r--spec/requests/user_accounts_controller/post_user_accounts_spec.rb (renamed from spec/requests/post_user_accounts_spec.rb)0
-rw-r--r--spec/support/shared_examples/requests/delete_request.rb5
6 files changed, 7 insertions, 33 deletions
diff --git a/app/controllers/concerns/token_generation_concern.rb b/app/controllers/concerns/token_generation_concern.rb
deleted file mode 100644
index beab467..0000000
--- a/app/controllers/concerns/token_generation_concern.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-# Common logic for all the logics that require the token generation
-# service.
-module TokenGenerationConcern
- extend ActiveSupport::Concern
-
- def service
- @service ||= Services::TokenGenerationService.new(service_params)
- end
-
- def generate_user_session_key(user)
- user.update_attribute(:session_key, SecureRandom.hex(16))
- end
-
- def generate_token
- { token: service.call(DateTime.current + 30.minutes), refresh: service.call(DateTime.current + 3.days) }
- end
-
- def service_params
- { email: @user_account.email, role: @user_account.role, session_key: @user_account.session_key }
- end
-end
diff --git a/spec/controllers/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb
deleted file mode 100644
index 43e7439..0000000
--- a/spec/controllers/authentications_controller_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-RSpec.describe Api::AuthenticationsController, type: :controller do
- it { should route(:post, '/api/authenticate').to(action: :create) }
- it { should route(:delete, '/api/logout').to(action: :destroy) }
-end
diff --git a/spec/requests/post_refresh_tokens_spec.rb b/spec/requests/refresh_tokens_controller/post_refresh_tokens_controller_spec.rb
index 5d8f8f0..5d8f8f0 100644
--- a/spec/requests/post_refresh_tokens_spec.rb
+++ b/spec/requests/refresh_tokens_controller/post_refresh_tokens_controller_spec.rb
diff --git a/spec/requests/authentications_spec.rb b/spec/requests/sessions_controller/post_sessions_controller_spec.rb
index 6b33402..31cef31 100644
--- a/spec/requests/authentications_spec.rb
+++ b/spec/requests/sessions_controller/post_sessions_controller_spec.rb
@@ -2,10 +2,10 @@
require 'rails_helper'
-RSpec.describe 'POST /api/authenticate', type: :request do
+RSpec.describe 'POST /api/login', type: :request do
it_behaves_like 'a POST request' do
let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
- let(:route) { '/api/authenticate' }
+ let(:route) { '/api/login' }
let(:expected_error_messages) { ['Credenciales incorrectas'] }
let(:desired_error_status) { 401 }
let(:expected_text) { %w[token refresh] }
diff --git a/spec/requests/post_user_accounts_spec.rb b/spec/requests/user_accounts_controller/post_user_accounts_spec.rb
index 7c5aacc..7c5aacc 100644
--- a/spec/requests/post_user_accounts_spec.rb
+++ b/spec/requests/user_accounts_controller/post_user_accounts_spec.rb
diff --git a/spec/support/shared_examples/requests/delete_request.rb b/spec/support/shared_examples/requests/delete_request.rb
new file mode 100644
index 0000000..ea921ea
--- /dev/null
+++ b/spec/support/shared_examples/requests/delete_request.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'a DELETE request' do
+ let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
+end