Skip to content

Commit b8812a7

Browse files
committed
Rubocop offense
1 parent 8b673ea commit b8812a7

File tree

13 files changed

+3223
-778
lines changed

13 files changed

+3223
-778
lines changed

app/controllers/api/v1/users_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Api
44
module V1
55
class UsersController < ApplicationController
6-
skip_before_action :authenticate_user, only: [:create, :login, :verify]
6+
skip_before_action :authenticate_user, only: %i[create login verify]
77
before_action :set_user, only: [:update]
88

99
# serves as signup
@@ -19,7 +19,7 @@ def create
1919
def update
2020
authorize @user
2121
if @user.update(user_params)
22-
render json: { message: I18n.t('generic.update.success')}, status: :ok
22+
render json: { message: I18n.t('generic.update.success') }, status: :ok
2323
else
2424
render json: { errors: @user.error_string }, status: :unprocessable_entity
2525
end

app/controllers/application_controller.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@ def authenticate_user
2525
end
2626
end
2727

28-
def current_user
29-
@current_user
30-
end
28+
attr_reader :current_user
3129

3230
private
3331

3432
def record_not_found
35-
return render json: { errors: I18n.t('generic.record_not_found') }, status: :not_found
33+
render json: { errors: I18n.t('generic.record_not_found') }, status: :not_found
3634
end
3735

3836
def unauthorized_access
39-
return render json: { errors: I18n.t('authorization.error') }, status: :forbidden
37+
render json: { errors: I18n.t('authorization.error') }, status: :forbidden
4038
end
4139
end

app/interactors/user/add_to_system.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# frozen_string_literal: true
22

3-
class User::AddToSystem
4-
include Interactor::Organizer
3+
module User
4+
class AddToSystem
5+
include Interactor::Organizer
56

6-
organize User::Create, Mail::VerifyUser
7+
organize User::Create, Mail::VerifyUser
8+
end
79
end

app/interactors/user/create.rb

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# frozen_string_literal: true
22

3-
class User::Create
4-
include Interactor
3+
module User
4+
class Create
5+
include Interactor
56

6-
def call
7-
params = context.params.merge(
8-
reset_password_token: SecureRandom.urlsafe_base64,
9-
reset_password_sent_at: Time.now
10-
)
11-
user = User.new(params)
12-
if user.save
13-
context.user = user
14-
else
15-
context.fail!(error: { errors: user.error_string })
7+
def call
8+
params = context.params.merge(
9+
reset_password_token: SecureRandom.urlsafe_base64,
10+
reset_password_sent_at: Time.now
11+
)
12+
user = User.new(params)
13+
if user.save
14+
context.user = user
15+
else
16+
context.fail!(error: { errors: user.error_string })
17+
end
1618
end
1719
end
1820
end

app/policies/user_policy.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# frozen_string_literal: true
2+
13
class UserPolicy < ApplicationPolicy
24
def update?
35
user.id == record.id
46
end
5-
end
7+
end

config/application.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require_relative 'boot'
4-
require_relative '../lib/health_check/middleware_healthcheck'
54

65
require 'rails/all'
76

@@ -25,7 +24,6 @@ class Application < Rails::Application
2524
# Only loads a smaller set of middleware suitable for API only apps.
2625
# Middleware like session, flash, cookies can be added back manually.
2726
# Skip views, helpers and assets when generating a new resource.
28-
# config.middleware.insert_after Rails::Rack::Logger, MiddlewareHealthcheck
2927
config.api_only = true
3028
config.active_job.queue_adapter = :good_job
3129
end

config/environments/test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
config.active_job.queue_adapter = :good_job
3333
config.good_job.execution_mode = :inline
34-
34+
3535
# Raise exceptions instead of rendering exception templates.
3636
config.action_dispatch.show_exceptions = false
3737

coverage/.last_run.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"result": {
3-
"line": 89.0
3+
"line": 93.93
44
}
55
}

0 commit comments

Comments
 (0)