mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
rubocop autocorret to get tests green
This commit is contained in:
parent
c0caf53878
commit
2d6ed7fa45
24 changed files with 105 additions and 112 deletions
|
@ -11,6 +11,7 @@ class Admin::ContactVersionsController < AdminController
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def set_contact
|
||||
@contact = Contact.find(params[:id])
|
||||
end
|
||||
|
|
|
@ -11,6 +11,7 @@ class Admin::DomainVersionsController < AdminController
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ class Client::ContactsController < ClientController
|
|||
redirect_to [:client, @contact]
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_create_contact')
|
||||
render "new"
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -63,7 +63,7 @@ class Client::ContactsController < ClientController
|
|||
end
|
||||
|
||||
def contact_params
|
||||
params.require(:contact).permit( :email, :phone, :fax, :ident_type, :ident, :auth_info, :name, :org_name,
|
||||
params.require(:contact).permit(:email, :phone, :fax, :ident_type, :ident, :auth_info, :name, :org_name,
|
||||
address_attributes: [:city, :street, :zip, :street2, :street3, :country_id])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class SessionsController < Devise::SessionsController
|
||||
def create
|
||||
#TODO: Create ID Card login here:
|
||||
# TODO: Create ID Card login here:
|
||||
# this is just testing config
|
||||
# if Rails.env.development? || Rails.env.test?
|
||||
@user = User.find_by(username: 'gitlab') if params[:gitlab]
|
||||
|
@ -10,8 +10,7 @@ class SessionsController < Devise::SessionsController
|
|||
session[:current_user_registrar_id] = Registrar.first.id if @user.admin?
|
||||
|
||||
flash[:notice] = I18n.t('shared.welcome')
|
||||
sign_in_and_redirect @user, :event => :authentication
|
||||
return
|
||||
sign_in_and_redirect @user, event: :authentication
|
||||
# end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module ApplicationHelper
|
||||
def coffee_script_tag(&block)
|
||||
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, :type => 'text/javascript')
|
||||
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, type: 'text/javascript')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,11 +54,11 @@ module Epp::ContactsHelper
|
|||
## CREATE
|
||||
def validate_contact_create_request
|
||||
@ph = params_hash['epp']['command']['create']['create']
|
||||
xml_attrs_present?(@ph, [ %w(authInfo pw), %w(postalInfo)])
|
||||
xml_attrs_present?(@ph, [%w(authInfo pw), %w(postalInfo)])
|
||||
|
||||
return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
|
||||
|
||||
#(epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten!
|
||||
# (epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten!
|
||||
xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)])
|
||||
end
|
||||
|
||||
|
@ -114,7 +114,7 @@ module Epp::ContactsHelper
|
|||
|
||||
def owner?
|
||||
return false unless find_contact
|
||||
#return true if current_epp_user.registrar == find_contact.created_by.try(:registrar)
|
||||
# return true if current_epp_user.registrar == find_contact.created_by.try(:registrar)
|
||||
return true if @contact.registrar == current_epp_user.registrar
|
||||
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
|
||||
false
|
||||
|
|
|
@ -7,12 +7,12 @@ module Epp::DomainsHelper
|
|||
|
||||
if @domain.errors.any?
|
||||
handle_errors(@domain)
|
||||
raise ActiveRecord::Rollback and return
|
||||
fail ActiveRecord::Rollback and return
|
||||
end
|
||||
|
||||
unless @domain.save
|
||||
handle_errors(@domain)
|
||||
raise ActiveRecord::Rollback and return
|
||||
fail ActiveRecord::Rollback and return
|
||||
end
|
||||
|
||||
render '/epp/domains/create'
|
||||
|
@ -55,12 +55,12 @@ module Epp::DomainsHelper
|
|||
|
||||
if @domain.errors.any?
|
||||
handle_errors(@domain)
|
||||
raise ActiveRecord::Rollback and return
|
||||
fail ActiveRecord::Rollback and return
|
||||
end
|
||||
|
||||
unless @domain.save
|
||||
handle_errors(@domain)
|
||||
raise ActiveRecord::Rollback and return
|
||||
fail ActiveRecord::Rollback and return
|
||||
end
|
||||
|
||||
render '/epp/domains/success'
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -18,7 +18,5 @@ module UserEvents
|
|||
def epp_user_events(id)
|
||||
where(whodunnit: "#{id}-EppUser")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,5 +5,4 @@ class ContactVersion < PaperTrail::Version
|
|||
|
||||
self.table_name = :contact_versions
|
||||
self.sequence_name = :contact_version_id_seq
|
||||
|
||||
end
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue