Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Simon Sölder
CodeBunker
Commits
32ecc3ce
Commit
32ecc3ce
authored
Mar 09, 2021
by
simon
Browse files
Add rubocop auto-corrections
parent
325ea214
Changes
11
Hide whitespace changes
Inline
Side-by-side
app/controllers/conversations_controller.rb
View file @
32ecc3ce
# frozen_string_literal: true
# this controller handles conversations
class
ConversationsController
<
ApplicationController
before_action
:set_conversation
,
only:
%w[show create new]
...
...
app/controllers/users/registrations_controller.rb
View file @
32ecc3ce
# frozen_string_literal: true
# inherits from Devise::RegistrationsController and allows registration with username param
class
Users::RegistrationsController
<
Devise
::
RegistrationsController
before_action
:configure_sign_up_params
,
only:
[
:create
]
before_action
:configure_account_update_params
,
only:
[
:update
]
module
Users
class
RegistrationsController
<
Devise
::
RegistrationsController
before_action
:configure_sign_up_params
,
only:
[
:create
]
before_action
:configure_account_update_params
,
only:
[
:update
]
# GET /resource/sign_up
# def new
# super
# end
# GET /resource/sign_up
# def new
# super
# end
# POST /resource
# def create
# super
# end
# POST /resource
# def create
# super
# end
# GET /resource/edit
# def edit
# super
# end
# GET /resource/edit
# def edit
# super
# end
# PUT /resource
# def update
# self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
# prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
# PUT /resource
# def update
# self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
# prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
# resource_updated = update_resource(resource, account_update_params)
# yield resource if block_given?
# if resource_updated
# set_flash_message_for_update(resource, prev_unconfirmed_email)
# bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?
# resource_updated = update_resource(resource, account_update_params)
# yield resource if block_given?
# if resource_updated
# set_flash_message_for_update(resource, prev_unconfirmed_email)
# bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?
# respond_with resource, location: after_update_path_for(resource)
# else
# clean_up_passwords resource
# set_minimum_password_length
# respond_with resource
# end
# end
# respond_with resource, location: after_update_path_for(resource)
# else
# clean_up_passwords resource
# set_minimum_password_length
# respond_with resource
# end
# end
# DELETE /resource
# def destroy
# super
# end
# DELETE /resource
# def destroy
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
protected
protected
# If you have extra params to permit, append them to the sanitizer.
def
configure_sign_up_params
devise_parameter_sanitizer
.
permit
(
:sign_up
,
keys:
[
:username
])
end
# If you have extra params to permit, append them to the sanitizer.
def
configure_sign_up_params
devise_parameter_sanitizer
.
permit
(
:sign_up
,
keys:
[
:username
])
end
# If you have extra params to permit, append them to the sanitizer.
def
configure_account_update_params
devise_parameter_sanitizer
.
permit
(
:account_update
,
keys:
%i[username avatar]
)
end
# If you have extra params to permit, append them to the sanitizer.
def
configure_account_update_params
devise_parameter_sanitizer
.
permit
(
:account_update
,
keys:
%i[username avatar]
)
end
def
after_update_path_for
(
resource
)
sign_in_after_change_password?
?
user_path
(
resource
)
:
new_session_path
(
resource_name
)
end
def
after_update_path_for
(
resource
)
sign_in_after_change_password?
?
user_path
(
resource
)
:
new_session_path
(
resource_name
)
end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
#
def
update_resource
(
resource
,
params
)
resource
.
update_without_password
(
params
)
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
#
def
update_resource
(
resource
,
params
)
resource
.
update_without_password
(
params
)
end
end
end
app/controllers/users_controller.rb
View file @
32ecc3ce
# frozen_string_literal: true
class
UsersController
<
ApplicationController
before_action
:set_user
,
only:
%w[show update]
...
...
app/helpers/conversation_helper.rb
View file @
32ecc3ce
# frozen_string_literal: true
module
ConversationHelper
end
app/helpers/users_helper.rb
View file @
32ecc3ce
# frozen_string_literal: true
module
UsersHelper
def
own_profile?
(
user
)
true
if
current_user
==
user
...
...
app/models/conversation.rb
View file @
32ecc3ce
# frozen_string_literal: true
class
Conversation
<
ApplicationRecord
validates
:author
,
uniqueness:
{
scope: :receiver
}
...
...
app/models/conversation_message.rb
View file @
32ecc3ce
# frozen_string_literal: true
class
ConversationMessage
<
ApplicationRecord
validates
:content
,
presence:
true
...
...
app/models/post.rb
View file @
32ecc3ce
...
...
@@ -6,7 +6,9 @@ class Post < ApplicationRecord
validates
:user
,
presence:
true
validates
:content_text
,
presence:
true
validates
:content_image
,
content_type:
[
'image/png'
,
'image/jpg'
,
'image/jpeg'
,
'image/svg'
]
validates
:content_file
,
content_type:
{
in:
[
'application/pdf'
,
'application/xls'
,
'application/doc'
,
'application/docx'
],
message:
"is not a valid MIME Type: PDF, XLS, DOC/X"
}
validates
:content_file
,
content_type:
{
in:
[
'application/pdf'
,
'application/xls'
,
'application/doc'
,
'application/docx'
],
message:
'is not a valid MIME Type: PDF, XLS, DOC/X'
}
belongs_to
:user
...
...
config/application.rb
View file @
32ecc3ce
...
...
@@ -4,7 +4,7 @@ require_relative 'boot'
require
'rails/all'
require
"
active_storage/engine
"
require
'
active_storage/engine
'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler
.
require
(
*
Rails
.
groups
)
...
...
config/initializers/assets.rb
View file @
32ecc3ce
...
...
@@ -15,4 +15,4 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails
.
application
.
config
.
assets
.
paths
<<
Rails
.
root
.
join
(
'app'
,
'assets'
,
'fonts'
)
\ No newline at end of file
Rails
.
application
.
config
.
assets
.
paths
<<
Rails
.
root
.
join
(
'app'
,
'assets'
,
'fonts'
)
test/controllers/users_controller_test.rb
View file @
32ecc3ce
# frozen_string_literal: true
require
'test_helper'
class
UsersControllerTest
<
ActionDispatch
::
IntegrationTest
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment