Fix all Style/RedundantSelf rubocop issues

This commit is contained in:
Bertocq
2017-07-04 22:53:25 +02:00
parent 97d7a21791
commit 2888c20489
40 changed files with 102 additions and 107 deletions

View File

@@ -475,11 +475,6 @@ Style/RedundantParentheses:
- 'spec/features/proposals_spec.rb' - 'spec/features/proposals_spec.rb'
- 'spec/models/debate_spec.rb' - 'spec/models/debate_spec.rb'
# Offense count: 49
# Cop supports --auto-correct.
Style/RedundantSelf:
Enabled: false
# Offense count: 3 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.

View File

@@ -3,7 +3,7 @@ module Abilities
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user)
self.merge Abilities::Moderation.new(user) merge Abilities::Moderation.new(user)
can :restore, Comment can :restore, Comment
cannot :restore, Comment, hidden_at: nil cannot :restore, Comment, hidden_at: nil

View File

@@ -3,7 +3,7 @@ module Abilities
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user)
self.merge Abilities::Everyone.new(user) merge Abilities::Everyone.new(user)
can [:read, :update], User, id: user.id can [:read, :update], User, id: user.id

View File

@@ -3,7 +3,7 @@ module Abilities
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user)
self.merge Abilities::Common.new(user) merge Abilities::Common.new(user)
can :read, Organization can :read, Organization
can(:verify, Organization){ |o| !o.verified? } can(:verify, Organization){ |o| !o.verified? }

View File

@@ -3,7 +3,7 @@ module Abilities
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user)
self.merge Abilities::Moderation.new(user) merge Abilities::Moderation.new(user)
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question, Legislation::Question, Legislation::Annotation] can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question, Legislation::Question, Legislation::Annotation]
end end

View File

@@ -7,17 +7,17 @@ class Ability
alias_action :hide_in_moderation_screen, to: :hide alias_action :hide_in_moderation_screen, to: :hide
if user # logged-in users if user # logged-in users
self.merge Abilities::Valuator.new(user) if user.valuator? merge Abilities::Valuator.new(user) if user.valuator?
if user.administrator? if user.administrator?
self.merge Abilities::Administrator.new(user) merge Abilities::Administrator.new(user)
elsif user.moderator? elsif user.moderator?
self.merge Abilities::Moderator.new(user) merge Abilities::Moderator.new(user)
else else
self.merge Abilities::Common.new(user) merge Abilities::Common.new(user)
end end
else else
self.merge Abilities::Everyone.new(user) merge Abilities::Everyone.new(user)
end end
end end

View File

@@ -28,7 +28,7 @@ class Budget < ActiveRecord::Base
scope :current, -> { where.not(phase: "finished") } scope :current, -> { where.not(phase: "finished") }
def description def description
self.send("description_#{self.phase}").try(:html_safe) send("description_#{phase}").try(:html_safe)
end end
def self.description_max_length def self.description_max_length
@@ -134,8 +134,8 @@ class Budget < ActiveRecord::Base
def sanitize_descriptions def sanitize_descriptions
s = WYSIWYGSanitizer.new s = WYSIWYGSanitizer.new
PHASES.each do |phase| PHASES.each do |phase|
sanitized = s.sanitize(self.send("description_#{phase}")) sanitized = s.sanitize(send("description_#{phase}"))
self.send("description_#{phase}=", sanitized) send("description_#{phase}=", sanitized)
end end
end end
end end

View File

@@ -33,7 +33,7 @@ class Budget
end end
def has_lines_in_group?(group) def has_lines_in_group?(group)
self.groups.include?(group) groups.include?(group)
end end
def wrong_budget?(heading) def wrong_budget?(heading)
@@ -54,7 +54,7 @@ class Budget
end end
def has_lines_with_heading? def has_lines_with_heading?
self.heading_id.present? heading_id.present?
end end
def has_lines_in_heading?(heading) def has_lines_in_heading?(heading)
@@ -62,12 +62,12 @@ class Budget
end end
def has_investment?(investment) def has_investment?(investment)
self.investment_ids.include?(investment.id) investment_ids.include?(investment.id)
end end
def heading_for_group(group) def heading_for_group(group)
return nil unless has_lines_in_group?(group) return nil unless has_lines_in_group?(group)
self.investments.where(group: group).first.heading investments.where(group: group).first.heading
end end
end end

View File

@@ -22,7 +22,7 @@ class Budget
end end
def check_valid_heading def check_valid_heading
errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") unless ballot.valid_heading?(self.heading) errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") unless ballot.valid_heading?(heading)
end end
def check_selected def check_selected
@@ -32,9 +32,9 @@ class Budget
private private
def set_denormalized_ids def set_denormalized_ids
self.heading_id ||= self.investment.try(:heading_id) self.heading_id ||= investment.try(:heading_id)
self.group_id ||= self.investment.try(:group_id) self.group_id ||= investment.try(:group_id)
self.budget_id ||= self.investment.try(:budget_id) self.budget_id ||= investment.try(:budget_id)
end end
end end
end end

View File

@@ -94,7 +94,7 @@ class Budget
end end
def self.search(terms) def self.search(terms)
self.pg_search(terms) pg_search(terms)
end end
def self.by_heading(heading) def self.by_heading(heading)
@@ -191,7 +191,7 @@ class Budget
end end
def enough_money?(ballot) def enough_money?(ballot)
available_money = ballot.amount_available(self.heading) available_money = ballot.amount_available(heading)
price.to_i <= available_money price.to_i <= available_money
end end
@@ -256,8 +256,8 @@ class Budget
private private
def set_denormalized_ids def set_denormalized_ids
self.group_id = self.heading.try(:group_id) if self.heading_id_changed? self.group_id = heading.try(:group_id) if heading_id_changed?
self.budget_id ||= self.heading.try(:group).try(:budget_id) self.budget_id ||= heading.try(:group).try(:budget_id)
end end
end end

View File

@@ -43,7 +43,7 @@ class Budget
end end
def ballot_lines_for_investment def ballot_lines_for_investment
Budget::Ballot::Line.by_investment(self.id) Budget::Ballot::Line.by_investment(id)
end end
end end

View File

@@ -100,7 +100,7 @@ class Comment < ActiveRecord::Base
end end
def call_after_commented def call_after_commented
self.commentable.try(:after_commented) commentable.try(:after_commented)
end end
def self.body_max_length def self.body_max_length

View File

@@ -9,7 +9,7 @@ module Filterable
class_methods do class_methods do
def filter(params) def filter(params)
resources = self.all resources = all
params.each do |filter, value| params.each do |filter, value|
if allowed_filter?(filter, value) if allowed_filter?(filter, value)
resources = resources.send("by_#{filter}", value) resources = resources.send("by_#{filter}", value)

View File

@@ -4,33 +4,33 @@ module Graphqlable
class_methods do class_methods do
def graphql_field_name def graphql_field_name
self.name.gsub('::', '_').underscore.to_sym name.gsub('::', '_').underscore.to_sym
end end
def graphql_field_description def graphql_field_description
"Find one #{self.model_name.human} by ID" "Find one #{model_name.human} by ID"
end end
def graphql_pluralized_field_name def graphql_pluralized_field_name
self.name.gsub('::', '_').underscore.pluralize.to_sym name.gsub('::', '_').underscore.pluralize.to_sym
end end
def graphql_pluralized_field_description def graphql_pluralized_field_description
"Find all #{self.model_name.human.pluralize}" "Find all #{model_name.human.pluralize}"
end end
def graphql_type_name def graphql_type_name
self.name.gsub('::', '_') name.gsub('::', '_')
end end
def graphql_type_description def graphql_type_description
(self.model_name.human).to_s (model_name.human).to_s
end end
end end
def public_created_at def public_created_at
self.created_at.change(min: 0) created_at.change(min: 0)
end end
end end

View File

@@ -1,5 +1,5 @@
module HasPublicAuthor module HasPublicAuthor
def public_author def public_author
self.author.public_activity? ? self.author : nil author.public_activity? ? author : nil
end end
end end

View File

@@ -4,11 +4,11 @@ module Measurable
class_methods do class_methods do
def title_max_length def title_max_length
@@title_max_length ||= (self.columns.find { |c| c.name == 'title' }.limit rescue nil) || 80 @@title_max_length ||= (columns.find { |c| c.name == 'title' }.limit rescue nil) || 80
end end
def responsible_name_max_length def responsible_name_max_length
@@responsible_name_max_length ||= (self.columns.find { |c| c.name == 'responsible_name' }.limit rescue nil) || 60 @@responsible_name_max_length ||= (columns.find { |c| c.name == 'responsible_name' }.limit rescue nil) || 60
end end
def question_max_length def question_max_length

View File

@@ -17,7 +17,7 @@ module Sanitizable
end end
def sanitize_tag_list def sanitize_tag_list
self.tag_list = TagSanitizer.new.sanitize_tag_list(self.tag_list) if self.class.taggable? self.tag_list = TagSanitizer.new.sanitize_tag_list(tag_list) if self.class.taggable?
end end
end end

View File

@@ -7,7 +7,7 @@ module SearchCache
def calculate_tsvector def calculate_tsvector
ActiveRecord::Base.connection.execute(" ActiveRecord::Base.connection.execute("
UPDATE #{self.class.table_name} SET tsv = (#{searchable_values_sql}) WHERE id = #{self.id}") UPDATE #{self.class.table_name} SET tsv = (#{searchable_values_sql}) WHERE id = #{id}")
end end
private private

View File

@@ -12,7 +12,7 @@ module Searchable
}, },
ignoring: :accents, ignoring: :accents,
ranked_by: '(:tsearch)', ranked_by: '(:tsearch)',
order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil) order_within_rank: (column_names.include?('cached_votes_up') ? "#{table_name}.cached_votes_up DESC" : nil)
} }
end end

View File

@@ -55,7 +55,7 @@ class Debate < ActiveRecord::Base
end end
def self.search(terms) def self.search(terms)
self.pg_search(terms) pg_search(terms)
end end
def to_param def to_param
@@ -124,15 +124,15 @@ class Debate < ActiveRecord::Base
end end
def after_hide def after_hide
self.tags.each{ |t| t.decrement_custom_counter_for('Debate') } tags.each{ |t| t.decrement_custom_counter_for('Debate') }
end end
def after_restore def after_restore
self.tags.each{ |t| t.increment_custom_counter_for('Debate') } tags.each{ |t| t.increment_custom_counter_for('Debate') }
end end
def featured? def featured?
self.featured_at.present? featured_at.present?
end end
end end

View File

@@ -45,7 +45,7 @@ class Legislation::Annotation < ActiveRecord::Base
end end
def create_first_comment def create_first_comment
comments.create(body: self.text, user: self.author) comments.create(body: text, user: author)
end end
def title def title

View File

@@ -12,7 +12,7 @@ class Notification < ActiveRecord::Base
end end
def mark_as_read def mark_as_read
self.destroy destroy
end end
def self.add(user_id, notifiable) def self.add(user_id, notifiable)

View File

@@ -23,12 +23,12 @@ class Officing::Residence
if user_exists? if user_exists?
self.user = find_user_by_document self.user = find_user_by_document
self.user.update(verified_at: Time.current) user.update(verified_at: Time.current)
else else
user_params = { user_params = {
document_number: document_number, document_number: document_number,
document_type: document_type, document_type: document_type,
geozone: self.geozone, geozone: geozone,
date_of_birth: date_of_birth.to_datetime, date_of_birth: date_of_birth.to_datetime,
gender: gender, gender: gender,
residence_verified_at: Time.current, residence_verified_at: Time.current,
@@ -115,7 +115,7 @@ class Officing::Residence
end end
def clean_document_number 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 end
def random_password def random_password

View File

@@ -39,11 +39,11 @@ class Organization < ActiveRecord::Base
end end
def self.name_max_length def self.name_max_length
@@name_max_length ||= self.columns.find { |c| c.name == 'name' }.limit || 60 @@name_max_length ||= columns.find { |c| c.name == 'name' }.limit || 60
end end
def self.responsible_name_max_length def self.responsible_name_max_length
@@responsible_name_max_length ||= self.columns.find { |c| c.name == 'responsible_name' }.limit || 60 @@responsible_name_max_length ||= columns.find { |c| c.name == 'responsible_name' }.limit || 60
end end
private private

View File

@@ -10,9 +10,9 @@ class Poll
before_save :update_logs before_save :update_logs
def update_logs def update_logs
if self.count_changed? && self.count_was.present? if count_changed? && count_was.present?
self.count_log += ":#{self.count_was.to_s}" self.count_log += ":#{count_was.to_s}"
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}" self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
end end
end end
end end

View File

@@ -14,10 +14,10 @@ class Poll::NullResult < ActiveRecord::Base
before_save :update_logs before_save :update_logs
def update_logs def update_logs
if self.amount_changed? && self.amount_was.present? if amount_changed? && amount_was.present?
self.amount_log += ":#{self.amount_was.to_s}" self.amount_log += ":#{amount_was.to_s}"
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}" self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
self.author_id_log += ":#{self.author_id_was.to_s}" self.author_id_log += ":#{author_id_was.to_s}"
end end
end end
end end

View File

@@ -19,10 +19,10 @@ class Poll::PartialResult < ActiveRecord::Base
before_save :update_logs before_save :update_logs
def update_logs def update_logs
if self.amount_changed? && self.amount_was.present? if amount_changed? && amount_was.present?
self.amount_log += ":#{self.amount_was.to_s}" self.amount_log += ":#{amount_was.to_s}"
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}" self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
self.author_id_log += ":#{self.author_id_was.to_s}" self.author_id_log += ":#{author_id_was.to_s}"
end end
end end
end end

View File

@@ -25,7 +25,7 @@ class Poll::Question < ActiveRecord::Base
scope :for_render, -> { includes(:author, :proposal) } scope :for_render, -> { includes(:author, :proposal) }
def self.search(params) def self.search(params)
results = self.all results = all
results = results.by_poll_id(params[:poll_id]) if params[:poll_id].present? results = results.by_poll_id(params[:poll_id]) if params[:poll_id].present?
results = results.pg_search(params[:search]) if params[:search].present? results = results.pg_search(params[:search]) if params[:search].present?
results results

View File

@@ -11,9 +11,9 @@ class Poll
before_save :update_logs before_save :update_logs
def update_logs def update_logs
if self.count_changed? && self.count_was.present? if count_changed? && count_was.present?
self.count_log += ":#{self.count_was.to_s}" self.count_log += ":#{count_was.to_s}"
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}" self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
end end
end end
end end

View File

@@ -14,10 +14,10 @@ class Poll::WhiteResult < ActiveRecord::Base
before_save :update_logs before_save :update_logs
def update_logs def update_logs
if self.amount_changed? && self.amount_was.present? if amount_changed? && amount_was.present?
self.amount_log += ":#{self.amount_was.to_s}" self.amount_log += ":#{amount_was.to_s}"
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}" self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
self.author_id_log += ":#{self.author_id_was.to_s}" self.author_id_log += ":#{author_id_was.to_s}"
end end
end end
end end

View File

@@ -71,12 +71,12 @@ class Proposal < ActiveRecord::Base
end end
def self.search(terms) def self.search(terms)
by_code = self.search_by_code(terms.strip) by_code = search_by_code(terms.strip)
by_code.present? ? by_code : self.pg_search(terms) by_code.present? ? by_code : pg_search(terms)
end end
def self.search_by_code(terms) def self.search_by_code(terms)
matched_code = self.match_code(terms) matched_code = match_code(terms)
results = where(id: matched_code[1]) if matched_code results = where(id: matched_code[1]) if matched_code
return results if (results.present? && results.first.code == terms) return results if (results.present? && results.first.code == terms)
end end
@@ -147,11 +147,11 @@ class Proposal < ActiveRecord::Base
end end
def after_hide def after_hide
self.tags.each{ |t| t.decrement_custom_counter_for('Proposal') } tags.each{ |t| t.decrement_custom_counter_for('Proposal') }
end end
def after_restore def after_restore
self.tags.each{ |t| t.increment_custom_counter_for('Proposal') } tags.each{ |t| t.increment_custom_counter_for('Proposal') }
end end
def self.votes_needed_for_success def self.votes_needed_for_success
@@ -163,7 +163,7 @@ class Proposal < ActiveRecord::Base
end end
def archived? def archived?
self.created_at <= Setting["months_to_archive_proposals"].to_i.months.ago created_at <= Setting["months_to_archive_proposals"].to_i.months.ago
end end
def notifications def notifications

View File

@@ -59,8 +59,8 @@ class Signature < ActiveRecord::Base
end end
def clean_document_number def clean_document_number
return if self.document_number.blank? return if document_number.blank?
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase
end end
def random_password def random_password

View File

@@ -22,7 +22,7 @@ class SignatureSheet < ActiveRecord::Base
def verify_signatures def verify_signatures
parsed_document_numbers.each do |document_number| parsed_document_numbers.each do |document_number|
signature = self.signatures.where(document_number: document_number).first_or_create signature = signatures.where(document_number: document_number).first_or_create
signature.verify signature.verify
end end
update(processed: true) update(processed: true)

View File

@@ -66,7 +66,7 @@ class SpendingProposal < ActiveRecord::Base
end end
def self.search(terms) def self.search(terms)
self.pg_search(terms) pg_search(terms)
end end
def self.by_geozone(geozone) def self.by_geozone(geozone)

View File

@@ -169,7 +169,7 @@ class User < ActiveRecord::Base
comments_ids = Comment.where(user_id: id).pluck(:id) comments_ids = Comment.where(user_id: id).pluck(:id)
proposal_ids = Proposal.where(author_id: id).pluck(:id) proposal_ids = Proposal.where(author_id: id).pluck(:id)
self.hide hide
Debate.hide_all debates_ids Debate.hide_all debates_ids
Comment.hide_all comments_ids Comment.hide_all comments_ids
@@ -177,7 +177,7 @@ class User < ActiveRecord::Base
end end
def erase(erase_reason = nil) def erase(erase_reason = nil)
self.update( update(
erased_at: Time.current, erased_at: Time.current,
erase_reason: erase_reason, erase_reason: erase_reason,
username: nil, username: nil,
@@ -191,7 +191,7 @@ class User < ActiveRecord::Base
confirmed_phone: nil, confirmed_phone: nil,
unconfirmed_phone: nil unconfirmed_phone: nil
) )
self.identities.destroy_all identities.destroy_all
end end
def erased? def erased?
@@ -201,17 +201,17 @@ class User < ActiveRecord::Base
def take_votes_if_erased_document(document_number, document_type) 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 erased_user = User.erased.where(document_number: document_number).where(document_type: document_type).first
if erased_user.present? if erased_user.present?
self.take_votes_from(erased_user) take_votes_from(erased_user)
erased_user.update(document_number: nil, document_type: nil) erased_user.update(document_number: nil, document_type: nil)
end end
end end
def take_votes_from(other_user) def take_votes_from(other_user)
return if other_user.blank? return if other_user.blank?
Poll::Voter.where(user_id: other_user.id).update_all(user_id: self.id) 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: self.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: self.id) Vote.where("voter_id = ? AND voter_type = ?", other_user.id, "User").update_all(voter_id: 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')}") update(former_users_data_log: "#{former_users_data_log} | id: #{other_user.id} - #{Time.current.strftime('%Y-%m-%d %H:%M:%S')}")
end end
def locked? def locked?
@@ -223,7 +223,7 @@ class User < ActiveRecord::Base
end end
def self.username_max_length 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 end
def self.minimum_required_age def self.minimum_required_age
@@ -257,10 +257,10 @@ class User < ActiveRecord::Base
def send_oauth_confirmation_instructions def send_oauth_confirmation_instructions
if oauth_email != email if oauth_email != email
self.update(confirmed_at: nil) update(confirmed_at: nil)
self.send_confirmation_instructions send_confirmation_instructions
end end
self.update(oauth_email: nil) if oauth_email.present? update(oauth_email: nil) if oauth_email.present?
end end
def name_and_email def name_and_email
@@ -274,11 +274,11 @@ class User < ActiveRecord::Base
def save_requiring_finish_signup def save_requiring_finish_signup
begin begin
self.registering_with_oauth = true 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 # Devise puts unique constraints for the email the db, so we must detect & handle that
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
self.email = nil self.email = nil
self.save(validate: false) save(validate: false)
end end
true true
end end
@@ -311,7 +311,7 @@ class User < ActiveRecord::Base
private private
def clean_document_number 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 end
def validate_username_length def validate_username_length

View File

@@ -27,7 +27,7 @@ class Verification::Email
end end
def self.find(user, token) def self.find(user, token)
self.valid_token?(user, token) valid_token?(user, token)
end end
def self.valid_token?(user, token) def self.valid_token?(user, token)

View File

@@ -31,7 +31,7 @@ class Verification::Residence
user.update(document_number: document_number, user.update(document_number: document_number,
document_type: document_type, document_type: document_type,
geozone: self.geozone, geozone: geozone,
date_of_birth: date_of_birth.to_datetime, date_of_birth: date_of_birth.to_datetime,
gender: gender, gender: gender,
residence_verified_at: Time.current) residence_verified_at: Time.current)
@@ -39,7 +39,7 @@ class Verification::Residence
def allowed_age def allowed_age
return if errors[:date_of_birth].any? return if errors[:date_of_birth].any?
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless Age.in_years(self.date_of_birth) >= User.minimum_required_age errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless Age.in_years(date_of_birth) >= User.minimum_required_age
end end
def document_number_uniqueness def document_number_uniqueness
@@ -81,7 +81,7 @@ class Verification::Residence
end end
def clean_document_number 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 end
end end

View File

@@ -12,7 +12,7 @@ class Verification::Sms
end end
def save def save
return false unless self.valid? return false unless valid?
update_user_phone_information update_user_phone_information
send_sms send_sms
Lock.increase_tries(user) Lock.increase_tries(user)

View File

@@ -2,7 +2,7 @@ module ActsAsParanoidAliases
def self.included(base) def self.included(base)
base.extend(ClassMethods) base.extend(ClassMethods)
self.class_eval do class_eval do
def hide def hide
return false if hidden? return false if hidden?

View File

@@ -1,5 +1,5 @@
class Numeric class Numeric
def percent_of(n) def percent_of(n)
(self.to_f / n * 100).to_i (to_f / n * 100).to_i
end end
end end