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

@ -11,6 +11,7 @@ class Admin::ContactVersionsController < AdminController
end
private
def set_contact
@contact = Contact.find(params[:id])
end

View file

@ -11,6 +11,7 @@ class Admin::DomainVersionsController < AdminController
end
private
def set_domain
@domain = Domain.find(params[:id])
end

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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'

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

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

@ -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

@ -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(

View file

@ -41,12 +41,12 @@ Devise.setup do |config|
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [ :email ]
config.case_insensitive_keys = [:email]
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
config.strip_whitespace_keys = [ :email ]
config.strip_whitespace_keys = [:email]
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the

View file

@ -66,10 +66,10 @@ Rails.application.routes.draw do
end
authenticated :user do
root :to => 'admin/domains#index', :as => :authenticated_root
root to: 'admin/domains#index', as: :authenticated_root
end
root :to => redirect('login')
root to: redirect('login')
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

View file

@ -2,12 +2,12 @@ desc 'Commands for whois'
desc 'generate whois files'
task 'whois:generate' => :environment do
Dir.mkdir("./tmp/whois") unless File.exists?("./tmp/whois") #a folder for ze stuff
Dir.mkdir('./tmp/whois') unless File.exist?('./tmp/whois') # a folder for ze stuff
alphabet = (("a".."z").to_a << %w(ö õ ü ä) ).flatten!
alphabet = (('a'..'z').to_a << %w(ö õ ü ä)).flatten!
@domains = {}
alphabet.each do |letter|
domains = Domain.where([ 'name LIKE ?', "#{letter}%" ])
domains = Domain.where(['name LIKE ?', "#{letter}%"])
@domains[letter] = {}
domains.each do |domain|
@ -22,9 +22,8 @@ task 'whois:generate' => :environment do
end
end
@domains.each do |k,v|
@domains.each do |k, v|
file = File.open("tmp/whois/#{k}_domain.yaml", 'w') { |f| f.write(v.to_yaml) }
end
end

View file

@ -33,7 +33,7 @@ describe 'EPP Contact', epp: true do
expect(response[:result_code]).to eq('1000')
expect(response[:msg]).to eq('Command completed successfully')
#expect(response[:clTRID]).to eq('ABC-12345')
# expect(response[:clTRID]).to eq('ABC-12345')
expect(Contact.first.created_by_id).to eq 2
expect(Contact.first.updated_by_id).to eq nil

View file

@ -273,7 +273,7 @@ describe 'EPP Domain', epp: true do
xml = domain_create_xml({
ns: [
{ hostObj: { value: 'invalid1-' } },
{ hostObj: { value: '-invalid2' } },
{ hostObj: { value: '-invalid2' } }
]
})
@ -314,7 +314,7 @@ describe 'EPP Domain', epp: true do
it 'does not create a domain with invalid period' do
xml = domain_create_xml({
period: {value: '367', attrs: { unit: 'd' } }
period: { value: '367', attrs: { unit: 'd' } }
})
response = epp_request(xml, :xml)
@ -580,12 +580,12 @@ describe 'EPP Domain', epp: true do
expect(inf_data.css('status').first[:s]).to eq('clientHold')
expect(inf_data.css('registrant').text).to eq(d.owner_contact_code)
admin_contacts_from_request = inf_data.css('contact[type="admin"]').map { |x| x.text }
admin_contacts_from_request = inf_data.css('contact[type="admin"]').map(&:text)
admin_contacts_existing = d.admin_contacts.pluck(:code)
expect(admin_contacts_from_request).to eq(admin_contacts_existing)
hosts_from_request = inf_data.css('hostObj').map { |x| x.text }
hosts_from_request = inf_data.css('hostObj').map(&:text)
hosts_existing = d.nameservers.where(ipv4: nil).pluck(:hostname)
expect(hosts_from_request).to eq(hosts_existing)

View file

@ -72,16 +72,16 @@ describe 'EPP Helper', epp: true do
xml = domain_create_xml({
name: { value: 'one.ee' },
period: {value: '345', attrs: { unit: 'd' } },
period: { value: '345', attrs: { unit: 'd' } },
ns: [
{ hostObj: {value: 'ns1.test.net' } },
{ hostObj: {value: 'ns2.test.net' } }
{ hostObj: { value: 'ns1.test.net' } },
{ hostObj: { value: 'ns2.test.net' } }
],
registrant: { value: '32fsdaf' },
_other: [
{ contact: {value: '2323rafaf', attrs: { type: 'admin' } } },
{ contact: {value: '3dgxx', attrs: { type: 'tech' } } },
{ contact: {value: '345xxv', attrs: { type: 'tech' } } }
{ contact: { value: '2323rafaf', attrs: { type: 'admin' } } },
{ contact: { value: '3dgxx', attrs: { type: 'tech' } } },
{ contact: { value: '345xxv', attrs: { type: 'tech' } } }
]
})
@ -452,7 +452,6 @@ describe 'EPP Helper', epp: true do
generated = Nokogiri::XML(domain_delete_xml).to_s.squish
expect(generated).to eq(expected)
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>

View file

@ -1,8 +1,8 @@
require 'rails_helper'
feature 'Contact management', type: :feature do
#background do
#end
# background do
# end
before(:each) do
Fabricate(:user, country: Fabricate(:country, iso: 'EE'), admin: false, username: 'zone')

View file

@ -74,7 +74,7 @@ end
describe Contact, '#up_id' do
before(:each) do
#Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user), registrar: zone)
# Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user), registrar: zone)
@epp_user = Fabricate(:epp_user)
@contact = Fabricate.build(:contact, code: 'asd12', created_by: @epp_user, updated_by: @epp_user)
end