Fix all Style/RedundantSelf rubocop issues
This commit is contained in:
@@ -169,7 +169,7 @@ class User < ActiveRecord::Base
|
||||
comments_ids = Comment.where(user_id: id).pluck(:id)
|
||||
proposal_ids = Proposal.where(author_id: id).pluck(:id)
|
||||
|
||||
self.hide
|
||||
hide
|
||||
|
||||
Debate.hide_all debates_ids
|
||||
Comment.hide_all comments_ids
|
||||
@@ -177,7 +177,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def erase(erase_reason = nil)
|
||||
self.update(
|
||||
update(
|
||||
erased_at: Time.current,
|
||||
erase_reason: erase_reason,
|
||||
username: nil,
|
||||
@@ -191,7 +191,7 @@ class User < ActiveRecord::Base
|
||||
confirmed_phone: nil,
|
||||
unconfirmed_phone: nil
|
||||
)
|
||||
self.identities.destroy_all
|
||||
identities.destroy_all
|
||||
end
|
||||
|
||||
def erased?
|
||||
@@ -201,17 +201,17 @@ class User < ActiveRecord::Base
|
||||
def take_votes_if_erased_document(document_number, document_type)
|
||||
erased_user = User.erased.where(document_number: document_number).where(document_type: document_type).first
|
||||
if erased_user.present?
|
||||
self.take_votes_from(erased_user)
|
||||
take_votes_from(erased_user)
|
||||
erased_user.update(document_number: nil, document_type: nil)
|
||||
end
|
||||
end
|
||||
|
||||
def take_votes_from(other_user)
|
||||
return if other_user.blank?
|
||||
Poll::Voter.where(user_id: other_user.id).update_all(user_id: self.id)
|
||||
Budget::Ballot.where(user_id: other_user.id).update_all(user_id: self.id)
|
||||
Vote.where("voter_id = ? AND voter_type = ?", other_user.id, "User").update_all(voter_id: self.id)
|
||||
self.update(former_users_data_log: "#{self.former_users_data_log} | id: #{other_user.id} - #{Time.current.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
Poll::Voter.where(user_id: other_user.id).update_all(user_id: id)
|
||||
Budget::Ballot.where(user_id: other_user.id).update_all(user_id: id)
|
||||
Vote.where("voter_id = ? AND voter_type = ?", other_user.id, "User").update_all(voter_id: id)
|
||||
update(former_users_data_log: "#{former_users_data_log} | id: #{other_user.id} - #{Time.current.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
end
|
||||
|
||||
def locked?
|
||||
@@ -223,7 +223,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.username_max_length
|
||||
@@username_max_length ||= self.columns.find { |c| c.name == 'username' }.limit || 60
|
||||
@@username_max_length ||= columns.find { |c| c.name == 'username' }.limit || 60
|
||||
end
|
||||
|
||||
def self.minimum_required_age
|
||||
@@ -257,10 +257,10 @@ class User < ActiveRecord::Base
|
||||
|
||||
def send_oauth_confirmation_instructions
|
||||
if oauth_email != email
|
||||
self.update(confirmed_at: nil)
|
||||
self.send_confirmation_instructions
|
||||
update(confirmed_at: nil)
|
||||
send_confirmation_instructions
|
||||
end
|
||||
self.update(oauth_email: nil) if oauth_email.present?
|
||||
update(oauth_email: nil) if oauth_email.present?
|
||||
end
|
||||
|
||||
def name_and_email
|
||||
@@ -274,11 +274,11 @@ class User < ActiveRecord::Base
|
||||
def save_requiring_finish_signup
|
||||
begin
|
||||
self.registering_with_oauth = true
|
||||
self.save(validate: false)
|
||||
save(validate: false)
|
||||
# Devise puts unique constraints for the email the db, so we must detect & handle that
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
self.email = nil
|
||||
self.save(validate: false)
|
||||
save(validate: false)
|
||||
end
|
||||
true
|
||||
end
|
||||
@@ -311,7 +311,7 @@ class User < ActiveRecord::Base
|
||||
private
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
|
||||
self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase if document_number.present?
|
||||
end
|
||||
|
||||
def validate_username_length
|
||||
|
||||
Reference in New Issue
Block a user