rubocop autocorret to get tests green

This commit is contained in:
Priit Tamboom 2014-10-10 15:10:05 +03:00
parent c0caf53878
commit 2d6ed7fa45
24 changed files with 105 additions and 112 deletions

View file

@ -2,8 +2,7 @@ class Ability
include CanCan::Ability
def initialize(user)
alias_action :create, :read, :update, :destroy, :to => :crud
alias_action :create, :read, :update, :destroy, to: :crud
user ||= User.new
@ -37,7 +36,7 @@ class Ability
can :read, DomainTransfer, transfer_to_id: user.registrar.id
can :read, DomainTransfer, transfer_from_id: user.registrar.id
can :approve_as_client, DomainTransfer,
transfer_from_id: user.registrar.id, status: DomainTransfer::PENDING
transfer_from_id: user.registrar.id, status: DomainTransfer::PENDING
end
# Define abilities for the passed in user here. For example:

View file

@ -13,19 +13,19 @@ class Address < ActiveRecord::Base
has_paper_trail class_name: 'AddressVersion'
class << self
# def validate_postal_info_types(parsed_frame)
# errors, used = [], []
# parsed_frame.css('postalInfo').each do |pi|
# attr = pi.attributes['type'].try(:value)
# errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') } and next unless attr
# unless TYPES.include?(attr)
# errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } }
# next
# end
# errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr)
# used << attr
# end; errors
# end
# def validate_postal_info_types(parsed_frame)
# errors, used = [], []
# parsed_frame.css('postalInfo').each do |pi|
# attr = pi.attributes['type'].try(:value)
# errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') } and next unless attr
# unless TYPES.include?(attr)
# errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } }
# next
# end
# errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr)
# used << attr
# end; errors
# end
def extract_attributes(ah)
address_hash = {}
@ -36,10 +36,10 @@ class Address < ActiveRecord::Base
private
# def local?(postal_info)
# return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT
# :international_address_attributes
# end
# def local?(postal_info)
# return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT
# :international_address_attributes
# end
def addr_hash_from_params(addr)
return {} if addr.nil?

View file

@ -25,7 +25,7 @@ module EppErrors
values.each do |err|
code, value = find_epp_code_and_value(err)
next unless code
epp_errors << { code: code, msg: err, value: value}
epp_errors << { code: code, msg: err, value: value }
end
epp_errors
end
@ -37,7 +37,7 @@ module EppErrors
epp_errors = []
send(key).each do |x|
x.errors.messages.each do |key, values|
x.errors.messages.each do |_key, values|
epp_errors << x.collect_parent_errors(values)
end
end if multi.include?(macro)

View file

@ -18,7 +18,5 @@ module UserEvents
def epp_user_events(id)
where(whodunnit: "#{id}-EppUser")
end
end
end

View file

@ -5,8 +5,8 @@ class Contact < ActiveRecord::Base
include EppErrors
#has_one :local_address, dependent: :destroy
#has_one :international_address, dependent: :destroy
# has_one :local_address, dependent: :destroy
# has_one :international_address, dependent: :destroy
has_one :address, dependent: :destroy
has_one :disclosure, class_name: 'ContactDisclosure'
@ -20,22 +20,22 @@ class Contact < ActiveRecord::Base
accepts_nested_attributes_for :address, :disclosure
validates :code, :phone, :email, :ident, :address, :registrar,presence: true
validates :code, :phone, :email, :ident, :address, :registrar, presence: true
validate :ident_must_be_valid
#validate :presence_of_one_address
# validate :presence_of_one_address
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
validates :email, format: /@/
validates :code, uniqueness: { message: :epp_id_taken }
delegate :country, to: :address#, prefix: true
delegate :city, to: :address#, prefix: true
delegate :street, to: :address#, prefix: true
delegate :zip, to: :address#, prefix: true
delegate :country, to: :address # , prefix: true
delegate :city, to: :address # , prefix: true
delegate :street, to: :address # , prefix: true
delegate :zip, to: :address # , prefix: true
#scopes
# scopes
scope :current_registrars, ->(id) { where(registrar_id: id) }
# archiving
has_paper_trail class_name: 'ContactVersion'
@ -97,7 +97,6 @@ class Contact < ActiveRecord::Base
# should use only in transaction
def destroy_and_clean
if relations_with_domain?
errors.add(:domains, :exist)
return false

View file

@ -5,5 +5,4 @@ class ContactVersion < PaperTrail::Version
self.table_name = :contact_versions
self.sequence_name = :contact_version_id_seq
end

View file

@ -19,17 +19,17 @@ class Domain < ActiveRecord::Base
has_many :nameservers, dependent: :delete_all
accepts_nested_attributes_for :nameservers, allow_destroy: true,
reject_if: proc { |attrs| attrs[:hostname].blank? }
reject_if: proc { |attrs| attrs[:hostname].blank? }
has_many :domain_statuses, dependent: :delete_all
accepts_nested_attributes_for :domain_statuses, allow_destroy: true,
reject_if: proc { |attrs| attrs[:value].blank? }
reject_if: proc { |attrs| attrs[:value].blank? }
has_many :domain_transfers, dependent: :delete_all
has_many :dnskeys, dependent: :delete_all
accepts_nested_attributes_for :dnskeys, allow_destroy: true,
reject_if: proc { |attrs| attrs[:public_key].blank? }
reject_if: proc { |attrs| attrs[:public_key].blank? }
delegate :code, to: :owner_contact, prefix: true
delegate :email, to: :owner_contact, prefix: true
@ -118,7 +118,7 @@ class Domain < ActiveRecord::Base
def validate_nameserver_ips
nameservers.each do |ns|
next if !ns.hostname.end_with?(name)
next unless ns.hostname.end_with?(name)
next if ns.ipv4.present?
errors.add(:nameservers, :invalid) if errors[:nameservers].blank?
ns.errors.add(:ipv4, :blank)

View file

@ -24,16 +24,16 @@ class Epp::EppDomain < Domain
],
'2004' => [ # Parameter value range error
[:nameservers, :out_of_range,
{
min: domain_validation_sg.setting(:ns_min_count).value,
max: domain_validation_sg.setting(:ns_max_count).value
}
{
min: domain_validation_sg.setting(:ns_min_count).value,
max: domain_validation_sg.setting(:ns_max_count).value
}
],
[:dnskeys, :out_of_range,
{
min: domain_validation_sg.setting(:dnskeys_min_count).value,
max: domain_validation_sg.setting(:dnskeys_max_count).value
}
{
min: domain_validation_sg.setting(:dnskeys_min_count).value,
max: domain_validation_sg.setting(:dnskeys_max_count).value
}
],
[:period, :out_of_range, { value: { obj: 'period', val: period } }]
],
@ -71,8 +71,8 @@ class Epp::EppDomain < Domain
# TODO: Find out if there are any attributes that can be changed
# if not, delete this method
def parse_and_update_domain_attributes(parsed_frame)
#assign_attributes(self.class.parse_update_params_from_frame(parsed_frame))
def parse_and_update_domain_attributes(_parsed_frame)
# assign_attributes(self.class.parse_update_params_from_frame(parsed_frame))
errors.empty?
end

View file

@ -1,14 +1,13 @@
class Registrar < ActiveRecord::Base
belongs_to :country
has_many :domains, :dependent => :restrict_with_error
has_many :contacts, :dependent => :restrict_with_error
has_many :epp_users, :dependent => :restrict_with_error
has_many :users, :dependent => :restrict_with_error
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
has_many :epp_users, dependent: :restrict_with_error
has_many :users, dependent: :restrict_with_error
validates :name, :reg_no, :address, :country, presence: true
validates :name, :reg_no, uniqueness: true
def domain_transfers
at = DomainTransfer.arel_table
DomainTransfer.where(